diff --git a/docs/src/main/asciidoc/ghpages.sh b/docs/src/main/asciidoc/ghpages.sh index 57c5da3a..55e76be1 100755 --- a/docs/src/main/asciidoc/ghpages.sh +++ b/docs/src/main/asciidoc/ghpages.sh @@ -40,7 +40,7 @@ function check_if_anything_to_sync() { function retrieve_current_branch() { # Code getting the name of the current branch. For master we want to publish as we did until now - # http://stackoverflow.com/questions/1593051/how-to-programmatically-determine-the-current-checked-out-git-branch + # https://stackoverflow.com/questions/1593051/how-to-programmatically-determine-the-current-checked-out-git-branch # If there is a branch already passed will reuse it - otherwise will try to find it CURRENT_BRANCH=${BRANCH} if [[ -z "${CURRENT_BRANCH}" ]] ; then @@ -147,7 +147,7 @@ function copy_docs_for_current_version() { COMMIT_CHANGES="yes" else echo -e "Current branch is [${CURRENT_BRANCH}]" - # http://stackoverflow.com/questions/29300806/a-bash-script-to-check-if-a-string-is-present-in-a-comma-separated-list-of-strin + # https://stackoverflow.com/questions/29300806/a-bash-script-to-check-if-a-string-is-present-in-a-comma-separated-list-of-strin if [[ ",${WHITELISTED_BRANCHES_VALUE}," = *",${CURRENT_BRANCH},"* ]] ; then mkdir -p ${ROOT_FOLDER}/${CURRENT_BRANCH} echo -e "Branch [${CURRENT_BRANCH}] is whitelisted! Will copy the current docs to the [${CURRENT_BRANCH}] folder" diff --git a/mvnw b/mvnw index a69491ac..675cb6b0 100755 --- a/mvnw +++ b/mvnw @@ -8,7 +8,7 @@ # "License"); you may not use this file except in compliance # with the License. You may obtain a copy of the License at # -# http://www.apache.org/licenses/LICENSE-2.0 +# https://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, # software distributed under the License is distributed on an diff --git a/mvnw.cmd b/mvnw.cmd index b0dc0e7e..7ecd01d8 100644 --- a/mvnw.cmd +++ b/mvnw.cmd @@ -7,7 +7,7 @@ @REM "License"); you may not use this file except in compliance @REM with the License. You may obtain a copy of the License at @REM -@REM http://www.apache.org/licenses/LICENSE-2.0 +@REM https://www.apache.org/licenses/LICENSE-2.0 @REM @REM Unless required by applicable law or agreed to in writing, @REM software distributed under the License is distributed on an diff --git a/spring-cloud-config-monitor/src/test/resources/gitea.json b/spring-cloud-config-monitor/src/test/resources/gitea.json new file mode 100755 index 00000000..c60e4d2c --- /dev/null +++ b/spring-cloud-config-monitor/src/test/resources/gitea.json @@ -0,0 +1,81 @@ +{ + "secret": "gitea_push", + "ref": "refs/heads/master", + "before": "70767b558d8f850eac3fead13dfc232d043646a0", + "after": "78b77379c448caf024c73fa280ca571449224590", + "compare_url": "https://gitea.lawyers.corp/internal/lawsuits/compare/70767b558d8f850eac3fead13dfc232d043646a0...78b77379c448caf024c73fa280ca571449224590", + "commits": [ + { + "id": "78b77379c448caf024c73fa280ca571449224590", + "message": "SUPPORT-4765: urlencode\n", + "url": "https://gitea.lawyers.corp/internal/lawsuits/commit/78b77379c448caf024c73fa280ca571449224590", + "author": { + "name": "Perry Mason", + "email": "perrym@lawyers.corp", + "username": "git" + }, + "committer": { + "name": "Perry Mason", + "email": "perrym@lawyers.corp", + "username": "git" + }, + "verification": null, + "timestamp": "2018-08-27T11:18:34Z" + } + ], + "repository": { + "id": 480, + "owner": { + "id": 3, + "login": "internal", + "full_name": "", + "email": "", + "avatar_url": "https://gitea.lawyers.corp/avatars/dbc87f99ecd29cb0eb4447807ad73f9f", + "language": "", + "username": "internal" + }, + "name": "lawsuits", + "full_name": "internal/lawsuits", + "description": "", + "empty": false, + "private": false, + "fork": false, + "parent": null, + "mirror": false, + "size": 5516, + "html_url": "https://gitea.lawyers.corp/internal/lawsuits", + "ssh_url": "git@localhost:internal/lawsuits.git", + "clone_url": "https://gitea.lawyers.corp/internal/lawsuits.git", + "website": "", + "stars_count": 1, + "forks_count": 20, + "watchers_count": 6, + "open_issues_count": 0, + "default_branch": "master", + "created_at": "2018-01-18T15:11:51Z", + "updated_at": "2018-08-27T11:18:34Z", + "permissions": { + "admin": false, + "push": false, + "pull": false + } + }, + "pusher": { + "id": 2, + "login": "perrym", + "full_name": "Perry Mason", + "email": "perrym@lawyers.corp", + "avatar_url": "https://gitea.lawyers.corp/avatars/5868737ae078a4441031bf550d16e967", + "language": "en-US", + "username": "perrym" + }, + "sender": { + "id": 2, + "login": "perrym", + "full_name": "Perry Mason", + "email": "perrym@lawyers.corp", + "avatar_url": "https://gitea.lawyers.corp/avatars/5868737ae078a4441031bf550d16e967", + "language": "en-US", + "username": "perrym" + } +} \ No newline at end of file diff --git a/spring-cloud-config-monitor/src/test/resources/gitee.json b/spring-cloud-config-monitor/src/test/resources/gitee.json new file mode 100644 index 00000000..4be60313 --- /dev/null +++ b/spring-cloud-config-monitor/src/test/resources/gitee.json @@ -0,0 +1,54 @@ +{ + "before": "fb32ef5812dc132ece716a05c50c7531c6dc1b4d", + "after": "ac63b9ba95191a1bf79d60bc262851a66c12cda1", + "ref": "refs/heads/master", + "user_id": 13, + "user_name": "123", + "user": { + "name": "123", + "username": "test123", + "url": "https://gitee.com/oschina" + }, + "repository": { + "name": "webhook", + "url": "https://git.oschina.net/oschina/webhook", + "description": "", + "homepage": "https://gitee.com/oschina/webhook" + }, + "commits": [{ + "id": "ac63b9ba95191a1bf79d60bc262851a66c12cda1", + "message": "1234 bug fix", + "timestamp": "2016-12-09T17:28:02 08:00", + "url": "https://gitee.com/oschina/webhook/commit/ac63b9ba95191a1bf79d60bc262851a66c12cda1", + "author": { + "name": "123", + "email": "123@123.com", + "time": "2016-12-09T17:28:02 08:00" + }, + "added": [ + "d.txt" + ], + "modified": [ + "c.txt" + ], + "removed": [ + "b.txt" + ] + }], + "total_commits_count": 1, + "commits_more_than_ten": false, + "project": { + "name": "webhook", + "path": "webhook", + "url": "https://gitee.com/oschina/webhook", + "git_ssh_url": "git@gitee.com:oschina/webhook.git", + "git_http_url": "https://gitee.com/oschina/webhook.git", + "git_svn_url": "svn://gitee.com/oschina/webhook", + "namespace": "oschina", + "name_with_namespace": "oschina/webhook", + "path_with_namespace": "oschina/webhook", + "default_branch": "master" + }, + "hook_name": "push_hooks", + "password": "pwd" +} diff --git a/spring-cloud-config-monitor/src/test/resources/gitlab.json b/spring-cloud-config-monitor/src/test/resources/gitlab.json new file mode 100644 index 00000000..6599a109 --- /dev/null +++ b/spring-cloud-config-monitor/src/test/resources/gitlab.json @@ -0,0 +1,65 @@ +{ + "object_kind": "push", + "before": "95790bf891e76fee5e1747ab589903a6a1f80f22", + "after": "da1560886d4f094c3e6c9ef40349f7d38b5d27d7", + "ref": "refs/heads/master", + "user_id": 4, + "user_name": "John Smith", + "user_email": "john@example.com", + "user_avatar": "https://s.gravatar.com/avatar/d4c74594d841139328695756648b6bd6?s=8://s.gravatar.com/avatar/d4c74594d841139328695756648b6bd6?s=80", + "project_id": 15, + "project":{ + "name":"Diaspora", + "description":"", + "web_url":"https://example.com/mike/diaspora", + "avatar_url":null, + "git_ssh_url":"git@example.com:mike/diaspora.git", + "git_http_url":"https://example.com/mike/diaspora.git", + "namespace":"Mike", + "visibility_level":0, + "path_with_namespace":"mike/diaspora", + "default_branch":"master", + "homepage":"https://example.com/mike/diaspora", + "url":"git@example.com:mike/diasporadiaspora.git", + "ssh_url":"git@example.com:mike/diaspora.git", + "http_url":"https://example.com/mike/diaspora.git" + }, + "repository":{ + "name": "Diaspora", + "url": "git@example.com:mike/diasporadiaspora.git", + "description": "", + "homepage": "https://example.com/mike/diaspora", + "git_http_url":"https://example.com/mike/diaspora.git", + "git_ssh_url":"git@example.com:mike/diaspora.git", + "visibility_level":0 + }, + "commits": [ + { + "id": "b6568db1bc1dcd7f8b4d5a946b0b91f9dacd7327", + "message": "Update Catalan translation to e38cb41.", + "timestamp": "2011-12-12T14:27:31+02:00", + "url": "https://example.com/mike/diaspora/commit/b6568db1bc1dcd7f8b4d5a946b0b91f9dacd7327", + "author": { + "name": "Jordi Mallach", + "email": "jordi@softcatala.org" + }, + "added": ["newapp.properties"], + "modified": ["application.yml"], + "removed": [] + }, + { + "id": "da1560886d4f094c3e6c9ef40349f7d38b5d27d7", + "message": "fixed readme", + "timestamp": "2012-01-03T23:36:29+02:00", + "url": "https://example.com/mike/diaspora/commit/da1560886d4f094c3e6c9ef40349f7d38b5d27d7", + "author": { + "name": "GitLab dev user", + "email": "gitlabdev@dv6700.(none)" + }, + "added": [], + "modified": ["oldapp.yml"], + "removed": [] + } + ], + "total_commits_count": 4 +} \ No newline at end of file diff --git a/spring-cloud-config-server/src/main/java/org/springframework/cloud/config/server/resource/ResourceController.java b/spring-cloud-config-server/src/main/java/org/springframework/cloud/config/server/resource/ResourceController.java index 0ad1b68b..1a28d860 100644 --- a/spring-cloud-config-server/src/main/java/org/springframework/cloud/config/server/resource/ResourceController.java +++ b/spring-cloud-config-server/src/main/java/org/springframework/cloud/config/server/resource/ResourceController.java @@ -136,6 +136,13 @@ public class ResourceController { return binary(request, name, profile, label, path); } + @RequestMapping(value = "/{name}/{profile}/**", params = "useDefaultLabel", produces = MediaType.APPLICATION_OCTET_STREAM_VALUE) + public byte[] binary(@PathVariable String name, @PathVariable String profile, + ServletWebRequest request) throws IOException { + String path = getFilePath(request, name, profile, null); + return binary(request, name, profile, null, path); + } + /* * Used only for unit tests. */ diff --git a/spring-cloud-config-server/src/main/java/org/springframework/cloud/config/server/support/AwsCodeCommitCredentialProvider.java b/spring-cloud-config-server/src/main/java/org/springframework/cloud/config/server/support/AwsCodeCommitCredentialProvider.java index 69502293..935b6661 100644 --- a/spring-cloud-config-server/src/main/java/org/springframework/cloud/config/server/support/AwsCodeCommitCredentialProvider.java +++ b/spring-cloud-config-server/src/main/java/org/springframework/cloud/config/server/support/AwsCodeCommitCredentialProvider.java @@ -48,7 +48,12 @@ import static org.springframework.util.StringUtils.hasText; *

* From the command line, you can configure git to use AWS code commit with a credential * helper. However, jgit does not support credential helper commands, but it does provider - * a CredentialsProvider abstract class we can extend. + * a CredentialsProvider abstract class we can extend. Connecting to an AWS CodeCommit + * (codecommit) repository requires an AWS access key and secret key. These are used to + * calculate a signature for the git request. The AWS access key is used as the codecommit + * username, and the calculated signature is used as the password. The process for + * calculating this signature is documented very well at + * https://docs.aws.amazon.com/general/latest/gr/signature-version-4.html. *

* Connecting to an AWS CodeCommit (codecommit) repository requires an AWS access key and * secret key. These are used to calculate a signature for the git request. The AWS access diff --git a/spring-cloud-config-server/src/test/java/org/springframework/cloud/config/server/resource/ResourceControllerIntegrationTests.java b/spring-cloud-config-server/src/test/java/org/springframework/cloud/config/server/resource/ResourceControllerIntegrationTests.java index 5e2fd983..19d8355b 100644 --- a/spring-cloud-config-server/src/test/java/org/springframework/cloud/config/server/resource/ResourceControllerIntegrationTests.java +++ b/spring-cloud-config-server/src/test/java/org/springframework/cloud/config/server/resource/ResourceControllerIntegrationTests.java @@ -32,12 +32,14 @@ import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Import; import org.springframework.core.io.ByteArrayResource; +import org.springframework.http.HttpHeaders; import org.springframework.test.annotation.DirtiesContext; import org.springframework.test.context.junit4.SpringRunner; import org.springframework.test.web.servlet.MockMvc; import org.springframework.test.web.servlet.request.MockMvcRequestBuilders; import org.springframework.test.web.servlet.result.MockMvcResultMatchers; import org.springframework.test.web.servlet.setup.MockMvcBuilders; +import org.springframework.util.MimeTypeUtils; import org.springframework.web.context.WebApplicationContext; import org.springframework.web.servlet.config.annotation.EnableWebMvc; @@ -64,7 +66,7 @@ public class ResourceControllerIntegrationTests { @Before public void init() { - Mockito.reset(this.repository); + Mockito.reset(this.repository, this.resources); this.mvc = MockMvcBuilders.webAppContextSetup(this.context).build(); } @@ -93,6 +95,20 @@ public class ResourceControllerIntegrationTests { Mockito.verify(this.resources).findOne("foo", "default", null, "foo.txt"); } + @Test + public void binaryResourceNoLabel() throws Exception { + Mockito.when(this.repository.findOne("foo", "default", null)) + .thenReturn(new Environment("foo", "default", "master")); + Mockito.when(this.resources.findOne("foo", "default", null, "foo.txt")) + .thenReturn(new ByteArrayResource("hello".getBytes())); + this.mvc.perform(MockMvcRequestBuilders.get("/foo/default/foo.txt") + .param("useDefaultLabel", "") + .header(HttpHeaders.ACCEPT, MimeTypeUtils.APPLICATION_OCTET_STREAM_VALUE)) + .andExpect(MockMvcResultMatchers.status().isOk()); + Mockito.verify(this.repository).findOne("foo", "default", null); + Mockito.verify(this.resources).findOne("foo", "default", null, "foo.txt"); + } + @Configuration @EnableWebMvc @Import(PropertyPlaceholderAutoConfiguration.class) diff --git a/spring-cloud-config-server/src/test/java/org/springframework/cloud/config/server/resource/ResourceControllerTests.java b/spring-cloud-config-server/src/test/java/org/springframework/cloud/config/server/resource/ResourceControllerTests.java index a2061a5e..cff89fd0 100644 --- a/spring-cloud-config-server/src/test/java/org/springframework/cloud/config/server/resource/ResourceControllerTests.java +++ b/spring-cloud-config-server/src/test/java/org/springframework/cloud/config/server/resource/ResourceControllerTests.java @@ -299,4 +299,15 @@ public class ResourceControllerTests { return text.replace("\n", "").replace("\t", ""); } + @Test + public void defaultLabelForBinary() throws Exception { + this.environmentRepository.setSearchLocations("classpath:/test/{application}"); + MockHttpServletRequest request = new MockHttpServletRequest(); + ServletWebRequest webRequest = new ServletWebRequest(request, + new MockHttpServletResponse()); + request.setRequestURI("/dev/spam/bar/" + "foo.txt"); + byte[] resource = this.controller.binary("dev/spam", "bar", webRequest); + assertThat(new String(resource)).isEqualToIgnoringNewLines("foo: dev_bar/spam"); + } + }