Skip to content

Commit bb008f5

Browse files
committed
implemented manifest flow test
1 parent 6b98021 commit bb008f5

File tree

5 files changed

+219
-0
lines changed

5 files changed

+219
-0
lines changed

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

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,25 @@ public void getAppBySlugTest() throws IOException {
3434
assertThat(app.getDescription(), equalTo("An app to test the GitHub getApp(slug) method."));
3535
}
3636

37+
/**
38+
* Tests the create from App Manifest Flow.
39+
*
40+
* The used code defined below was only valid for a short time, meaning that you can not replay the test against the
41+
* GitHub API. Use the stored wire snapshot for executing those tests.
42+
*
43+
* @throws IOException
44+
*/
45+
@Test
46+
public void createAppByManifestFlowTest() throws IOException {
47+
snapshotNotAllowed();
48+
GHAppFromManifest appFromManifest = gitHub.createAppFromManifest("46fbe5453b245dee21b96753f80eace209a3cf01");
3749

50+
assertThat(appFromManifest.getClientId(), equalTo("Iv1.1c63d0b87c03d42e"));
51+
assertThat(appFromManifest.getWebhookSecret(), equalTo("f4dafa9b05d8248d81f65f0e6cb108cb8bb76a0c"));
52+
assertThat(appFromManifest.getClientSecret(), equalTo("f4b60603e85b3965492b393bca0809a914dcdf18"));
53+
assertThat(appFromManifest.getPem(),
54+
equalTo("-----BEGIN RSA PRIVATE KEY-----\nMIIEpAIBAAKCAQEA4UT2qvDbMK3hQtvrK7wu7y7B6hypYhsXyD6GN22Bcn3JZdSI\nWm/zhRMH/vKwU5r67YKcJCchHVbvLRWNt911r85D0uLMPIjOkdL+cnSOa5yRhTJy\nI/RhZqx8yoXHSSE5ToKwfPAn3hiv8N2gQEsEpWxdycqPOg7paFsAJ5hjstmS09uU\nKwrFcCQdWuidRnwn6bdgGt+bL9dsvRd4RDoP5sZj5pLNo1y8N9DnFvHihd1rQxQS\nIf9sRgGPDLasNkLvMdxKnsDTsufRBmmw72iaTJXc+EVZw2jYKrOjRVechTMEfbRp\nQRVZw9vysT2XhDB9J4bbJ6NopP/c7JC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7Oqg7kyIKPkrCdjNlR/Ygtm\nvGXEozECgYAFpzntJpUdYN4OxutpNXdnTgN0CJ3TECkk/+0xbTHoWNuMpJ5dR/yQ\n7RLxwcu8CqizXCB750jSgHlWk5GF1yAQzFO9ozjx/mxdPp1PxHaeN/5kmx8VjT8W\nL7zhUMfZLeDMpIbQ/3gyq0EUxxHIEJc2Mx42C9/OY/fkEuZPFSEL2A==\n-----END RSA PRIVATE KEY-----\n"));
55+
56+
}
3857

