Skip to content

Commit a4a11f7

Browse files
committed
Upgrade GHAppTest#getGitHubApp with a recent WireMock snapshot
1 parent 319e943 commit a4a11f7

File tree

4 files changed

+69
-67
lines changed

4 files changed

+69
-67
lines changed

src/test/java/org/kohsuke/github/GHAppTest.java

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -17,29 +17,33 @@
1717
*
1818
* @author Paulo Miguel Almeida
1919
*/
20-
public class GHAppTest extends AbstractGitHubWireMockTest {
20+
public class GHAppTest extends AbstractGHAppInstallationTest {
2121

2222
protected GitHubBuilder getGitHubBuilder() {
2323
return super.getGitHubBuilder()
2424
// ensure that only JWT will be used against the tests below
2525
.withPassword(null, null)
26-
.withJwtToken("bogus");
26+
// Note that we used to provide a bogus token here and to rely on (apparently) manually crafted/edited
27+
// Wiremock recordings, so most of the tests cannot actually be executed against GitHub without
28+
// relying on the Wiremock recordings.
29+
// Some tests have been updated, though (getGitHubApp in particular).
30+
.withAuthorizationProvider(jwtProvider1);
2731
}
2832

2933
@Test
3034
public void getGitHubApp() throws IOException {
3135
GHApp app = gitHub.getApp();
32-
assertThat(app.getId(), is((long) 11111));
33-
assertThat(app.getOwner().getId(), is((long) 111111111));
34-
assertThat(app.getOwner().login, is("bogus"));
35-
assertThat(app.getName(), is("Bogus-Development"));
36+
assertThat(app.getId(), is((long) 82994));
37+
assertThat(app.getOwner().getId(), is((long) 7544739));
38+
assertThat(app.getOwner().getLogin(), is("hub4j-test-org"));
39+
assertThat(app.getName(), is("GHApi Test app 1"));
3640
assertThat(app.getDescription(), is(""));
37-
assertThat(app.getExternalUrl(), is("https://bogus.domain.com"));
38-
assertThat(app.getHtmlUrl().toString(), is("https://github.com/apps/bogus-development"));
39-
assertThat(app.getCreatedAt(), is(GitHubClient.parseDate("2019-06-10T04:21:41Z")));
40-
assertThat(app.getUpdatedAt(), is(GitHubClient.parseDate("2019-06-10T04:21:41Z")));
41-
assertThat(app.getPermissions().size(), is(4));
42-
assertThat(app.getEvents().size(), is(2));
41+
assertThat(app.getExternalUrl(), is("http://localhost"));
42+
assertThat(app.getHtmlUrl().toString(), is("https://github.com/apps/ghapi-test-app-1"));
43+
assertThat(app.getCreatedAt(), is(GitHubClient.parseDate("2020-09-30T13:40:56Z")));
44+
assertThat(app.getUpdatedAt(), is(GitHubClient.parseDate("2020-09-30T13:40:56Z")));
45+
assertThat(app.getPermissions().size(), is(2));
46+
assertThat(app.getEvents().size(), is(0));
4347
assertThat(app.getInstallationsCount(), is((long) 1));
4448

4549
// Deprecated methods
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
{
2+
"id": 82994,
3+
"slug": "ghapi-test-app-1",
4+
"node_id": "MDM6QXBwODI5OTQ=",
5+
"owner": {
6+
"login": "hub4j-test-org",
7+
"id": 7544739,
8+
"node_id": "MDEyOk9yZ2FuaXphdGlvbjc1NDQ3Mzk=",
9+
"avatar_url": "https://avatars.githubusercontent.com/u/7544739?v=4",
10+
"gravatar_id": "",
11+
"url": "https://api.github.com/users/hub4j-test-org",
12+
"html_url": "https://github.com/hub4j-test-org",
13+
"followers_url": "https://api.github.com/users/hub4j-test-org/followers",
14+
"following_url": "https://api.github.com/users/hub4j-test-org/following{/other_user}",
15+
"gists_url": "https://api.github.com/users/hub4j-test-org/gists{/gist_id}",
16+
"starred_url": "https://api.github.com/users/hub4j-test-org/starred{/owner}{/repo}",
17+
"subscriptions_url": "https://api.github.com/users/hub4j-test-org/subscriptions",
18+
"organizations_url": "https://api.github.com/users/hub4j-test-org/orgs",
19+
"repos_url": "https://api.github.com/users/hub4j-test-org/repos",
20+
"events_url": "https://api.github.com/users/hub4j-test-org/events{/privacy}",
21+
"received_events_url": "https://api.github.com/users/hub4j-test-org/received_events",
22+
"type": "Organization",
23+
"site_admin": false
24+
},
25+
"name": "GHApi Test app 1",
26+
"description": "",
27+
"external_url": "http://localhost",
28+
"html_url": "https://github.com/apps/ghapi-test-app-1",
29+
"created_at": "2020-09-30T13:40:56Z",
30+
"updated_at": "2020-09-30T13:40:56Z",
31+
"permissions": {
32+
"contents": "read",
33+
"metadata": "read"
34+
},
35+
"events": [],
36+
"installations_count": 1
37+
}

src/test/resources/org/kohsuke/github/GHAppTest/wiremock/getGitHubApp/__files/body-mapping-githubapp-app.json

Lines changed: 0 additions & 41 deletions
This file was deleted.

src/test/resources/org/kohsuke/github/GHAppTest/wiremock/getGitHubApp/mappings/mapping-githubapp-app.json renamed to src/test/resources/org/kohsuke/github/GHAppTest/wiremock/getGitHubApp/mappings/app-1.json

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
{
2+
"id": "5d93739e-0223-463e-9d26-1a9b3b4d1cc9",
3+
"name": "app",
24
"request": {
35
"url": "/app",
46
"method": "GET",
@@ -10,28 +12,28 @@
1012
},
1113
"response": {
1214
"status": 200,
13-
"bodyFileName": "body-mapping-githubapp-app.json",
15+
"bodyFileName": "app-1.json",
1416
"headers": {
1517
"Server": "GitHub.com",
16-
"Date": "Fri, 09 Aug 2019 05:36:38 GMT",
18+
"Date": "Thu, 22 Sep 2022 12:34:57 GMT",
1719
"Content-Type": "application/json; charset=utf-8",
18-
"Status": "200 OK",
1920
"Cache-Control": "public, max-age=60, s-maxage=60",
2021
"Vary": [
2122
"Accept",
22-
"Accept-Encoding"
23+
"Accept-Encoding, Accept, X-Requested-With"
2324
],
24-
"ETag": "W/\"01163b1a237898d328ed56cd0e9aefca\"",
25-
"X-GitHub-Media-Type": "github.machine-man-preview; format=json",
26-
"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",
27-
"Access-Control-Allow-Origin": "*",
28-
"Referrer-Policy": "origin-when-cross-origin, strict-origin-when-cross-origin",
29-
"Content-Security-Policy": "default-src 'none'",
25+
"ETag": "W/\"662c8ea184a852f605e0c94a9789fe43965f939e16e02ff0b3a8cc1043078a62\"",
26+
"X-GitHub-Media-Type": "github.v3; param=machine-man-preview; format=json",
3027
"Strict-Transport-Security": "max-age=31536000; includeSubdomains; preload",
31-
"X-Content-Type-Options": "nosniff",
3228
"X-Frame-Options": "deny",
33-
"X-XSS-Protection": "1; mode=block",
34-
"X-GitHub-Request-Id": "E0C4:3088:300C54:3ACB77:5D4D0666"
29+
"X-Content-Type-Options": "nosniff",
30+
"X-XSS-Protection": "0",
31+
"Referrer-Policy": "origin-when-cross-origin, strict-origin-when-cross-origin",
32+
"Content-Security-Policy": "default-src 'none'",
33+
"X-GitHub-Request-Id": "E69F:6970:A871C34:AACF01E:632C5670"
3534
}
36-
}
35+
},
36+
"uuid": "5d93739e-0223-463e-9d26-1a9b3b4d1cc9",
37+
"persistent": true,
38+
"insertionIndex": 1
3739
}

0 commit comments

Comments
 (0)