-
Notifications
You must be signed in to change notification settings - Fork 83
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add support for listing repositories accessible to an app installation (
#42) * add method to list repos accessible to a Github App this change implements support for https://docs.github.com/en/free-pro-team@latest/rest/reference/apps#list-repositories-accessible-to-the-app-installation I believe though, that in this initial form, the response is limited to only the first page of results returned by the Github API: #41 * add GithubAppClientTest#listAccessibleRepositories and refactor other tests This commit refactors GithubAppClientTest so that it tests the actual methods in GithubAppClient and adds a test of the new method `listAccessibleRepositories()`. Previously the test did not actually test any logic in GithubAppClient but rather the tests were of the deserialization logic for some of the types used in the class. I moved the test related to deserializing an AccessToken to a new AccessTokenTest, and replaced the other tests so that they use a MockWebServer to actually be able to test the HTTP requests/responses. * minor: unnecessary type arguments * forgot to teardown MockWebServer use it as a Rule instead to make things a little simpler * squash: remove redundant toCompletableFuture() calls
- Loading branch information
Showing
11 changed files
with
491 additions
and
118 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
41 changes: 41 additions & 0 deletions
41
src/main/java/com/spotify/github/v3/apps/InstallationRepositoriesResponse.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
/*- | ||
* -\-\- | ||
* github-client | ||
* -- | ||
* Copyright (C) 2016 - 2020 Spotify AB | ||
* -- | ||
* Licensed under the Apache License, Version 2.0 (the "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 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
* -/-/- | ||
*/ | ||
|
||
package com.spotify.github.v3.apps; | ||
|
||
import com.fasterxml.jackson.databind.annotation.JsonDeserialize; | ||
import com.spotify.github.GithubStyle; | ||
import com.spotify.github.v3.repos.Repository; | ||
import java.util.List; | ||
import org.immutables.value.Value; | ||
|
||
/** | ||
* Response for requests to "List repositories accessible to the app installation" | ||
* | ||
* https://docs.github.com/en/free-pro-team@latest/rest/reference/apps#list-repositories-accessible-to-the-app-installation | ||
*/ | ||
@Value.Immutable | ||
@GithubStyle | ||
@JsonDeserialize(as = ImmutableInstallationRepositoriesResponse.class) | ||
public interface InstallationRepositoriesResponse { | ||
int totalCount(); | ||
|
||
List<Repository> repositories(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
42 changes: 42 additions & 0 deletions
42
src/test/java/com/spotify/github/v3/checks/AccessTokenTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
/*- | ||
* -\-\- | ||
* github-client | ||
* -- | ||
* Copyright (C) 2016 - 2020 Spotify AB | ||
* -- | ||
* Licensed under the Apache License, Version 2.0 (the "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 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
* -/-/- | ||
*/ | ||
|
||
package com.spotify.github.v3.checks; | ||
|
||
import static org.hamcrest.CoreMatchers.is; | ||
import static org.hamcrest.MatcherAssert.assertThat; | ||
|
||
import com.spotify.github.FixtureHelper; | ||
import com.spotify.github.jackson.Json; | ||
import java.io.IOException; | ||
import java.time.ZonedDateTime; | ||
import org.junit.Test; | ||
|
||
public class AccessTokenTest { | ||
private final Json json = Json.create(); | ||
|
||
@Test | ||
public void canDeserializeToken() throws IOException { | ||
final AccessToken accessToken = | ||
json.fromJson(FixtureHelper.loadFixture("checks/access-token.json"), AccessToken.class); | ||
assertThat(accessToken.token(), is("v1.1f699f1069f60xxx")); | ||
assertThat(accessToken.expiresAt(), is(ZonedDateTime.parse("2016-07-11T22:14:10Z"))); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
Oops, something went wrong.