3958
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
{
2+
"id": 330788,
3+
"slug": "ghapi-test-app-5",
4+
"node_id": "A_kwHOAHMfo84ABQwk",
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 5",
26+
"description": null,
27+
"external_url": "https://www.example.com",
28+
"html_url": "https://github.com/apps/ghapi-test-app-5",
29+
"created_at": "2023-05-08T09:22:36Z",
30+
"updated_at": "2023-05-08T09:22:36Z",
31+
"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pCLZVelw1JYs7hq+roTdKds0\ny9pu+E6I7+g6LsVtjkMqf/VXuY0qomf9hbNE9Yj/Tqty5B4xU+gj01MCm5RRln9M\nKGKCeJAPDB5AEmyidPvLbPp5U6Rniu0Ds+AJ0FnRAoGBAMro/bGTuwNhXs4aP+D1\nVhAkWE4JEqq0zQZoJIba8bW683YZ2WMaVMI9y1djx9OeZOVERYYtGzUZwnxOmMBH\nluSPJDbcuXIxn0X/xAd6fdSCfEUbMfUBX5jSevYImfTn1VaVQOX9iQnEHjx+hi7l\n+i5ICFoEotXkO8CKpr+8vbq5AoGAOCfkZAfjb6XHB/XhhOKSk7UxMWuVJ8EPlSC5\nCPe7AMZX37bN08QtVKZZphQZXE38yo3W6QHDoc4iUipgki2HshKIaGI2sdjm+8yC\nb73Ew8wYNwmn8QXGMF0W6mWUb3UDxaIhnBfCwDFVn7Oqg7kyIKPkrCdjNlR/Ygtm\nvGXEozECgYAFpzntJpUdYN4OxutpNXdnTgN0CJ3TECkk/+0xbTHoWNuMpJ5dR/yQ\n7RLxwcu8CqizXCB750jSgHlWk5GF1yAQzFO9ozjx/mxdPp1PxHaeN/5kmx8VjT8W\nL7zhUMfZLeDMpIbQ/3gyq0EUxxHIEJc2Mx42C9/OY/fkEuZPFSEL2A==\n-----END RSA PRIVATE KEY-----\n",
34+
"client_secret": "f4b60603e85b3965492b393bca0809a914dcdf18",
35+
"permissions": {
36+
"issues": "write",
37+
"checks": "write",
38+
"metadata": "read"
39+
},
40+
"events": [
41+
"issues",
42+
"issue_comment",
43+
"check_suite",
44+
"check_run"
45+
]
46+
}
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
{
2+
"login": "dbaur",
3+
"id": 7251904,
4+
"node_id": "MDQ6VXNlcjcyNTE5MDQ=",
5+
"avatar_url": "https://avatars.githubusercontent.com/u/7251904?v=4",
6+
"gravatar_id": "",
7+
"url": "https://api.github.com/users/dbaur",
8+
"html_url": "https://github.com/dbaur",
9+
"followers_url": "https://api.github.com/users/dbaur/followers",
10+
"following_url": "https://api.github.com/users/dbaur/following{/other_user}",
11+
"gists_url": "https://api.github.com/users/dbaur/gists{/gist_id}",
12+
"starred_url": "https://api.github.com/users/dbaur/starred{/owner}{/repo}",
13+
"subscriptions_url": "https://api.github.com/users/dbaur/subscriptions",
14+
"organizations_url": "https://api.github.com/users/dbaur/orgs",
15+
"repos_url": "https://api.github.com/users/dbaur/repos",
16+
"events_url": "https://api.github.com/users/dbaur/events{/privacy}",
17+
"received_events_url": "https://api.github.com/users/dbaur/received_events",
18+
"type": "User",
19+
"site_admin": false,
20+
"name": "Daniel Baur",
21+
"company": null,
22+
"blog": "",
23+
"location": "Ulm",
24+
"email": null,
25+
"hireable": null,
26+
"bio": null,
27+
"twitter_username": null,
28+
"public_repos": 48,
29+
"public_gists": 0,
30+
"followers": 7,
31+
"following": 10,
32+
"created_at": "2014-04-10T14:14:43Z",
33+
"updated_at": "2023-04-28T11:26:17Z",
34+
"private_gists": 3,
35+
"total_private_repos": 13,
36+
"owned_private_repos": 13,
37+
"disk_usage": 104958,
38+
"collaborators": 0,
39+
"two_factor_authentication": true,
40+
"plan": {
41+
"name": "free",
42+
"space": 976562499,
43+
"collaborators": 0,
44+
"private_repos": 10000
45+
}
46+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
{
2+
"id": "14af1029-56b1-4d4b-9579-c2a30a4df4c4",
3+
"name": "app-manifests_46fbe5453b245dee21b96753f80eace209a3cf01_conversions",
4+
"request": {
5+
"url": "/app-manifests/46fbe5453b245dee21b96753f80eace209a3cf01/conversions",
6+
"method": "POST",
7+
"headers": {
8+
"Accept": {
9+
"equalTo": "application/vnd.github.v3+json"
10+
}
11+
},
12+
"bodyPatterns": [
13+
{
14+
"equalToJson": "{}",
15+
"ignoreArrayOrder": true,
16+
"ignoreExtraElements": false
17+
}
18+
]
19+
},
20+
"response": {
21+
"status": 201,
22+
"bodyFileName": "app-manifests_46fbe5453b245dee21b96753f80eace209a3cf01_conversions-2.json",
23+
"headers": {
24+
"Server": "GitHub.com",
25+
"Date": "Mon, 08 May 2023 09:22:37 GMT",
26+
"Content-Type": "application/json; charset=utf-8",
27+
"Cache-Control": "private, max-age=60, s-maxage=60",
28+
"Vary": [
29+
"Accept, Authorization, Cookie, X-GitHub-OTP",
30+
"Accept-Encoding, Accept, X-Requested-With"
31+
],
32+
"ETag": "\"11658fb48526e56c552184ab239fde425aef041a1d48fce2333682009b178a2c\"",
33+
"X-OAuth-Scopes": "admin:gpg_key, admin:org, admin:org_hook, admin:public_key, admin:repo_hook, admin:ssh_signing_key, audit_log, codespace, delete:packages, delete_repo, gist, notifications, project, repo, user, workflow, write:discussion, write:packages",
34+
"X-Accepted-OAuth-Scopes": "",
35+
"github-authentication-token-expiration": "2023-06-07 08:27:57 UTC",
36+
"X-GitHub-Media-Type": "github.v3; format=json",
37+
"x-github-api-version-selected": "2022-11-28",
38+
"X-RateLimit-Limit": "5000",
39+
"X-RateLimit-Remaining": "4999",
40+
"X-RateLimit-Reset": "1683541357",
41+
"X-RateLimit-Used": "1",
42+
"X-RateLimit-Resource": "integration_manifest",
43+
"Access-Control-Expose-Headers": "ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Used, X-RateLimit-Resource, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type, X-GitHub-SSO, X-GitHub-Request-Id, Deprecation, Sunset",
44+
"Access-Control-Allow-Origin": "*",
45+
"Strict-Transport-Security": "max-age=31536000; includeSubdomains; preload",
46+
"X-Frame-Options": "deny",
47+
"X-Content-Type-Options": "nosniff",
48+
"X-XSS-Protection": "0",
49+
"Referrer-Policy": "origin-when-cross-origin, strict-origin-when-cross-origin",
50+
"Content-Security-Policy": "default-src 'none'",
51+
"X-GitHub-Request-Id": "CC01:67BE:362DA52:36DD95C:6458BF5C"
52+
}
53+
},
54+
"uuid": "14af1029-56b1-4d4b-9579-c2a30a4df4c4",
55+
"persistent": true,
56+
"insertionIndex": 2
57+
}
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
{
2+
"id": "e173459b-205e-447b-9c70-70bddd564b12",
3+
"name": "user",
4+
"request": {
5+
"url": "/user",
6+
"method": "GET",
7+
"headers": {
8+
"Accept": {
9+
"equalTo": "application/vnd.github.v3+json"
10+
}
11+
}
12+
},
13+
"response": {
14+
"status": 200,
15+
"bodyFileName": "user-1.json",
16+
"headers": {
17+
"Server": "GitHub.com",
18+
"Date": "Mon, 08 May 2023 09:22:35 GMT",
19+
"Content-Type": "application/json; charset=utf-8",
20+
"Cache-Control": "private, max-age=60, s-maxage=60",
21+
"Vary": [
22+
"Accept, Authorization, Cookie, X-GitHub-OTP",
23+
"Accept-Encoding, Accept, X-Requested-With"
24+
],
25+
"ETag": "W/\"ed2b1866194223c334b01088179c15c223bc73dc80a5611a2dd5df357b0f0b30\"",
26+
"Last-Modified": "Fri, 28 Apr 2023 11:26:17 GMT",
27+
"X-OAuth-Scopes": "admin:gpg_key, admin:org, admin:org_hook, admin:public_key, admin:repo_hook, admin:ssh_signing_key, audit_log, codespace, delete:packages, delete_repo, gist, notifications, project, repo, user, workflow, write:discussion, write:packages",
28+
"X-Accepted-OAuth-Scopes": "",
29+
"github-authentication-token-expiration": "2023-06-07 08:27:57 UTC",
30+
"X-GitHub-Media-Type": "github.v3; format=json",
31+
"x-github-api-version-selected": "2022-11-28",
32+
"X-RateLimit-Limit": "5000",
33+
"X-RateLimit-Remaining": "4960",
34+
"X-RateLimit-Reset": "1683538171",
35+
"X-RateLimit-Used": "40",
36+
"X-RateLimit-Resource": "core",
37+
"Access-Control-Expose-Headers": "ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Used, X-RateLimit-Resource, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type, X-GitHub-SSO, X-GitHub-Request-Id, Deprecation, Sunset",
38+
"Access-Control-Allow-Origin": "*",
39+
"Strict-Transport-Security": "max-age=31536000; includeSubdomains; preload",
40+
"X-Frame-Options": "deny",
41+
"X-Content-Type-Options": "nosniff",
42+
"X-XSS-Protection": "0",
43+
"Referrer-Policy": "origin-when-cross-origin, strict-origin-when-cross-origin",
44+
"Content-Security-Policy": "default-src 'none'",
45+
"X-GitHub-Request-Id": "D3E6:CDC9:7C734B0:7DDAE36:6458BF5B"
46+
}
47+
},
48+
"uuid": "e173459b-205e-447b-9c70-70bddd564b12",
49+
"persistent": true,
50+
"insertionIndex": 1
51+
}

0 commit comments

Comments
 (0)