diff --git a/src/main/java/org/kohsuke/github/GHApp.java b/src/main/java/org/kohsuke/github/GHApp.java new file mode 100644 index 0000000000..97de867ccf --- /dev/null +++ b/src/main/java/org/kohsuke/github/GHApp.java @@ -0,0 +1,177 @@ +package org.kohsuke.github; + +import com.fasterxml.jackson.annotation.JsonProperty; + +import java.io.IOException; +import java.net.URL; +import java.util.List; +import java.util.Map; + +import static org.kohsuke.github.Previews.MACHINE_MAN; + +/** + * A Github App. + * + * @author Paulo Miguel Almeida + * + * @see GitHub#getApp() + */ + +public class GHApp extends GHObject { + + private GitHub root; + private GHUser owner; + private String name; + private String description; + @JsonProperty("external_url") + private String externalUrl; + private Map permissions; + private List events; + @JsonProperty("installations_count") + private long installationsCount; + @JsonProperty("html_url") + private String htmlUrl; + + + public GHUser getOwner() { + return owner; + } + + public void setOwner(GHUser owner) { + this.owner = owner; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public String getExternalUrl() { + return externalUrl; + } + + public void setExternalUrl(String externalUrl) { + this.externalUrl = externalUrl; + } + + public List getEvents() { + return events; + } + + public void setEvents(List events) { + this.events = events; + } + + public long getInstallationsCount() { + return installationsCount; + } + + public void setInstallationsCount(long installationsCount) { + this.installationsCount = installationsCount; + } + + public URL getHtmlUrl() { + return GitHub.parseURL(htmlUrl); + } + + public Map getPermissions() { + return permissions; + } + + public void setPermissions(Map permissions) { + this.permissions = permissions; + } + + /*package*/ GHApp wrapUp(GitHub root) { + this.root = root; + return this; + } + + /** + * Obtains all the installations associated with this app. + * + * You must use a JWT to access this endpoint. + * + * @see List installations + */ + @Preview @Deprecated + public PagedIterable listInstallations() { + return new PagedIterable() { + public PagedIterator _iterator(int pageSize) { + return new PagedIterator(root.retrieve().withPreview(MACHINE_MAN).asIterator("/app/installations", GHAppInstallation[].class, pageSize)) { + protected void wrapUp(GHAppInstallation[] page) { + for (GHAppInstallation appInstallation : page) { + appInstallation.wrapUp(root); + } + } + }; + } + }; + } + + /** + * Obtain an installation associated with this app + * @param id - Installation Id + * + * You must use a JWT to access this endpoint. + * + * @see Get an installation + */ + @Preview @Deprecated + public GHAppInstallation getInstallationById(long id) throws IOException { + return root.retrieve().withPreview(MACHINE_MAN).to(String.format("/app/installations/%d", id), GHAppInstallation.class).wrapUp(root); + } + + /** + * Obtain an organization installation associated with this app + * @param name - Organization name + * + * You must use a JWT to access this endpoint. + * + * @see Get an organization installation + */ + @Preview @Deprecated + public GHAppInstallation getInstallationByOrganization(String name) throws IOException { + return root.retrieve().withPreview(MACHINE_MAN).to(String.format("/orgs/%s/installation", name), GHAppInstallation.class).wrapUp(root); + } + + /** + * Obtain an repository installation associated with this app + * @param ownerName - Organization or user name + * @param repositoryName - Repository name + * + * You must use a JWT to access this endpoint. + * + * @see Get a repository installation + */ + @Preview @Deprecated + public GHAppInstallation getInstallationByRepository(String ownerName, String repositoryName) throws IOException { + return root.retrieve().withPreview(MACHINE_MAN).to(String.format("/repos/%s/%s/installation", ownerName, repositoryName), GHAppInstallation.class).wrapUp(root); + } + + /** + * Obtain a user installation associated with this app + * @param name - user name + * + * You must use a JWT to access this endpoint. + * + * @see Get a user installation + */ + @Preview @Deprecated + public GHAppInstallation getInstallationByUser(String name) throws IOException { + return root.retrieve().withPreview(MACHINE_MAN).to(String.format("/users/%s/installation", name), GHAppInstallation.class).wrapUp(root); + } + +} + diff --git a/src/main/java/org/kohsuke/github/GHAppCreateTokenBuilder.java b/src/main/java/org/kohsuke/github/GHAppCreateTokenBuilder.java new file mode 100644 index 0000000000..cf19dd99af --- /dev/null +++ b/src/main/java/org/kohsuke/github/GHAppCreateTokenBuilder.java @@ -0,0 +1,53 @@ +package org.kohsuke.github; + +import java.io.IOException; +import java.util.List; +import java.util.Map; + +import static org.kohsuke.github.Previews.MACHINE_MAN; + +/** + * Creates a access token for a GitHub App Installation + * + * @author Paulo Miguel Almeida + * + * @see GHAppInstallation#createToken(Map) + */ +public class GHAppCreateTokenBuilder { + private final GitHub root; + protected final Requester builder; + private final String apiUrlTail; + + @Preview @Deprecated + /*package*/ GHAppCreateTokenBuilder(GitHub root, String apiUrlTail, Map permissions) { + this.root = root; + this.apiUrlTail = apiUrlTail; + this.builder = new Requester(root); + this.builder.withPermissions("permissions",permissions); + } + + /** + * By default the installation token has access to all repositories that the installation can access. To restrict + * the access to specific repositories, you can provide the repository_ids when creating the token. When you omit + * repository_ids, the response does not contain neither the repositories nor the permissions key. + * + * @param repositoryIds - Array containing the repositories Ids + * + */ + @Preview @Deprecated + public GHAppCreateTokenBuilder repositoryIds(List repositoryIds) { + this.builder.with("repository_ids",repositoryIds); + return this; + } + + /** + * Creates an app token with all the parameters. + * + * You must use a JWT to access this endpoint. + */ + @Preview @Deprecated + public GHAppInstallationToken create() throws IOException { + return builder.method("POST").withPreview(MACHINE_MAN).to(apiUrlTail, GHAppInstallationToken.class).wrapUp(root); + } + +} diff --git a/src/main/java/org/kohsuke/github/GHAppInstallation.java b/src/main/java/org/kohsuke/github/GHAppInstallation.java new file mode 100644 index 0000000000..3925742162 --- /dev/null +++ b/src/main/java/org/kohsuke/github/GHAppInstallation.java @@ -0,0 +1,167 @@ +package org.kohsuke.github; + +import com.fasterxml.jackson.annotation.JsonProperty; + +import java.io.IOException; +import java.net.URL; +import java.util.List; +import java.util.Map; + +import static org.kohsuke.github.Previews.GAMBIT; + +/** + * A Github App Installation. + * + * @author Paulo Miguel Almeida + * + * @see GHApp#listInstallations() + * @see GHApp#getInstallationById(long) + * @see GHApp#getInstallationByOrganization(String) + * @see GHApp#getInstallationByRepository(String, String) + * @see GHApp#getInstallationByUser(String) + */ + +public class GHAppInstallation extends GHObject { + private GitHub root; + private GHUser account; + + @JsonProperty("access_tokens_url") + private String accessTokenUrl; + @JsonProperty("repositories_url") + private String repositoriesUrl; + @JsonProperty("app_id") + private long appId; + @JsonProperty("target_id") + private long targetId; + @JsonProperty("target_type") + private GHTargetType targetType; + private Map permissions; + private List events; + @JsonProperty("single_file_name") + private String singleFileName; + @JsonProperty("repository_selection") + private GHRepositorySelection repositorySelection; + private String htmlUrl; + + public URL getHtmlUrl() { + return GitHub.parseURL(htmlUrl); + } + + public GitHub getRoot() { + return root; + } + + public void setRoot(GitHub root) { + this.root = root; + } + + public GHUser getAccount() { + return account; + } + + public void setAccount(GHUser account) { + this.account = account; + } + + public String getAccessTokenUrl() { + return accessTokenUrl; + } + + public void setAccessTokenUrl(String accessTokenUrl) { + this.accessTokenUrl = accessTokenUrl; + } + + public String getRepositoriesUrl() { + return repositoriesUrl; + } + + public void setRepositoriesUrl(String repositoriesUrl) { + this.repositoriesUrl = repositoriesUrl; + } + + public long getAppId() { + return appId; + } + + public void setAppId(long appId) { + this.appId = appId; + } + + public long getTargetId() { + return targetId; + } + + public void setTargetId(long targetId) { + this.targetId = targetId; + } + + public GHTargetType getTargetType() { + return targetType; + } + + public void setTargetType(GHTargetType targetType) { + this.targetType = targetType; + } + + public Map getPermissions() { + return permissions; + } + + public void setPermissions(Map permissions) { + this.permissions = permissions; + } + + public List getEvents() { + return events; + } + + public void setEvents(List events) { + this.events = events; + } + + public String getSingleFileName() { + return singleFileName; + } + + public void setSingleFileName(String singleFileName) { + this.singleFileName = singleFileName; + } + + public GHRepositorySelection getRepositorySelection() { + return repositorySelection; + } + + public void setRepositorySelection(GHRepositorySelection repositorySelection) { + this.repositorySelection = repositorySelection; + } + + /*package*/ GHAppInstallation wrapUp(GitHub root) { + this.root = root; + return this; + } + + /** + * Delete a Github App installation + * + * You must use a JWT to access this endpoint. + * + * @see Delete an installation + */ + @Preview @Deprecated + public void deleteInstallation() throws IOException { + root.retrieve().method("DELETE").withPreview(GAMBIT).to(String.format("/app/installations/%d", id)); + } + + + /** + * Starts a builder that creates a new App Installation Token. + * + *

+ * You use the returned builder to set various properties, then call {@link GHAppCreateTokenBuilder#create()} + * to finally create an access token. + */ + @Preview @Deprecated + public GHAppCreateTokenBuilder createToken(Map permissions){ + return new GHAppCreateTokenBuilder(root,String.format("/app/installations/%d/access_tokens", id), permissions); + } +} diff --git a/src/main/java/org/kohsuke/github/GHAppInstallationToken.java b/src/main/java/org/kohsuke/github/GHAppInstallationToken.java new file mode 100644 index 0000000000..2b6e78fdee --- /dev/null +++ b/src/main/java/org/kohsuke/github/GHAppInstallationToken.java @@ -0,0 +1,87 @@ +package org.kohsuke.github; + +import com.fasterxml.jackson.annotation.JsonProperty; +import com.infradna.tool.bridge_method_injector.WithBridgeMethods; +import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; + +import java.io.IOException; +import java.util.Date; +import java.util.List; +import java.util.Map; + +/** + * A Github App Installation Token. + * + * @author Paulo Miguel Almeida + * + * @see GHAppInstallation#createToken(Map) + */ + +public class GHAppInstallationToken { + private GitHub root; + + private String token; + protected String expires_at; + private Map permissions; + private List repositories; + @JsonProperty("repository_selection") + private GHRepositorySelection repositorySelection; + + public GitHub getRoot() { + return root; + } + + public void setRoot(GitHub root) { + this.root = root; + } + + public Map getPermissions() { + return permissions; + } + + public void setPermissions(Map permissions) { + this.permissions = permissions; + } + + public String getToken() { + return token; + } + + public void setToken(String token) { + this.token = token; + } + + public List getRepositories() { + return repositories; + } + + public void setRepositories(List repositories) { + this.repositories = repositories; + } + + public GHRepositorySelection getRepositorySelection() { + return repositorySelection; + } + + public void setRepositorySelection(GHRepositorySelection repositorySelection) { + this.repositorySelection = repositorySelection; + } + + /** + * When was this tokens expires? + */ + @WithBridgeMethods(value=String.class, adapterMethod="expiresAtStr") + public Date getExpiresAt() throws IOException { + return GitHub.parseDate(expires_at); + } + + @SuppressFBWarnings(value = "UPM_UNCALLED_PRIVATE_METHOD", justification = "Bridge method of getExpiresAt") + private Object expiresAtStr(Date id, Class type) { + return expires_at; + } + + /*package*/ GHAppInstallationToken wrapUp(GitHub root) { + this.root = root; + return this; + } +} diff --git a/src/main/java/org/kohsuke/github/GHEvent.java b/src/main/java/org/kohsuke/github/GHEvent.java index 970b6afbf7..8ad6368fe5 100644 --- a/src/main/java/org/kohsuke/github/GHEvent.java +++ b/src/main/java/org/kohsuke/github/GHEvent.java @@ -23,6 +23,8 @@ public enum GHEvent { GOLLUM, INSTALLATION, INSTALLATION_REPOSITORIES, + INTEGRATION_INSTALLATION_REPOSITORIES, + CHECK_SUITE, ISSUE_COMMENT, ISSUES, LABEL, diff --git a/src/main/java/org/kohsuke/github/GHRepositorySelection.java b/src/main/java/org/kohsuke/github/GHRepositorySelection.java new file mode 100644 index 0000000000..afba38aaa2 --- /dev/null +++ b/src/main/java/org/kohsuke/github/GHRepositorySelection.java @@ -0,0 +1,22 @@ +package org.kohsuke.github; + +import java.util.Locale; + +/** + * App installation repository selection. + * + * @author Paulo Miguel Almeida + * + * @see GHAppInstallation + */ +public enum GHRepositorySelection { + SELECTED, + ALL; + + /** + * Returns GitHub's internal representation of this event. + */ + String symbol() { + return name().toLowerCase(Locale.ENGLISH); + } +} diff --git a/src/main/java/org/kohsuke/github/GHTargetType.java b/src/main/java/org/kohsuke/github/GHTargetType.java new file mode 100644 index 0000000000..42a23d8726 --- /dev/null +++ b/src/main/java/org/kohsuke/github/GHTargetType.java @@ -0,0 +1,24 @@ +package org.kohsuke.github; + +import org.apache.commons.lang3.StringUtils; + +import java.util.Locale; + +/** + * App installation target type. + * + * @author Paulo Miguel Almeida + * + * @see GHAppInstallation + */ +public enum GHTargetType { + ORGANIZATION, + USER; + + /** + * Returns GitHub's internal representation of this event. + */ + String symbol() { + return StringUtils.capitalize(name().toLowerCase(Locale.ENGLISH)); + } +} diff --git a/src/main/java/org/kohsuke/github/GitHub.java b/src/main/java/org/kohsuke/github/GitHub.java index 002fda9b1e..23973f3546 100644 --- a/src/main/java/org/kohsuke/github/GitHub.java +++ b/src/main/java/org/kohsuke/github/GitHub.java @@ -115,6 +115,12 @@ public class GitHub { *

Specify oauthAccessToken, and optionally specify the login. Leave password null. * This will send OAuth token to the GitHub API. If the login parameter is null, * The constructor makes an API call to figure out the user name that owns the token. + * + *
Log in with JWT token + *
Specify jwtToken. Leave password null. + * This will send JWT token to the GitHub API via the Authorization HTTP header. + * Please note that only operations in which permissions have been previously configured and accepted during + * the GitHub App will be executed successfully. * * * @param apiUrl @@ -132,7 +138,7 @@ public class GitHub { * @param connector * HttpConnector to use. Pass null to use default connector. */ - /* package */ GitHub(String apiUrl, String login, String oauthAccessToken, String password, HttpConnector connector, RateLimitHandler rateLimitHandler, AbuseLimitHandler abuseLimitHandler) throws IOException { + /* package */ GitHub(String apiUrl, String login, String oauthAccessToken, String jwtToken, String password, HttpConnector connector, RateLimitHandler rateLimitHandler, AbuseLimitHandler abuseLimitHandler) throws IOException { if (apiUrl.endsWith("/")) apiUrl = apiUrl.substring(0, apiUrl.length()-1); // normalize this.apiUrl = apiUrl; if (null != connector) this.connector = connector; @@ -140,7 +146,9 @@ public class GitHub { if (oauthAccessToken!=null) { encodedAuthorization = "token "+oauthAccessToken; } else { - if (password!=null) { + if(jwtToken!=null){ + encodedAuthorization = "Bearer "+jwtToken; + }else if (password!=null) { String authorization = (login + ':' + password); String charsetName = Charsets.UTF_8.name(); encodedAuthorization = "Basic "+new String(Base64.encodeBase64(authorization.getBytes(charsetName)), charsetName); @@ -154,7 +162,7 @@ public class GitHub { this.rateLimitHandler = rateLimitHandler; this.abuseLimitHandler = abuseLimitHandler; - if (login==null && encodedAuthorization!=null) + if (login==null && encodedAuthorization!=null && jwtToken == null) login = getMyself().getLogin(); this.login = login; } @@ -699,6 +707,18 @@ public GHAuthorization resetAuth(@Nonnull String clientId, @Nonnull String acces return retrieve().method("POST").to("/applications/" + clientId + "/tokens/" + accessToken, GHAuthorization.class); } + /** + * Returns the GitHub App associated with the authentication credentials used. + * + * You must use a JWT to access this endpoint. + * + * @see Get the authenticated GitHub App + */ + @Preview @Deprecated + public GHApp getApp() throws IOException { + return retrieve().withPreview(MACHINE_MAN).to("/app", GHApp.class).wrapUp(this); + } + /** * Ensures that the credential is valid. */ @@ -922,7 +942,11 @@ public Reader renderMarkdown(String text) throws IOException { /*package*/ static final ObjectMapper MAPPER = new ObjectMapper(); - private static final String[] TIME_FORMATS = {"yyyy/MM/dd HH:mm:ss ZZZZ","yyyy-MM-dd'T'HH:mm:ss'Z'"}; + private static final String[] TIME_FORMATS = { + "yyyy/MM/dd HH:mm:ss ZZZZ", + "yyyy-MM-dd'T'HH:mm:ss'Z'", + "yyyy-MM-dd'T'HH:mm:ss.S'Z'" // GitHub App endpoints return a different date format + }; static { MAPPER.setVisibilityChecker(new Std(NONE, NONE, NONE, NONE, ANY)); diff --git a/src/main/java/org/kohsuke/github/GitHubBuilder.java b/src/main/java/org/kohsuke/github/GitHubBuilder.java index d7b6e639e6..e299e7340d 100644 --- a/src/main/java/org/kohsuke/github/GitHubBuilder.java +++ b/src/main/java/org/kohsuke/github/GitHubBuilder.java @@ -26,7 +26,8 @@ public class GitHubBuilder implements Cloneable { /* private */ String user; /* private */ String password; /* private */ String oauthToken; - + /* private */ String jwtToken; + private HttpConnector connector; private RateLimitHandler rateLimitHandler = RateLimitHandler.WAIT; @@ -53,13 +54,13 @@ static GitHubBuilder fromCredentials() throws IOException { builder = fromEnvironment(); - if (builder.oauthToken != null || builder.user != null) + if (builder.oauthToken != null || builder.user != null || builder.jwtToken != null) return builder; try { builder = fromPropertyFile(); - if (builder.oauthToken != null || builder.user != null) + if (builder.oauthToken != null || builder.user != null || builder.jwtToken != null) return builder; } catch (FileNotFoundException e) { // fall through @@ -108,6 +109,7 @@ public static GitHubBuilder fromEnvironment(String loginVariableName, String pas *
  • GITHUB_PASSWORD: raw password *
  • GITHUB_OAUTH: OAuth token to login *
  • GITHUB_ENDPOINT: URL of the API endpoint + *
  • GITHUB_JWT: JWT token to login * * *

    @@ -149,6 +151,7 @@ public static GitHubBuilder fromPropertyFile(String propertyFileName) throws IOE public static GitHubBuilder fromProperties(Properties props) { GitHubBuilder self = new GitHubBuilder(); self.withOAuthToken(props.getProperty("oauth"), props.getProperty("login")); + self.withJwtToken(props.getProperty("jwt")); self.withPassword(props.getProperty("login"), props.getProperty("password")); self.withEndpoint(props.getProperty("endpoint", GitHub.GITHUB_URL)); return self; @@ -177,6 +180,10 @@ public GitHubBuilder withOAuthToken(String oauthToken, String user) { this.user = user; return this; } + public GitHubBuilder withJwtToken(String jwtToken){ + this.jwtToken = jwtToken; + return this; + } public GitHubBuilder withConnector(HttpConnector connector) { this.connector = connector; return this; @@ -204,7 +211,7 @@ public HttpURLConnection connect(URL url) throws IOException { } public GitHub build() throws IOException { - return new GitHub(endpoint, user, oauthToken, password, connector, rateLimitHandler, abuseLimitHandler); + return new GitHub(endpoint, user, oauthToken, jwtToken, password, connector, rateLimitHandler, abuseLimitHandler); } @Override diff --git a/src/main/java/org/kohsuke/github/Previews.java b/src/main/java/org/kohsuke/github/Previews.java index ad23bbf4c8..d99743f8e7 100644 --- a/src/main/java/org/kohsuke/github/Previews.java +++ b/src/main/java/org/kohsuke/github/Previews.java @@ -36,4 +36,6 @@ * @see GitHub API Previews */ static final String ZZZAX = "application/vnd.github.zzzax-preview+json"; + static final String MACHINE_MAN = "application/vnd.github.machine-man-preview+json"; + static final String GAMBIT = "application/vnd.github.gambit-preview+json"; } diff --git a/src/main/java/org/kohsuke/github/Requester.java b/src/main/java/org/kohsuke/github/Requester.java index 3c0e95ecdf..618ca87ffd 100644 --- a/src/main/java/org/kohsuke/github/Requester.java +++ b/src/main/java/org/kohsuke/github/Requester.java @@ -154,18 +154,14 @@ public Requester with(String key, Boolean value) { public Requester with(String key, Enum e) { if (e==null) return _with(key, null); - - // by convention Java constant names are upper cases, but github uses - // lower-case constants. GitHub also uses '-', which in Java we always - // replace by '_' - return with(key, e.toString().toLowerCase(Locale.ENGLISH).replace('_', '-')); + return with(key, transformEnum(e)); } public Requester with(String key, String value) { return _with(key, value); } - public Requester with(String key, Collection value) { + public Requester with(String key, Collection value) { return _with(key, value); } @@ -181,6 +177,14 @@ public Requester with(String key, Map value) { return _with(key, value); } + public Requester withPermissions(String key, Map value) { + Map retMap = new HashMap(); + for (Map.Entry entry : value.entrySet()) { + retMap.put(entry.getKey(), transformEnum(entry.getValue())); + } + return _with(key, retMap); + } + public Requester with(@WillClose/*later*/ InputStream body) { this.body = body; return this; @@ -726,6 +730,18 @@ private InputStream wrapStream(InputStream in) throws IOException { throw e; } + /** + * Transform Java Enum into Github constants given its conventions + * @param en - Enum to be transformed + * @return a String containing the value of a Github constant + */ + private String transformEnum(Enum en){ + // by convention Java constant names are upper cases, but github uses + // lower-case constants. GitHub also uses '-', which in Java we always + // replace by '_' + return en.toString().toLowerCase(Locale.ENGLISH).replace('_', '-'); + } + private static final List METHODS_WITHOUT_BODY = asList("GET", "DELETE"); private static final Logger LOGGER = Logger.getLogger(Requester.class.getName()); } diff --git a/src/test/java/org/kohsuke/github/GHAppTest.java b/src/test/java/org/kohsuke/github/GHAppTest.java new file mode 100644 index 0000000000..342312ff28 --- /dev/null +++ b/src/test/java/org/kohsuke/github/GHAppTest.java @@ -0,0 +1,148 @@ +package org.kohsuke.github; + +import org.junit.Test; + +import java.io.IOException; +import java.util.Arrays; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import static org.hamcrest.Matchers.*; + +/** + * Tests for the GitHub App API methods + * + * @author Paulo Miguel Almeida + */ +public class GHAppTest extends AbstractGitHubApiWireMockTest { + + protected GitHubBuilder getGitHubBuilder() { + return super.getGitHubBuilder() + // ensure that only JWT will be used against the tests below + .withPassword(null, null) + .withJwtToken("bogus"); + } + + @Test + public void getGitHubApp() throws IOException { + GHApp app = gitHub.getApp(); + assertThat(app.id, is((long) 11111)); + assertThat(app.getOwner().id, is((long) 111111111)); + assertThat(app.getOwner().login, is("bogus")); + assertThat(app.getName(), is("Bogus-Development")); + assertThat(app.getDescription(), is("")); + assertThat(app.getExternalUrl(), is("https://bogus.domain.com")); + assertThat(app.getHtmlUrl().toString(), is("https://github.com/apps/bogus-development")); + assertThat(app.getCreatedAt(), is(GitHub.parseDate("2019-06-10T04:21:41Z"))); + assertThat(app.getUpdatedAt(), is(GitHub.parseDate("2019-06-10T04:21:41Z"))); + assertThat(app.getPermissions().size(), is(4)); + assertThat(app.getEvents().size(), is(2)); + assertThat(app.getInstallationsCount(), is((long) 1)); + } + + + @Test + public void listInstallations() throws IOException { + GHApp app = gitHub.getApp(); + List installations = app.listInstallations().asList(); + assertThat(installations.size(), is(1)); + + GHAppInstallation appInstallation = installations.get(0); + testAppInstallation(appInstallation); + } + + @Test + public void getInstallationById() throws IOException { + GHApp app = gitHub.getApp(); + GHAppInstallation installation = app.getInstallationById(1111111); + testAppInstallation(installation); + } + + @Test + public void getInstallationByOrganization() throws IOException { + GHApp app = gitHub.getApp(); + GHAppInstallation installation = app.getInstallationByOrganization("bogus"); + testAppInstallation(installation); + } + + @Test + public void getInstallationByRepository() throws IOException { + GHApp app = gitHub.getApp(); + GHAppInstallation installation = app.getInstallationByRepository("bogus", "bogus"); + testAppInstallation(installation); + } + + @Test + public void getInstallationByUser() throws IOException { + GHApp app = gitHub.getApp(); + GHAppInstallation installation = app.getInstallationByUser("bogus"); + testAppInstallation(installation); + } + + @Test + public void deleteInstallation() throws IOException { + GHApp app = gitHub.getApp(); + GHAppInstallation installation = app.getInstallationByUser("bogus"); + try { + installation.deleteInstallation(); + } catch (IOException e) { + fail("deleteInstallation wasn't suppose to fail in this test"); + } + } + + @Test + public void createToken() throws IOException { + GHApp app = gitHub.getApp(); + GHAppInstallation installation = app.getInstallationByUser("bogus"); + + Map permissions = new HashMap(); + permissions.put("checks", GHPermissionType.WRITE); + permissions.put("pull_requests", GHPermissionType.WRITE); + permissions.put("contents", GHPermissionType.READ); + permissions.put("metadata", GHPermissionType.READ); + + GHAppInstallationToken installationToken = installation.createToken(permissions) + .repositoryIds(Arrays.asList(111111111)) + .create(); + + assertThat(installationToken.getToken(), is("bogus")); + assertThat(installation.getPermissions(), is(permissions)); + assertThat(installationToken.getRepositorySelection(),is(GHRepositorySelection.SELECTED)); + assertThat(installationToken.getExpiresAt(), is(GitHub.parseDate("2019-08-10T05:54:58Z"))); + + GHRepository repository = installationToken.getRepositories().get(0); + assertThat(installationToken.getRepositories().size(), is(1)); + assertThat(repository.getId(), is((long) 111111111)); + assertThat(repository.getName(), is("bogus")); + } + + private void testAppInstallation(GHAppInstallation appInstallation) throws IOException { + Map appPermissions = appInstallation.getPermissions(); + GHUser appAccount = appInstallation.getAccount(); + + assertThat(appInstallation.id, is((long) 11111111)); + assertThat(appAccount.id, is((long) 111111111)); + assertThat(appAccount.login, is("bogus")); + assertThat(appInstallation.getRepositorySelection(), is(GHRepositorySelection.SELECTED)); + assertThat(appInstallation.getAccessTokenUrl(), endsWith("/app/installations/11111111/access_tokens")); + assertThat(appInstallation.getRepositoriesUrl(), endsWith("/installation/repositories")); + assertThat(appInstallation.getAppId(), is((long) 11111)); + assertThat(appInstallation.getTargetId(), is((long) 111111111)); + assertThat(appInstallation.getTargetType(), is(GHTargetType.ORGANIZATION)); + + Map permissionsMap = new HashMap(); + permissionsMap.put("checks", GHPermissionType.WRITE); + permissionsMap.put("pull_requests", GHPermissionType.WRITE); + permissionsMap.put("contents", GHPermissionType.READ); + permissionsMap.put("metadata", GHPermissionType.READ); + assertThat(appPermissions, is(permissionsMap)); + + List events = Arrays.asList(GHEvent.PULL_REQUEST, GHEvent.PUSH); + assertThat(appInstallation.getEvents(), containsInAnyOrder(events.toArray(new GHEvent[0]))); + assertThat(appInstallation.getCreatedAt(), is(GitHub.parseDate("2019-07-04T01:19:36.000Z"))); + assertThat(appInstallation.getUpdatedAt(), is(GitHub.parseDate("2019-07-30T22:48:09.000Z"))); + assertNull(appInstallation.getSingleFileName()); + } + +} diff --git a/src/test/java/org/kohsuke/github/GitHubTest.java b/src/test/java/org/kohsuke/github/GitHubTest.java index 21ea40b590..35e2e14ac5 100644 --- a/src/test/java/org/kohsuke/github/GitHubTest.java +++ b/src/test/java/org/kohsuke/github/GitHubTest.java @@ -14,10 +14,6 @@ import static org.hamcrest.CoreMatchers.equalTo; import static org.hamcrest.CoreMatchers.notNullValue; -import static org.hamcrest.MatcherAssert.assertThat; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; import static org.mockito.Mockito.spy; import static org.mockito.Mockito.when; @@ -50,7 +46,6 @@ public void testGitHubServerWithHttps() throws Exception { GitHub hub = GitHub.connectToEnterprise("https://enterprise.kohsuke.org/api/v3", "bogus", "bogus"); assertEquals("https://enterprise.kohsuke.org/api/v3/test", hub.getApiURL("/test").toString()); } - @Test public void testGitHubServerWithoutServer() throws Exception { GitHub hub = GitHub.connectUsingPassword("kohsuke", "bogus"); @@ -65,6 +60,7 @@ public void testGitHubBuilderFromEnvironment() throws IOException { props.put("login", "bogus"); props.put("oauth", "bogus"); props.put("password", "bogus"); + props.put("jwt", "bogus"); setupEnvironment(props); @@ -73,6 +69,7 @@ public void testGitHubBuilderFromEnvironment() throws IOException { assertEquals("bogus", builder.user); assertEquals("bogus", builder.oauthToken); assertEquals("bogus", builder.password); + assertEquals("bogus", builder.jwtToken); } diff --git a/src/test/resources/org/kohsuke/github/GHAppTest/wiremock/createToken/__files/body-githubapp-create-installation-accesstokens.json b/src/test/resources/org/kohsuke/github/GHAppTest/wiremock/createToken/__files/body-githubapp-create-installation-accesstokens.json new file mode 100644 index 0000000000..d891cc0e7d --- /dev/null +++ b/src/test/resources/org/kohsuke/github/GHAppTest/wiremock/createToken/__files/body-githubapp-create-installation-accesstokens.json @@ -0,0 +1,107 @@ +{ + "token": "bogus", + "expires_at": "2019-08-10T05:54:58Z", + "permissions": { + "checks": "write", + "pull_requests": "write", + "contents": "read", + "metadata": "read" + }, + "repository_selection": "selected", + "repositories": [ + { + "id": 111111111, + "node_id": "asdfasdf", + "name": "bogus", + "full_name": "bogus/bogus", + "private": true, + "owner": { + "login": "bogus", + "id": 11111111, + "node_id": "asdfasdf", + "avatar_url": "https://avatars2.githubusercontent.com/u/11111111?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/bogus", + "html_url": "https://github.com/bogus", + "followers_url": "https://api.github.com/users/bogus/followers", + "following_url": "https://api.github.com/users/bogus/following{/other_user}", + "gists_url": "https://api.github.com/users/bogus/gists{/gist_id}", + "starred_url": "https://api.github.com/users/bogus/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/bogus/subscriptions", + "organizations_url": "https://api.github.com/users/bogus/orgs", + "repos_url": "https://api.github.com/users/bogus/repos", + "events_url": "https://api.github.com/users/bogus/events{/privacy}", + "received_events_url": "https://api.github.com/users/bogus/received_events", + "type": "Organization", + "site_admin": false + }, + "html_url": "https://github.com/bogus/bogus", + "description": null, + "fork": false, + "url": "https://api.github.com/repos/bogus/bogus", + "forks_url": "https://api.github.com/repos/bogus/bogus/forks", + "keys_url": "https://api.github.com/repos/bogus/bogus/keys{/key_id}", + "collaborators_url": "https://api.github.com/repos/bogus/bogus/collaborators{/collaborator}", + "teams_url": "https://api.github.com/repos/bogus/bogus/teams", + "hooks_url": "https://api.github.com/repos/bogus/bogus/hooks", + "issue_events_url": "https://api.github.com/repos/bogus/bogus/issues/events{/number}", + "events_url": "https://api.github.com/repos/bogus/bogus/events", + "assignees_url": "https://api.github.com/repos/bogus/bogus/assignees{/user}", + "branches_url": "https://api.github.com/repos/bogus/bogus/branches{/branch}", + "tags_url": "https://api.github.com/repos/bogus/bogus/tags", + "blobs_url": "https://api.github.com/repos/bogus/bogus/git/blobs{/sha}", + "git_tags_url": "https://api.github.com/repos/bogus/bogus/git/tags{/sha}", + "git_refs_url": "https://api.github.com/repos/bogus/bogus/git/refs{/sha}", + "trees_url": "https://api.github.com/repos/bogus/bogus/git/trees{/sha}", + "statuses_url": "https://api.github.com/repos/bogus/bogus/statuses/{sha}", + "languages_url": "https://api.github.com/repos/bogus/bogus/languages", + "stargazers_url": "https://api.github.com/repos/bogus/bogus/stargazers", + "contributors_url": "https://api.github.com/repos/bogus/bogus/contributors", + "subscribers_url": "https://api.github.com/repos/bogus/bogus/subscribers", + "subscription_url": "https://api.github.com/repos/bogus/bogus/subscription", + "commits_url": "https://api.github.com/repos/bogus/bogus/commits{/sha}", + "git_commits_url": "https://api.github.com/repos/bogus/bogus/git/commits{/sha}", + "comments_url": "https://api.github.com/repos/bogus/bogus/comments{/number}", + "issue_comment_url": "https://api.github.com/repos/bogus/bogus/issues/comments{/number}", + "contents_url": "https://api.github.com/repos/bogus/bogus/contents/{+path}", + "compare_url": "https://api.github.com/repos/bogus/bogus/compare/{base}...{head}", + "merges_url": "https://api.github.com/repos/bogus/bogus/merges", + "archive_url": "https://api.github.com/repos/bogus/bogus/{archive_format}{/ref}", + "downloads_url": "https://api.github.com/repos/bogus/bogus/downloads", + "issues_url": "https://api.github.com/repos/bogus/bogus/issues{/number}", + "pulls_url": "https://api.github.com/repos/bogus/bogus/pulls{/number}", + "milestones_url": "https://api.github.com/repos/bogus/bogus/milestones{/number}", + "notifications_url": "https://api.github.com/repos/bogus/bogus/notifications{?since,all,participating}", + "labels_url": "https://api.github.com/repos/bogus/bogus/labels{/name}", + "releases_url": "https://api.github.com/repos/bogus/bogus/releases{/id}", + "deployments_url": "https://api.github.com/repos/bogus/bogus/deployments", + "created_at": "2018-09-06T03:25:38Z", + "updated_at": "2018-09-30T22:04:06Z", + "pushed_at": "2019-08-08T22:22:34Z", + "git_url": "git://github.com/bogus/bogus.git", + "ssh_url": "git@github.com:bogus/bogus.git", + "clone_url": "https://github.com/bogus/bogus.git", + "svn_url": "https://github.com/bogus/bogus", + "homepage": null, + "size": 618, + "stargazers_count": 0, + "watchers_count": 0, + "language": "Java", + "has_issues": true, + "has_projects": true, + "has_downloads": true, + "has_wiki": true, + "has_pages": false, + "forks_count": 0, + "mirror_url": null, + "archived": false, + "disabled": false, + "open_issues_count": 5, + "license": null, + "forks": 0, + "open_issues": 5, + "watchers": 0, + "default_branch": "master" + } + ] +} \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/GHAppTest/wiremock/createToken/__files/body-mapping-githubapp-app.json b/src/test/resources/org/kohsuke/github/GHAppTest/wiremock/createToken/__files/body-mapping-githubapp-app.json new file mode 100644 index 0000000000..d36be086d7 --- /dev/null +++ b/src/test/resources/org/kohsuke/github/GHAppTest/wiremock/createToken/__files/body-mapping-githubapp-app.json @@ -0,0 +1,41 @@ +{ + "id": 11111, + "node_id": "MDM6QXBwMzI2MTY=", + "owner": { + "login": "bogus", + "id": 111111111, + "node_id": "asdfasdfasdf", + "avatar_url": "https://avatars2.githubusercontent.com/u/111111111?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/bogus", + "html_url": "https://github.com/bogus", + "followers_url": "https://api.github.com/users/bogus/followers", + "following_url": "https://api.github.com/users/bogus/following{/other_user}", + "gists_url": "https://api.github.com/users/bogus/gists{/gist_id}", + "starred_url": "https://api.github.com/users/bogus/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/bogus/subscriptions", + "organizations_url": "https://api.github.com/users/bogus/orgs", + "repos_url": "https://api.github.com/users/bogus/repos", + "events_url": "https://api.github.com/users/bogus/events{/privacy}", + "received_events_url": "https://api.github.com/users/bogus/received_events", + "type": "Organization", + "site_admin": false + }, + "name": "Bogus-Development", + "description": "", + "external_url": "https://bogus.domain.com", + "html_url": "https://github.com/apps/bogus-development", + "created_at": "2019-06-10T04:21:41Z", + "updated_at": "2019-06-10T04:21:41Z", + "permissions": { + "checks": "write", + "contents": "read", + "metadata": "read", + "pull_requests": "write" + }, + "events": [ + "pull_request", + "push" + ], + "installations_count": 1 +} \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/GHAppTest/wiremock/createToken/__files/body-mapping-githubapp-installation-by-user.json b/src/test/resources/org/kohsuke/github/GHAppTest/wiremock/createToken/__files/body-mapping-githubapp-installation-by-user.json new file mode 100644 index 0000000000..8975c0c55d --- /dev/null +++ b/src/test/resources/org/kohsuke/github/GHAppTest/wiremock/createToken/__files/body-mapping-githubapp-installation-by-user.json @@ -0,0 +1,43 @@ +{ + "id": 11111111, + "account": { + "login": "bogus", + "id": 111111111, + "node_id": "asdfasdfasdf", + "avatar_url": "https://avatars2.githubusercontent.com/u/111111111?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/bogus", + "html_url": "https://github.com/bogus", + "followers_url": "https://api.github.com/users/bogus/followers", + "following_url": "https://api.github.com/users/bogus/following{/other_user}", + "gists_url": "https://api.github.com/users/bogus/gists{/gist_id}", + "starred_url": "https://api.github.com/users/bogus/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/bogus/subscriptions", + "organizations_url": "https://api.github.com/users/bogus/orgs", + "repos_url": "https://api.github.com/users/bogus/repos", + "events_url": "https://api.github.com/users/bogus/events{/privacy}", + "received_events_url": "https://api.github.com/users/bogus/received_events", + "type": "Organization", + "site_admin": false + }, + "repository_selection": "selected", + "access_tokens_url": "https://api.github.com/app/installations/11111111/access_tokens", + "repositories_url": "https://api.github.com/installation/repositories", + "html_url": "https://github.com/organizations/bogus/settings/installations/11111111", + "app_id": 11111, + "target_id": 111111111, + "target_type": "Organization", + "permissions": { + "checks": "write", + "pull_requests": "write", + "contents": "read", + "metadata": "read" + }, + "events": [ + "pull_request", + "push" + ], + "created_at": "2019-07-04T01:19:36.000Z", + "updated_at": "2019-07-30T22:48:09.000Z", + "single_file_name": null +} \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/GHAppTest/wiremock/createToken/mappings/mapping-githubapp-app.json b/src/test/resources/org/kohsuke/github/GHAppTest/wiremock/createToken/mappings/mapping-githubapp-app.json new file mode 100644 index 0000000000..999f4c8286 --- /dev/null +++ b/src/test/resources/org/kohsuke/github/GHAppTest/wiremock/createToken/mappings/mapping-githubapp-app.json @@ -0,0 +1,34 @@ +{ + "request": { + "url": "/app", + "method": "GET", + "headers" : { + "Accept" : { + "equalTo" : "application/vnd.github.machine-man-preview+json" + } + } + }, + "response": { + "status": 200, + "bodyFileName": "body-mapping-githubapp-app.json", + "headers": { + "Server": "GitHub.com", + "Date": "Fri, 09 Aug 2019 05:36:38 GMT", + "Content-Type": "application/json; charset=utf-8", + "Status": "200 OK", + "Cache-Control": "public, max-age=60, s-maxage=60", + "Vary": ["Accept","Accept-Encoding"], + "ETag": "W/\"01163b1a237898d328ed56cd0e9aefca\"", + "X-GitHub-Media-Type": "github.machine-man-preview; format=json", + "Access-Control-Expose-Headers": "ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type", + "Access-Control-Allow-Origin": "*", + "Referrer-Policy": "origin-when-cross-origin, strict-origin-when-cross-origin", + "Content-Security-Policy": "default-src 'none'", + "Strict-Transport-Security": "max-age=31536000; includeSubdomains; preload", + "X-Content-Type-Options": "nosniff", + "X-Frame-Options": "deny", + "X-XSS-Protection": "1; mode=block", + "X-GitHub-Request-Id": "E0C4:3088:300C54:3ACB77:5D4D0666" + } + } +} \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/GHAppTest/wiremock/createToken/mappings/mapping-githubapp-create-installation-accesstokens.json b/src/test/resources/org/kohsuke/github/GHAppTest/wiremock/createToken/mappings/mapping-githubapp-create-installation-accesstokens.json new file mode 100644 index 0000000000..7996662d18 --- /dev/null +++ b/src/test/resources/org/kohsuke/github/GHAppTest/wiremock/createToken/mappings/mapping-githubapp-create-installation-accesstokens.json @@ -0,0 +1,39 @@ +{ + "request" : { + "url" : "/app/installations/11111111/access_tokens", + "method" : "POST", + "bodyPatterns" : [ { + "equalToJson" : "{\"repository_ids\":[111111111],\"permissions\":{\"pull_requests\":\"write\",\"metadata\":\"read\",\"checks\":\"write\",\"contents\":\"read\"}}", + "ignoreArrayOrder" : true, + "ignoreExtraElements" : false + } ], + "headers" : { + "Accept" : { + "equalTo" : "application/vnd.github.machine-man-preview+json" + } + } + }, + "response" : { + "status" : 201, + "bodyFileName" : "body-githubapp-create-installation-accesstokens.json", + "headers" : { + "Date" : "Sat, 10 Aug 2019 04:54:58 GMT", + "Content-Type" : "application/json; charset=utf-8", + "Server" : "GitHub.com", + "Status" : "201 Created", + "Cache-Control" : "public, max-age=60, s-maxage=60", + "Vary" : [ "Accept", "Accept-Encoding" ], + "ETag" : "\"c47070915d3f78d2c4aea4bd8a2c3351\"", + "X-GitHub-Media-Type" : "github.machine-man-preview; format=json", + "Access-Control-Expose-Headers" : "ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type", + "Access-Control-Allow-Origin" : "*", + "Strict-Transport-Security" : "max-age=31536000; includeSubdomains; preload", + "X-Frame-Options" : "deny", + "X-Content-Type-Options" : "nosniff", + "X-XSS-Protection" : "1; mode=block", + "Referrer-Policy" : "origin-when-cross-origin, strict-origin-when-cross-origin", + "Content-Security-Policy" : "default-src 'none'", + "X-GitHub-Request-Id" : "EEC8:4357:E0DD17:110A2E7:5D4E4E22" + } + } +} \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/GHAppTest/wiremock/createToken/mappings/mapping-githubapp-installation-by-user.json b/src/test/resources/org/kohsuke/github/GHAppTest/wiremock/createToken/mappings/mapping-githubapp-installation-by-user.json new file mode 100644 index 0000000000..573705fde7 --- /dev/null +++ b/src/test/resources/org/kohsuke/github/GHAppTest/wiremock/createToken/mappings/mapping-githubapp-installation-by-user.json @@ -0,0 +1,34 @@ +{ + "request": { + "url": "/users/bogus/installation", + "method": "GET", + "headers" : { + "Accept" : { + "equalTo" : "application/vnd.github.machine-man-preview+json" + } + } + }, + "response": { + "status": 200, + "bodyFileName": "body-mapping-githubapp-installation-by-user.json", + "headers": { + "Server": "GitHub.com", + "Date": "Fri, 09 Aug 2019 05:36:38 GMT", + "Content-Type": "application/json; charset=utf-8", + "Status": "200 OK", + "Cache-Control": "public, max-age=60, s-maxage=60", + "Vary": ["Accept","Accept-Encoding"], + "ETag": "W/\"01163b1a237898d328ed56cd0e9aefca\"", + "X-GitHub-Media-Type": "github.machine-man-preview; format=json", + "Access-Control-Expose-Headers": "ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type", + "Access-Control-Allow-Origin": "*", + "Referrer-Policy": "origin-when-cross-origin, strict-origin-when-cross-origin", + "Content-Security-Policy": "default-src 'none'", + "Strict-Transport-Security": "max-age=31536000; includeSubdomains; preload", + "X-Content-Type-Options": "nosniff", + "X-Frame-Options": "deny", + "X-XSS-Protection": "1; mode=block", + "X-GitHub-Request-Id": "E0C4:3088:300C54:3ACB77:5D4D0666" + } + } +} \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/GHAppTest/wiremock/deleteInstallation/__files/body-mapping-githubapp-app.json b/src/test/resources/org/kohsuke/github/GHAppTest/wiremock/deleteInstallation/__files/body-mapping-githubapp-app.json new file mode 100644 index 0000000000..d36be086d7 --- /dev/null +++ b/src/test/resources/org/kohsuke/github/GHAppTest/wiremock/deleteInstallation/__files/body-mapping-githubapp-app.json @@ -0,0 +1,41 @@ +{ + "id": 11111, + "node_id": "MDM6QXBwMzI2MTY=", + "owner": { + "login": "bogus", + "id": 111111111, + "node_id": "asdfasdfasdf", + "avatar_url": "https://avatars2.githubusercontent.com/u/111111111?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/bogus", + "html_url": "https://github.com/bogus", + "followers_url": "https://api.github.com/users/bogus/followers", + "following_url": "https://api.github.com/users/bogus/following{/other_user}", + "gists_url": "https://api.github.com/users/bogus/gists{/gist_id}", + "starred_url": "https://api.github.com/users/bogus/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/bogus/subscriptions", + "organizations_url": "https://api.github.com/users/bogus/orgs", + "repos_url": "https://api.github.com/users/bogus/repos", + "events_url": "https://api.github.com/users/bogus/events{/privacy}", + "received_events_url": "https://api.github.com/users/bogus/received_events", + "type": "Organization", + "site_admin": false + }, + "name": "Bogus-Development", + "description": "", + "external_url": "https://bogus.domain.com", + "html_url": "https://github.com/apps/bogus-development", + "created_at": "2019-06-10T04:21:41Z", + "updated_at": "2019-06-10T04:21:41Z", + "permissions": { + "checks": "write", + "contents": "read", + "metadata": "read", + "pull_requests": "write" + }, + "events": [ + "pull_request", + "push" + ], + "installations_count": 1 +} \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/GHAppTest/wiremock/deleteInstallation/__files/body-mapping-githubapp-installation-by-user.json b/src/test/resources/org/kohsuke/github/GHAppTest/wiremock/deleteInstallation/__files/body-mapping-githubapp-installation-by-user.json new file mode 100644 index 0000000000..8975c0c55d --- /dev/null +++ b/src/test/resources/org/kohsuke/github/GHAppTest/wiremock/deleteInstallation/__files/body-mapping-githubapp-installation-by-user.json @@ -0,0 +1,43 @@ +{ + "id": 11111111, + "account": { + "login": "bogus", + "id": 111111111, + "node_id": "asdfasdfasdf", + "avatar_url": "https://avatars2.githubusercontent.com/u/111111111?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/bogus", + "html_url": "https://github.com/bogus", + "followers_url": "https://api.github.com/users/bogus/followers", + "following_url": "https://api.github.com/users/bogus/following{/other_user}", + "gists_url": "https://api.github.com/users/bogus/gists{/gist_id}", + "starred_url": "https://api.github.com/users/bogus/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/bogus/subscriptions", + "organizations_url": "https://api.github.com/users/bogus/orgs", + "repos_url": "https://api.github.com/users/bogus/repos", + "events_url": "https://api.github.com/users/bogus/events{/privacy}", + "received_events_url": "https://api.github.com/users/bogus/received_events", + "type": "Organization", + "site_admin": false + }, + "repository_selection": "selected", + "access_tokens_url": "https://api.github.com/app/installations/11111111/access_tokens", + "repositories_url": "https://api.github.com/installation/repositories", + "html_url": "https://github.com/organizations/bogus/settings/installations/11111111", + "app_id": 11111, + "target_id": 111111111, + "target_type": "Organization", + "permissions": { + "checks": "write", + "pull_requests": "write", + "contents": "read", + "metadata": "read" + }, + "events": [ + "pull_request", + "push" + ], + "created_at": "2019-07-04T01:19:36.000Z", + "updated_at": "2019-07-30T22:48:09.000Z", + "single_file_name": null +} \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/GHAppTest/wiremock/deleteInstallation/mappings/mapping-githubapp-app.json b/src/test/resources/org/kohsuke/github/GHAppTest/wiremock/deleteInstallation/mappings/mapping-githubapp-app.json new file mode 100644 index 0000000000..999f4c8286 --- /dev/null +++ b/src/test/resources/org/kohsuke/github/GHAppTest/wiremock/deleteInstallation/mappings/mapping-githubapp-app.json @@ -0,0 +1,34 @@ +{ + "request": { + "url": "/app", + "method": "GET", + "headers" : { + "Accept" : { + "equalTo" : "application/vnd.github.machine-man-preview+json" + } + } + }, + "response": { + "status": 200, + "bodyFileName": "body-mapping-githubapp-app.json", + "headers": { + "Server": "GitHub.com", + "Date": "Fri, 09 Aug 2019 05:36:38 GMT", + "Content-Type": "application/json; charset=utf-8", + "Status": "200 OK", + "Cache-Control": "public, max-age=60, s-maxage=60", + "Vary": ["Accept","Accept-Encoding"], + "ETag": "W/\"01163b1a237898d328ed56cd0e9aefca\"", + "X-GitHub-Media-Type": "github.machine-man-preview; format=json", + "Access-Control-Expose-Headers": "ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type", + "Access-Control-Allow-Origin": "*", + "Referrer-Policy": "origin-when-cross-origin, strict-origin-when-cross-origin", + "Content-Security-Policy": "default-src 'none'", + "Strict-Transport-Security": "max-age=31536000; includeSubdomains; preload", + "X-Content-Type-Options": "nosniff", + "X-Frame-Options": "deny", + "X-XSS-Protection": "1; mode=block", + "X-GitHub-Request-Id": "E0C4:3088:300C54:3ACB77:5D4D0666" + } + } +} \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/GHAppTest/wiremock/deleteInstallation/mappings/mapping-githubapp-delete-installation.json b/src/test/resources/org/kohsuke/github/GHAppTest/wiremock/deleteInstallation/mappings/mapping-githubapp-delete-installation.json new file mode 100644 index 0000000000..4fbf043a8f --- /dev/null +++ b/src/test/resources/org/kohsuke/github/GHAppTest/wiremock/deleteInstallation/mappings/mapping-githubapp-delete-installation.json @@ -0,0 +1,33 @@ +{ + "request": { + "url": "/app/installations/11111111", + "method": "DELETE", + "headers" : { + "Accept" : { + "equalTo" : "application/vnd.github.gambit-preview+json" + } + } + }, + "response": { + "status": 204, + "headers": { + "Server": "GitHub.com", + "Date": "Fri, 09 Aug 2019 05:36:38 GMT", + "Content-Type": "application/json; charset=utf-8", + "Status": "204 No Content", + "Cache-Control": "public, max-age=60, s-maxage=60", + "Vary": ["Accept","Accept-Encoding"], + "ETag": "W/\"01163b1a237898d328ed56cd0e9aefca\"", + "X-GitHub-Media-Type": "github.machine-man-preview; format=json", + "Access-Control-Expose-Headers": "ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type", + "Access-Control-Allow-Origin": "*", + "Referrer-Policy": "origin-when-cross-origin, strict-origin-when-cross-origin", + "Content-Security-Policy": "default-src 'none'", + "Strict-Transport-Security": "max-age=31536000; includeSubdomains; preload", + "X-Content-Type-Options": "nosniff", + "X-Frame-Options": "deny", + "X-XSS-Protection": "1; mode=block", + "X-GitHub-Request-Id": "E0C4:3088:300C54:3ACB77:5D4D0666" + } + } +} \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/GHAppTest/wiremock/deleteInstallation/mappings/mapping-githubapp-installation-by-user.json b/src/test/resources/org/kohsuke/github/GHAppTest/wiremock/deleteInstallation/mappings/mapping-githubapp-installation-by-user.json new file mode 100644 index 0000000000..573705fde7 --- /dev/null +++ b/src/test/resources/org/kohsuke/github/GHAppTest/wiremock/deleteInstallation/mappings/mapping-githubapp-installation-by-user.json @@ -0,0 +1,34 @@ +{ + "request": { + "url": "/users/bogus/installation", + "method": "GET", + "headers" : { + "Accept" : { + "equalTo" : "application/vnd.github.machine-man-preview+json" + } + } + }, + "response": { + "status": 200, + "bodyFileName": "body-mapping-githubapp-installation-by-user.json", + "headers": { + "Server": "GitHub.com", + "Date": "Fri, 09 Aug 2019 05:36:38 GMT", + "Content-Type": "application/json; charset=utf-8", + "Status": "200 OK", + "Cache-Control": "public, max-age=60, s-maxage=60", + "Vary": ["Accept","Accept-Encoding"], + "ETag": "W/\"01163b1a237898d328ed56cd0e9aefca\"", + "X-GitHub-Media-Type": "github.machine-man-preview; format=json", + "Access-Control-Expose-Headers": "ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type", + "Access-Control-Allow-Origin": "*", + "Referrer-Policy": "origin-when-cross-origin, strict-origin-when-cross-origin", + "Content-Security-Policy": "default-src 'none'", + "Strict-Transport-Security": "max-age=31536000; includeSubdomains; preload", + "X-Content-Type-Options": "nosniff", + "X-Frame-Options": "deny", + "X-XSS-Protection": "1; mode=block", + "X-GitHub-Request-Id": "E0C4:3088:300C54:3ACB77:5D4D0666" + } + } +} \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/GHAppTest/wiremock/getGitHubApp/__files/body-mapping-githubapp-app.json b/src/test/resources/org/kohsuke/github/GHAppTest/wiremock/getGitHubApp/__files/body-mapping-githubapp-app.json new file mode 100644 index 0000000000..d36be086d7 --- /dev/null +++ b/src/test/resources/org/kohsuke/github/GHAppTest/wiremock/getGitHubApp/__files/body-mapping-githubapp-app.json @@ -0,0 +1,41 @@ +{ + "id": 11111, + "node_id": "MDM6QXBwMzI2MTY=", + "owner": { + "login": "bogus", + "id": 111111111, + "node_id": "asdfasdfasdf", + "avatar_url": "https://avatars2.githubusercontent.com/u/111111111?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/bogus", + "html_url": "https://github.com/bogus", + "followers_url": "https://api.github.com/users/bogus/followers", + "following_url": "https://api.github.com/users/bogus/following{/other_user}", + "gists_url": "https://api.github.com/users/bogus/gists{/gist_id}", + "starred_url": "https://api.github.com/users/bogus/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/bogus/subscriptions", + "organizations_url": "https://api.github.com/users/bogus/orgs", + "repos_url": "https://api.github.com/users/bogus/repos", + "events_url": "https://api.github.com/users/bogus/events{/privacy}", + "received_events_url": "https://api.github.com/users/bogus/received_events", + "type": "Organization", + "site_admin": false + }, + "name": "Bogus-Development", + "description": "", + "external_url": "https://bogus.domain.com", + "html_url": "https://github.com/apps/bogus-development", + "created_at": "2019-06-10T04:21:41Z", + "updated_at": "2019-06-10T04:21:41Z", + "permissions": { + "checks": "write", + "contents": "read", + "metadata": "read", + "pull_requests": "write" + }, + "events": [ + "pull_request", + "push" + ], + "installations_count": 1 +} \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/GHAppTest/wiremock/getGitHubApp/mappings/mapping-githubapp-app.json b/src/test/resources/org/kohsuke/github/GHAppTest/wiremock/getGitHubApp/mappings/mapping-githubapp-app.json new file mode 100644 index 0000000000..999f4c8286 --- /dev/null +++ b/src/test/resources/org/kohsuke/github/GHAppTest/wiremock/getGitHubApp/mappings/mapping-githubapp-app.json @@ -0,0 +1,34 @@ +{ + "request": { + "url": "/app", + "method": "GET", + "headers" : { + "Accept" : { + "equalTo" : "application/vnd.github.machine-man-preview+json" + } + } + }, + "response": { + "status": 200, + "bodyFileName": "body-mapping-githubapp-app.json", + "headers": { + "Server": "GitHub.com", + "Date": "Fri, 09 Aug 2019 05:36:38 GMT", + "Content-Type": "application/json; charset=utf-8", + "Status": "200 OK", + "Cache-Control": "public, max-age=60, s-maxage=60", + "Vary": ["Accept","Accept-Encoding"], + "ETag": "W/\"01163b1a237898d328ed56cd0e9aefca\"", + "X-GitHub-Media-Type": "github.machine-man-preview; format=json", + "Access-Control-Expose-Headers": "ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type", + "Access-Control-Allow-Origin": "*", + "Referrer-Policy": "origin-when-cross-origin, strict-origin-when-cross-origin", + "Content-Security-Policy": "default-src 'none'", + "Strict-Transport-Security": "max-age=31536000; includeSubdomains; preload", + "X-Content-Type-Options": "nosniff", + "X-Frame-Options": "deny", + "X-XSS-Protection": "1; mode=block", + "X-GitHub-Request-Id": "E0C4:3088:300C54:3ACB77:5D4D0666" + } + } +} \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/GHAppTest/wiremock/getInstallationById/__files/body-mapping-githubapp-app.json b/src/test/resources/org/kohsuke/github/GHAppTest/wiremock/getInstallationById/__files/body-mapping-githubapp-app.json new file mode 100644 index 0000000000..d36be086d7 --- /dev/null +++ b/src/test/resources/org/kohsuke/github/GHAppTest/wiremock/getInstallationById/__files/body-mapping-githubapp-app.json @@ -0,0 +1,41 @@ +{ + "id": 11111, + "node_id": "MDM6QXBwMzI2MTY=", + "owner": { + "login": "bogus", + "id": 111111111, + "node_id": "asdfasdfasdf", + "avatar_url": "https://avatars2.githubusercontent.com/u/111111111?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/bogus", + "html_url": "https://github.com/bogus", + "followers_url": "https://api.github.com/users/bogus/followers", + "following_url": "https://api.github.com/users/bogus/following{/other_user}", + "gists_url": "https://api.github.com/users/bogus/gists{/gist_id}", + "starred_url": "https://api.github.com/users/bogus/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/bogus/subscriptions", + "organizations_url": "https://api.github.com/users/bogus/orgs", + "repos_url": "https://api.github.com/users/bogus/repos", + "events_url": "https://api.github.com/users/bogus/events{/privacy}", + "received_events_url": "https://api.github.com/users/bogus/received_events", + "type": "Organization", + "site_admin": false + }, + "name": "Bogus-Development", + "description": "", + "external_url": "https://bogus.domain.com", + "html_url": "https://github.com/apps/bogus-development", + "created_at": "2019-06-10T04:21:41Z", + "updated_at": "2019-06-10T04:21:41Z", + "permissions": { + "checks": "write", + "contents": "read", + "metadata": "read", + "pull_requests": "write" + }, + "events": [ + "pull_request", + "push" + ], + "installations_count": 1 +} \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/GHAppTest/wiremock/getInstallationById/__files/body-mapping-githubapp-installation-by-id.json b/src/test/resources/org/kohsuke/github/GHAppTest/wiremock/getInstallationById/__files/body-mapping-githubapp-installation-by-id.json new file mode 100644 index 0000000000..8975c0c55d --- /dev/null +++ b/src/test/resources/org/kohsuke/github/GHAppTest/wiremock/getInstallationById/__files/body-mapping-githubapp-installation-by-id.json @@ -0,0 +1,43 @@ +{ + "id": 11111111, + "account": { + "login": "bogus", + "id": 111111111, + "node_id": "asdfasdfasdf", + "avatar_url": "https://avatars2.githubusercontent.com/u/111111111?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/bogus", + "html_url": "https://github.com/bogus", + "followers_url": "https://api.github.com/users/bogus/followers", + "following_url": "https://api.github.com/users/bogus/following{/other_user}", + "gists_url": "https://api.github.com/users/bogus/gists{/gist_id}", + "starred_url": "https://api.github.com/users/bogus/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/bogus/subscriptions", + "organizations_url": "https://api.github.com/users/bogus/orgs", + "repos_url": "https://api.github.com/users/bogus/repos", + "events_url": "https://api.github.com/users/bogus/events{/privacy}", + "received_events_url": "https://api.github.com/users/bogus/received_events", + "type": "Organization", + "site_admin": false + }, + "repository_selection": "selected", + "access_tokens_url": "https://api.github.com/app/installations/11111111/access_tokens", + "repositories_url": "https://api.github.com/installation/repositories", + "html_url": "https://github.com/organizations/bogus/settings/installations/11111111", + "app_id": 11111, + "target_id": 111111111, + "target_type": "Organization", + "permissions": { + "checks": "write", + "pull_requests": "write", + "contents": "read", + "metadata": "read" + }, + "events": [ + "pull_request", + "push" + ], + "created_at": "2019-07-04T01:19:36.000Z", + "updated_at": "2019-07-30T22:48:09.000Z", + "single_file_name": null +} \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/GHAppTest/wiremock/getInstallationById/mappings/mapping-githubapp-app.json b/src/test/resources/org/kohsuke/github/GHAppTest/wiremock/getInstallationById/mappings/mapping-githubapp-app.json new file mode 100644 index 0000000000..999f4c8286 --- /dev/null +++ b/src/test/resources/org/kohsuke/github/GHAppTest/wiremock/getInstallationById/mappings/mapping-githubapp-app.json @@ -0,0 +1,34 @@ +{ + "request": { + "url": "/app", + "method": "GET", + "headers" : { + "Accept" : { + "equalTo" : "application/vnd.github.machine-man-preview+json" + } + } + }, + "response": { + "status": 200, + "bodyFileName": "body-mapping-githubapp-app.json", + "headers": { + "Server": "GitHub.com", + "Date": "Fri, 09 Aug 2019 05:36:38 GMT", + "Content-Type": "application/json; charset=utf-8", + "Status": "200 OK", + "Cache-Control": "public, max-age=60, s-maxage=60", + "Vary": ["Accept","Accept-Encoding"], + "ETag": "W/\"01163b1a237898d328ed56cd0e9aefca\"", + "X-GitHub-Media-Type": "github.machine-man-preview; format=json", + "Access-Control-Expose-Headers": "ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type", + "Access-Control-Allow-Origin": "*", + "Referrer-Policy": "origin-when-cross-origin, strict-origin-when-cross-origin", + "Content-Security-Policy": "default-src 'none'", + "Strict-Transport-Security": "max-age=31536000; includeSubdomains; preload", + "X-Content-Type-Options": "nosniff", + "X-Frame-Options": "deny", + "X-XSS-Protection": "1; mode=block", + "X-GitHub-Request-Id": "E0C4:3088:300C54:3ACB77:5D4D0666" + } + } +} \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/GHAppTest/wiremock/getInstallationById/mappings/mapping-githubapp-installation-by-id.json b/src/test/resources/org/kohsuke/github/GHAppTest/wiremock/getInstallationById/mappings/mapping-githubapp-installation-by-id.json new file mode 100644 index 0000000000..87ba55f445 --- /dev/null +++ b/src/test/resources/org/kohsuke/github/GHAppTest/wiremock/getInstallationById/mappings/mapping-githubapp-installation-by-id.json @@ -0,0 +1,34 @@ +{ + "request": { + "url": "/app/installations/1111111", + "method": "GET", + "headers" : { + "Accept" : { + "equalTo" : "application/vnd.github.machine-man-preview+json" + } + } + }, + "response": { + "status": 200, + "bodyFileName": "body-mapping-githubapp-installation-by-id.json", + "headers": { + "Server": "GitHub.com", + "Date": "Fri, 09 Aug 2019 05:36:38 GMT", + "Content-Type": "application/json; charset=utf-8", + "Status": "200 OK", + "Cache-Control": "public, max-age=60, s-maxage=60", + "Vary": ["Accept","Accept-Encoding"], + "ETag": "W/\"01163b1a237898d328ed56cd0e9aefca\"", + "X-GitHub-Media-Type": "github.machine-man-preview; format=json", + "Access-Control-Expose-Headers": "ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type", + "Access-Control-Allow-Origin": "*", + "Referrer-Policy": "origin-when-cross-origin, strict-origin-when-cross-origin", + "Content-Security-Policy": "default-src 'none'", + "Strict-Transport-Security": "max-age=31536000; includeSubdomains; preload", + "X-Content-Type-Options": "nosniff", + "X-Frame-Options": "deny", + "X-XSS-Protection": "1; mode=block", + "X-GitHub-Request-Id": "E0C4:3088:300C54:3ACB77:5D4D0666" + } + } +} \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/GHAppTest/wiremock/getInstallationByOrganization/__files/body-mapping-githubapp-app.json b/src/test/resources/org/kohsuke/github/GHAppTest/wiremock/getInstallationByOrganization/__files/body-mapping-githubapp-app.json new file mode 100644 index 0000000000..d36be086d7 --- /dev/null +++ b/src/test/resources/org/kohsuke/github/GHAppTest/wiremock/getInstallationByOrganization/__files/body-mapping-githubapp-app.json @@ -0,0 +1,41 @@ +{ + "id": 11111, + "node_id": "MDM6QXBwMzI2MTY=", + "owner": { + "login": "bogus", + "id": 111111111, + "node_id": "asdfasdfasdf", + "avatar_url": "https://avatars2.githubusercontent.com/u/111111111?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/bogus", + "html_url": "https://github.com/bogus", + "followers_url": "https://api.github.com/users/bogus/followers", + "following_url": "https://api.github.com/users/bogus/following{/other_user}", + "gists_url": "https://api.github.com/users/bogus/gists{/gist_id}", + "starred_url": "https://api.github.com/users/bogus/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/bogus/subscriptions", + "organizations_url": "https://api.github.com/users/bogus/orgs", + "repos_url": "https://api.github.com/users/bogus/repos", + "events_url": "https://api.github.com/users/bogus/events{/privacy}", + "received_events_url": "https://api.github.com/users/bogus/received_events", + "type": "Organization", + "site_admin": false + }, + "name": "Bogus-Development", + "description": "", + "external_url": "https://bogus.domain.com", + "html_url": "https://github.com/apps/bogus-development", + "created_at": "2019-06-10T04:21:41Z", + "updated_at": "2019-06-10T04:21:41Z", + "permissions": { + "checks": "write", + "contents": "read", + "metadata": "read", + "pull_requests": "write" + }, + "events": [ + "pull_request", + "push" + ], + "installations_count": 1 +} \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/GHAppTest/wiremock/getInstallationByOrganization/__files/body-mapping-githubapp-installation-by-organization.json b/src/test/resources/org/kohsuke/github/GHAppTest/wiremock/getInstallationByOrganization/__files/body-mapping-githubapp-installation-by-organization.json new file mode 100644 index 0000000000..8975c0c55d --- /dev/null +++ b/src/test/resources/org/kohsuke/github/GHAppTest/wiremock/getInstallationByOrganization/__files/body-mapping-githubapp-installation-by-organization.json @@ -0,0 +1,43 @@ +{ + "id": 11111111, + "account": { + "login": "bogus", + "id": 111111111, + "node_id": "asdfasdfasdf", + "avatar_url": "https://avatars2.githubusercontent.com/u/111111111?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/bogus", + "html_url": "https://github.com/bogus", + "followers_url": "https://api.github.com/users/bogus/followers", + "following_url": "https://api.github.com/users/bogus/following{/other_user}", + "gists_url": "https://api.github.com/users/bogus/gists{/gist_id}", + "starred_url": "https://api.github.com/users/bogus/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/bogus/subscriptions", + "organizations_url": "https://api.github.com/users/bogus/orgs", + "repos_url": "https://api.github.com/users/bogus/repos", + "events_url": "https://api.github.com/users/bogus/events{/privacy}", + "received_events_url": "https://api.github.com/users/bogus/received_events", + "type": "Organization", + "site_admin": false + }, + "repository_selection": "selected", + "access_tokens_url": "https://api.github.com/app/installations/11111111/access_tokens", + "repositories_url": "https://api.github.com/installation/repositories", + "html_url": "https://github.com/organizations/bogus/settings/installations/11111111", + "app_id": 11111, + "target_id": 111111111, + "target_type": "Organization", + "permissions": { + "checks": "write", + "pull_requests": "write", + "contents": "read", + "metadata": "read" + }, + "events": [ + "pull_request", + "push" + ], + "created_at": "2019-07-04T01:19:36.000Z", + "updated_at": "2019-07-30T22:48:09.000Z", + "single_file_name": null +} \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/GHAppTest/wiremock/getInstallationByOrganization/mappings/mapping-githubapp-app.json b/src/test/resources/org/kohsuke/github/GHAppTest/wiremock/getInstallationByOrganization/mappings/mapping-githubapp-app.json new file mode 100644 index 0000000000..999f4c8286 --- /dev/null +++ b/src/test/resources/org/kohsuke/github/GHAppTest/wiremock/getInstallationByOrganization/mappings/mapping-githubapp-app.json @@ -0,0 +1,34 @@ +{ + "request": { + "url": "/app", + "method": "GET", + "headers" : { + "Accept" : { + "equalTo" : "application/vnd.github.machine-man-preview+json" + } + } + }, + "response": { + "status": 200, + "bodyFileName": "body-mapping-githubapp-app.json", + "headers": { + "Server": "GitHub.com", + "Date": "Fri, 09 Aug 2019 05:36:38 GMT", + "Content-Type": "application/json; charset=utf-8", + "Status": "200 OK", + "Cache-Control": "public, max-age=60, s-maxage=60", + "Vary": ["Accept","Accept-Encoding"], + "ETag": "W/\"01163b1a237898d328ed56cd0e9aefca\"", + "X-GitHub-Media-Type": "github.machine-man-preview; format=json", + "Access-Control-Expose-Headers": "ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type", + "Access-Control-Allow-Origin": "*", + "Referrer-Policy": "origin-when-cross-origin, strict-origin-when-cross-origin", + "Content-Security-Policy": "default-src 'none'", + "Strict-Transport-Security": "max-age=31536000; includeSubdomains; preload", + "X-Content-Type-Options": "nosniff", + "X-Frame-Options": "deny", + "X-XSS-Protection": "1; mode=block", + "X-GitHub-Request-Id": "E0C4:3088:300C54:3ACB77:5D4D0666" + } + } +} \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/GHAppTest/wiremock/getInstallationByOrganization/mappings/mapping-githubapp-installation-by-organization.json b/src/test/resources/org/kohsuke/github/GHAppTest/wiremock/getInstallationByOrganization/mappings/mapping-githubapp-installation-by-organization.json new file mode 100644 index 0000000000..bd94ed4800 --- /dev/null +++ b/src/test/resources/org/kohsuke/github/GHAppTest/wiremock/getInstallationByOrganization/mappings/mapping-githubapp-installation-by-organization.json @@ -0,0 +1,34 @@ +{ + "request": { + "url": "/orgs/bogus/installation", + "method": "GET", + "headers" : { + "Accept" : { + "equalTo" : "application/vnd.github.machine-man-preview+json" + } + } + }, + "response": { + "status": 200, + "bodyFileName": "body-mapping-githubapp-installation-by-organization.json", + "headers": { + "Server": "GitHub.com", + "Date": "Fri, 09 Aug 2019 05:36:38 GMT", + "Content-Type": "application/json; charset=utf-8", + "Status": "200 OK", + "Cache-Control": "public, max-age=60, s-maxage=60", + "Vary": ["Accept","Accept-Encoding"], + "ETag": "W/\"01163b1a237898d328ed56cd0e9aefca\"", + "X-GitHub-Media-Type": "github.machine-man-preview; format=json", + "Access-Control-Expose-Headers": "ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type", + "Access-Control-Allow-Origin": "*", + "Referrer-Policy": "origin-when-cross-origin, strict-origin-when-cross-origin", + "Content-Security-Policy": "default-src 'none'", + "Strict-Transport-Security": "max-age=31536000; includeSubdomains; preload", + "X-Content-Type-Options": "nosniff", + "X-Frame-Options": "deny", + "X-XSS-Protection": "1; mode=block", + "X-GitHub-Request-Id": "E0C4:3088:300C54:3ACB77:5D4D0666" + } + } +} \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/GHAppTest/wiremock/getInstallationByRepository/__files/body-mapping-githubapp-app.json b/src/test/resources/org/kohsuke/github/GHAppTest/wiremock/getInstallationByRepository/__files/body-mapping-githubapp-app.json new file mode 100644 index 0000000000..d36be086d7 --- /dev/null +++ b/src/test/resources/org/kohsuke/github/GHAppTest/wiremock/getInstallationByRepository/__files/body-mapping-githubapp-app.json @@ -0,0 +1,41 @@ +{ + "id": 11111, + "node_id": "MDM6QXBwMzI2MTY=", + "owner": { + "login": "bogus", + "id": 111111111, + "node_id": "asdfasdfasdf", + "avatar_url": "https://avatars2.githubusercontent.com/u/111111111?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/bogus", + "html_url": "https://github.com/bogus", + "followers_url": "https://api.github.com/users/bogus/followers", + "following_url": "https://api.github.com/users/bogus/following{/other_user}", + "gists_url": "https://api.github.com/users/bogus/gists{/gist_id}", + "starred_url": "https://api.github.com/users/bogus/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/bogus/subscriptions", + "organizations_url": "https://api.github.com/users/bogus/orgs", + "repos_url": "https://api.github.com/users/bogus/repos", + "events_url": "https://api.github.com/users/bogus/events{/privacy}", + "received_events_url": "https://api.github.com/users/bogus/received_events", + "type": "Organization", + "site_admin": false + }, + "name": "Bogus-Development", + "description": "", + "external_url": "https://bogus.domain.com", + "html_url": "https://github.com/apps/bogus-development", + "created_at": "2019-06-10T04:21:41Z", + "updated_at": "2019-06-10T04:21:41Z", + "permissions": { + "checks": "write", + "contents": "read", + "metadata": "read", + "pull_requests": "write" + }, + "events": [ + "pull_request", + "push" + ], + "installations_count": 1 +} \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/GHAppTest/wiremock/getInstallationByRepository/__files/body-mapping-githubapp-installation-by-repository.json b/src/test/resources/org/kohsuke/github/GHAppTest/wiremock/getInstallationByRepository/__files/body-mapping-githubapp-installation-by-repository.json new file mode 100644 index 0000000000..8975c0c55d --- /dev/null +++ b/src/test/resources/org/kohsuke/github/GHAppTest/wiremock/getInstallationByRepository/__files/body-mapping-githubapp-installation-by-repository.json @@ -0,0 +1,43 @@ +{ + "id": 11111111, + "account": { + "login": "bogus", + "id": 111111111, + "node_id": "asdfasdfasdf", + "avatar_url": "https://avatars2.githubusercontent.com/u/111111111?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/bogus", + "html_url": "https://github.com/bogus", + "followers_url": "https://api.github.com/users/bogus/followers", + "following_url": "https://api.github.com/users/bogus/following{/other_user}", + "gists_url": "https://api.github.com/users/bogus/gists{/gist_id}", + "starred_url": "https://api.github.com/users/bogus/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/bogus/subscriptions", + "organizations_url": "https://api.github.com/users/bogus/orgs", + "repos_url": "https://api.github.com/users/bogus/repos", + "events_url": "https://api.github.com/users/bogus/events{/privacy}", + "received_events_url": "https://api.github.com/users/bogus/received_events", + "type": "Organization", + "site_admin": false + }, + "repository_selection": "selected", + "access_tokens_url": "https://api.github.com/app/installations/11111111/access_tokens", + "repositories_url": "https://api.github.com/installation/repositories", + "html_url": "https://github.com/organizations/bogus/settings/installations/11111111", + "app_id": 11111, + "target_id": 111111111, + "target_type": "Organization", + "permissions": { + "checks": "write", + "pull_requests": "write", + "contents": "read", + "metadata": "read" + }, + "events": [ + "pull_request", + "push" + ], + "created_at": "2019-07-04T01:19:36.000Z", + "updated_at": "2019-07-30T22:48:09.000Z", + "single_file_name": null +} \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/GHAppTest/wiremock/getInstallationByRepository/mappings/mapping-githubapp-app.json b/src/test/resources/org/kohsuke/github/GHAppTest/wiremock/getInstallationByRepository/mappings/mapping-githubapp-app.json new file mode 100644 index 0000000000..999f4c8286 --- /dev/null +++ b/src/test/resources/org/kohsuke/github/GHAppTest/wiremock/getInstallationByRepository/mappings/mapping-githubapp-app.json @@ -0,0 +1,34 @@ +{ + "request": { + "url": "/app", + "method": "GET", + "headers" : { + "Accept" : { + "equalTo" : "application/vnd.github.machine-man-preview+json" + } + } + }, + "response": { + "status": 200, + "bodyFileName": "body-mapping-githubapp-app.json", + "headers": { + "Server": "GitHub.com", + "Date": "Fri, 09 Aug 2019 05:36:38 GMT", + "Content-Type": "application/json; charset=utf-8", + "Status": "200 OK", + "Cache-Control": "public, max-age=60, s-maxage=60", + "Vary": ["Accept","Accept-Encoding"], + "ETag": "W/\"01163b1a237898d328ed56cd0e9aefca\"", + "X-GitHub-Media-Type": "github.machine-man-preview; format=json", + "Access-Control-Expose-Headers": "ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type", + "Access-Control-Allow-Origin": "*", + "Referrer-Policy": "origin-when-cross-origin, strict-origin-when-cross-origin", + "Content-Security-Policy": "default-src 'none'", + "Strict-Transport-Security": "max-age=31536000; includeSubdomains; preload", + "X-Content-Type-Options": "nosniff", + "X-Frame-Options": "deny", + "X-XSS-Protection": "1; mode=block", + "X-GitHub-Request-Id": "E0C4:3088:300C54:3ACB77:5D4D0666" + } + } +} \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/GHAppTest/wiremock/getInstallationByRepository/mappings/mapping-githubapp-installation-by-repository.json b/src/test/resources/org/kohsuke/github/GHAppTest/wiremock/getInstallationByRepository/mappings/mapping-githubapp-installation-by-repository.json new file mode 100644 index 0000000000..3fd3c011c0 --- /dev/null +++ b/src/test/resources/org/kohsuke/github/GHAppTest/wiremock/getInstallationByRepository/mappings/mapping-githubapp-installation-by-repository.json @@ -0,0 +1,34 @@ +{ + "request": { + "url": "/repos/bogus/bogus/installation", + "method": "GET", + "headers" : { + "Accept" : { + "equalTo" : "application/vnd.github.machine-man-preview+json" + } + } + }, + "response": { + "status": 200, + "bodyFileName": "body-mapping-githubapp-installation-by-repository.json", + "headers": { + "Server": "GitHub.com", + "Date": "Fri, 09 Aug 2019 05:36:38 GMT", + "Content-Type": "application/json; charset=utf-8", + "Status": "200 OK", + "Cache-Control": "public, max-age=60, s-maxage=60", + "Vary": ["Accept","Accept-Encoding"], + "ETag": "W/\"01163b1a237898d328ed56cd0e9aefca\"", + "X-GitHub-Media-Type": "github.machine-man-preview; format=json", + "Access-Control-Expose-Headers": "ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type", + "Access-Control-Allow-Origin": "*", + "Referrer-Policy": "origin-when-cross-origin, strict-origin-when-cross-origin", + "Content-Security-Policy": "default-src 'none'", + "Strict-Transport-Security": "max-age=31536000; includeSubdomains; preload", + "X-Content-Type-Options": "nosniff", + "X-Frame-Options": "deny", + "X-XSS-Protection": "1; mode=block", + "X-GitHub-Request-Id": "E0C4:3088:300C54:3ACB77:5D4D0666" + } + } +} \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/GHAppTest/wiremock/getInstallationByUser/__files/body-mapping-githubapp-app.json b/src/test/resources/org/kohsuke/github/GHAppTest/wiremock/getInstallationByUser/__files/body-mapping-githubapp-app.json new file mode 100644 index 0000000000..d36be086d7 --- /dev/null +++ b/src/test/resources/org/kohsuke/github/GHAppTest/wiremock/getInstallationByUser/__files/body-mapping-githubapp-app.json @@ -0,0 +1,41 @@ +{ + "id": 11111, + "node_id": "MDM6QXBwMzI2MTY=", + "owner": { + "login": "bogus", + "id": 111111111, + "node_id": "asdfasdfasdf", + "avatar_url": "https://avatars2.githubusercontent.com/u/111111111?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/bogus", + "html_url": "https://github.com/bogus", + "followers_url": "https://api.github.com/users/bogus/followers", + "following_url": "https://api.github.com/users/bogus/following{/other_user}", + "gists_url": "https://api.github.com/users/bogus/gists{/gist_id}", + "starred_url": "https://api.github.com/users/bogus/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/bogus/subscriptions", + "organizations_url": "https://api.github.com/users/bogus/orgs", + "repos_url": "https://api.github.com/users/bogus/repos", + "events_url": "https://api.github.com/users/bogus/events{/privacy}", + "received_events_url": "https://api.github.com/users/bogus/received_events", + "type": "Organization", + "site_admin": false + }, + "name": "Bogus-Development", + "description": "", + "external_url": "https://bogus.domain.com", + "html_url": "https://github.com/apps/bogus-development", + "created_at": "2019-06-10T04:21:41Z", + "updated_at": "2019-06-10T04:21:41Z", + "permissions": { + "checks": "write", + "contents": "read", + "metadata": "read", + "pull_requests": "write" + }, + "events": [ + "pull_request", + "push" + ], + "installations_count": 1 +} \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/GHAppTest/wiremock/getInstallationByUser/__files/body-mapping-githubapp-installation-by-user.json b/src/test/resources/org/kohsuke/github/GHAppTest/wiremock/getInstallationByUser/__files/body-mapping-githubapp-installation-by-user.json new file mode 100644 index 0000000000..8975c0c55d --- /dev/null +++ b/src/test/resources/org/kohsuke/github/GHAppTest/wiremock/getInstallationByUser/__files/body-mapping-githubapp-installation-by-user.json @@ -0,0 +1,43 @@ +{ + "id": 11111111, + "account": { + "login": "bogus", + "id": 111111111, + "node_id": "asdfasdfasdf", + "avatar_url": "https://avatars2.githubusercontent.com/u/111111111?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/bogus", + "html_url": "https://github.com/bogus", + "followers_url": "https://api.github.com/users/bogus/followers", + "following_url": "https://api.github.com/users/bogus/following{/other_user}", + "gists_url": "https://api.github.com/users/bogus/gists{/gist_id}", + "starred_url": "https://api.github.com/users/bogus/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/bogus/subscriptions", + "organizations_url": "https://api.github.com/users/bogus/orgs", + "repos_url": "https://api.github.com/users/bogus/repos", + "events_url": "https://api.github.com/users/bogus/events{/privacy}", + "received_events_url": "https://api.github.com/users/bogus/received_events", + "type": "Organization", + "site_admin": false + }, + "repository_selection": "selected", + "access_tokens_url": "https://api.github.com/app/installations/11111111/access_tokens", + "repositories_url": "https://api.github.com/installation/repositories", + "html_url": "https://github.com/organizations/bogus/settings/installations/11111111", + "app_id": 11111, + "target_id": 111111111, + "target_type": "Organization", + "permissions": { + "checks": "write", + "pull_requests": "write", + "contents": "read", + "metadata": "read" + }, + "events": [ + "pull_request", + "push" + ], + "created_at": "2019-07-04T01:19:36.000Z", + "updated_at": "2019-07-30T22:48:09.000Z", + "single_file_name": null +} \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/GHAppTest/wiremock/getInstallationByUser/mappings/mapping-githubapp-app.json b/src/test/resources/org/kohsuke/github/GHAppTest/wiremock/getInstallationByUser/mappings/mapping-githubapp-app.json new file mode 100644 index 0000000000..999f4c8286 --- /dev/null +++ b/src/test/resources/org/kohsuke/github/GHAppTest/wiremock/getInstallationByUser/mappings/mapping-githubapp-app.json @@ -0,0 +1,34 @@ +{ + "request": { + "url": "/app", + "method": "GET", + "headers" : { + "Accept" : { + "equalTo" : "application/vnd.github.machine-man-preview+json" + } + } + }, + "response": { + "status": 200, + "bodyFileName": "body-mapping-githubapp-app.json", + "headers": { + "Server": "GitHub.com", + "Date": "Fri, 09 Aug 2019 05:36:38 GMT", + "Content-Type": "application/json; charset=utf-8", + "Status": "200 OK", + "Cache-Control": "public, max-age=60, s-maxage=60", + "Vary": ["Accept","Accept-Encoding"], + "ETag": "W/\"01163b1a237898d328ed56cd0e9aefca\"", + "X-GitHub-Media-Type": "github.machine-man-preview; format=json", + "Access-Control-Expose-Headers": "ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type", + "Access-Control-Allow-Origin": "*", + "Referrer-Policy": "origin-when-cross-origin, strict-origin-when-cross-origin", + "Content-Security-Policy": "default-src 'none'", + "Strict-Transport-Security": "max-age=31536000; includeSubdomains; preload", + "X-Content-Type-Options": "nosniff", + "X-Frame-Options": "deny", + "X-XSS-Protection": "1; mode=block", + "X-GitHub-Request-Id": "E0C4:3088:300C54:3ACB77:5D4D0666" + } + } +} \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/GHAppTest/wiremock/getInstallationByUser/mappings/mapping-githubapp-installation-by-user.json b/src/test/resources/org/kohsuke/github/GHAppTest/wiremock/getInstallationByUser/mappings/mapping-githubapp-installation-by-user.json new file mode 100644 index 0000000000..573705fde7 --- /dev/null +++ b/src/test/resources/org/kohsuke/github/GHAppTest/wiremock/getInstallationByUser/mappings/mapping-githubapp-installation-by-user.json @@ -0,0 +1,34 @@ +{ + "request": { + "url": "/users/bogus/installation", + "method": "GET", + "headers" : { + "Accept" : { + "equalTo" : "application/vnd.github.machine-man-preview+json" + } + } + }, + "response": { + "status": 200, + "bodyFileName": "body-mapping-githubapp-installation-by-user.json", + "headers": { + "Server": "GitHub.com", + "Date": "Fri, 09 Aug 2019 05:36:38 GMT", + "Content-Type": "application/json; charset=utf-8", + "Status": "200 OK", + "Cache-Control": "public, max-age=60, s-maxage=60", + "Vary": ["Accept","Accept-Encoding"], + "ETag": "W/\"01163b1a237898d328ed56cd0e9aefca\"", + "X-GitHub-Media-Type": "github.machine-man-preview; format=json", + "Access-Control-Expose-Headers": "ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type", + "Access-Control-Allow-Origin": "*", + "Referrer-Policy": "origin-when-cross-origin, strict-origin-when-cross-origin", + "Content-Security-Policy": "default-src 'none'", + "Strict-Transport-Security": "max-age=31536000; includeSubdomains; preload", + "X-Content-Type-Options": "nosniff", + "X-Frame-Options": "deny", + "X-XSS-Protection": "1; mode=block", + "X-GitHub-Request-Id": "E0C4:3088:300C54:3ACB77:5D4D0666" + } + } +} \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/GHAppTest/wiremock/listInstallations/__files/body-mapping-githubapp-app.json b/src/test/resources/org/kohsuke/github/GHAppTest/wiremock/listInstallations/__files/body-mapping-githubapp-app.json new file mode 100644 index 0000000000..d36be086d7 --- /dev/null +++ b/src/test/resources/org/kohsuke/github/GHAppTest/wiremock/listInstallations/__files/body-mapping-githubapp-app.json @@ -0,0 +1,41 @@ +{ + "id": 11111, + "node_id": "MDM6QXBwMzI2MTY=", + "owner": { + "login": "bogus", + "id": 111111111, + "node_id": "asdfasdfasdf", + "avatar_url": "https://avatars2.githubusercontent.com/u/111111111?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/bogus", + "html_url": "https://github.com/bogus", + "followers_url": "https://api.github.com/users/bogus/followers", + "following_url": "https://api.github.com/users/bogus/following{/other_user}", + "gists_url": "https://api.github.com/users/bogus/gists{/gist_id}", + "starred_url": "https://api.github.com/users/bogus/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/bogus/subscriptions", + "organizations_url": "https://api.github.com/users/bogus/orgs", + "repos_url": "https://api.github.com/users/bogus/repos", + "events_url": "https://api.github.com/users/bogus/events{/privacy}", + "received_events_url": "https://api.github.com/users/bogus/received_events", + "type": "Organization", + "site_admin": false + }, + "name": "Bogus-Development", + "description": "", + "external_url": "https://bogus.domain.com", + "html_url": "https://github.com/apps/bogus-development", + "created_at": "2019-06-10T04:21:41Z", + "updated_at": "2019-06-10T04:21:41Z", + "permissions": { + "checks": "write", + "contents": "read", + "metadata": "read", + "pull_requests": "write" + }, + "events": [ + "pull_request", + "push" + ], + "installations_count": 1 +} \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/GHAppTest/wiremock/listInstallations/__files/body-mapping-githubapp-installations.json b/src/test/resources/org/kohsuke/github/GHAppTest/wiremock/listInstallations/__files/body-mapping-githubapp-installations.json new file mode 100644 index 0000000000..d81bc3786e --- /dev/null +++ b/src/test/resources/org/kohsuke/github/GHAppTest/wiremock/listInstallations/__files/body-mapping-githubapp-installations.json @@ -0,0 +1,45 @@ +[ + { + "id": 11111111, + "account": { + "login": "bogus", + "id": 111111111, + "node_id": "asdfasdfasdf", + "avatar_url": "https://avatars2.githubusercontent.com/u/111111111?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/bogus", + "html_url": "https://github.com/bogus", + "followers_url": "https://api.github.com/users/bogus/followers", + "following_url": "https://api.github.com/users/bogus/following{/other_user}", + "gists_url": "https://api.github.com/users/bogus/gists{/gist_id}", + "starred_url": "https://api.github.com/users/bogus/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/bogus/subscriptions", + "organizations_url": "https://api.github.com/users/bogus/orgs", + "repos_url": "https://api.github.com/users/bogus/repos", + "events_url": "https://api.github.com/users/bogus/events{/privacy}", + "received_events_url": "https://api.github.com/users/bogus/received_events", + "type": "Organization", + "site_admin": false + }, + "repository_selection": "selected", + "access_tokens_url": "https://api.github.com/app/installations/11111111/access_tokens", + "repositories_url": "https://api.github.com/installation/repositories", + "html_url": "https://github.com/organizations/bogus/settings/installations/11111111", + "app_id": 11111, + "target_id": 111111111, + "target_type": "Organization", + "permissions": { + "checks": "write", + "pull_requests": "write", + "contents": "read", + "metadata": "read" + }, + "events": [ + "pull_request", + "push" + ], + "created_at": "2019-07-04T01:19:36.000Z", + "updated_at": "2019-07-30T22:48:09.000Z", + "single_file_name": null + } +] \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/GHAppTest/wiremock/listInstallations/mappings/mapping-githubapp-app.json b/src/test/resources/org/kohsuke/github/GHAppTest/wiremock/listInstallations/mappings/mapping-githubapp-app.json new file mode 100644 index 0000000000..999f4c8286 --- /dev/null +++ b/src/test/resources/org/kohsuke/github/GHAppTest/wiremock/listInstallations/mappings/mapping-githubapp-app.json @@ -0,0 +1,34 @@ +{ + "request": { + "url": "/app", + "method": "GET", + "headers" : { + "Accept" : { + "equalTo" : "application/vnd.github.machine-man-preview+json" + } + } + }, + "response": { + "status": 200, + "bodyFileName": "body-mapping-githubapp-app.json", + "headers": { + "Server": "GitHub.com", + "Date": "Fri, 09 Aug 2019 05:36:38 GMT", + "Content-Type": "application/json; charset=utf-8", + "Status": "200 OK", + "Cache-Control": "public, max-age=60, s-maxage=60", + "Vary": ["Accept","Accept-Encoding"], + "ETag": "W/\"01163b1a237898d328ed56cd0e9aefca\"", + "X-GitHub-Media-Type": "github.machine-man-preview; format=json", + "Access-Control-Expose-Headers": "ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type", + "Access-Control-Allow-Origin": "*", + "Referrer-Policy": "origin-when-cross-origin, strict-origin-when-cross-origin", + "Content-Security-Policy": "default-src 'none'", + "Strict-Transport-Security": "max-age=31536000; includeSubdomains; preload", + "X-Content-Type-Options": "nosniff", + "X-Frame-Options": "deny", + "X-XSS-Protection": "1; mode=block", + "X-GitHub-Request-Id": "E0C4:3088:300C54:3ACB77:5D4D0666" + } + } +} \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/GHAppTest/wiremock/listInstallations/mappings/mapping-githubapp-installations.json b/src/test/resources/org/kohsuke/github/GHAppTest/wiremock/listInstallations/mappings/mapping-githubapp-installations.json new file mode 100644 index 0000000000..5b01455c26 --- /dev/null +++ b/src/test/resources/org/kohsuke/github/GHAppTest/wiremock/listInstallations/mappings/mapping-githubapp-installations.json @@ -0,0 +1,34 @@ +{ + "request": { + "url": "/app/installations", + "method": "GET", + "headers" : { + "Accept" : { + "equalTo" : "application/vnd.github.machine-man-preview+json" + } + } + }, + "response": { + "status": 200, + "bodyFileName": "body-mapping-githubapp-installations.json", + "headers": { + "Server": "GitHub.com", + "Date": "Fri, 09 Aug 2019 05:36:38 GMT", + "Content-Type": "application/json; charset=utf-8", + "Status": "200 OK", + "Cache-Control": "public, max-age=60, s-maxage=60", + "Vary": ["Accept","Accept-Encoding"], + "ETag": "W/\"01163b1a237898d328ed56cd0e9aefca\"", + "X-GitHub-Media-Type": "github.machine-man-preview; format=json", + "Access-Control-Expose-Headers": "ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type", + "Access-Control-Allow-Origin": "*", + "Referrer-Policy": "origin-when-cross-origin, strict-origin-when-cross-origin", + "Content-Security-Policy": "default-src 'none'", + "Strict-Transport-Security": "max-age=31536000; includeSubdomains; preload", + "X-Content-Type-Options": "nosniff", + "X-Frame-Options": "deny", + "X-XSS-Protection": "1; mode=block", + "X-GitHub-Request-Id": "E0C4:3088:300C54:3ACB77:5D4D0666" + } + } +} \ No newline at end of file