diff --git a/src/main/java/org/kohsuke/github/GHRepository.java b/src/main/java/org/kohsuke/github/GHRepository.java index 5220a1b80b..e09be03ab1 100644 --- a/src/main/java/org/kohsuke/github/GHRepository.java +++ b/src/main/java/org/kohsuke/github/GHRepository.java @@ -2850,14 +2850,31 @@ public GHMilestone createMilestone(String title, String description) throws IOEx * the io exception */ public GHDeployKey addDeployKey(String title, String key) throws IOException { + return addDeployKey(title, key, false); + } + + /** + * Add deploy key gh deploy key. + * + * @param title + * the title + * @param key + * the key + * @param readOnly + * read-only ability of the key + * @return the gh deploy key + * @throws IOException + * the io exception + */ + public GHDeployKey addDeployKey(String title, String key, boolean readOnly) throws IOException { return root().createRequest() .method("POST") .with("title", title) .with("key", key) + .with("read_only", readOnly) .withUrlPath(getApiTailUrl("keys")) .fetch(GHDeployKey.class) .lateBind(this); - } /** diff --git a/src/test/java/org/kohsuke/github/AppTest.java b/src/test/java/org/kohsuke/github/AppTest.java index f8d7a39892..aef04e8cfd 100755 --- a/src/test/java/org/kohsuke/github/AppTest.java +++ b/src/test/java/org/kohsuke/github/AppTest.java @@ -1283,18 +1283,43 @@ public void directoryListing() throws IOException { * @throws IOException * Signals that an I/O exception has occurred. */ - @Ignore("Needs mocking check") @Test public void testAddDeployKey() throws IOException { GHRepository myRepository = getTestRepository(); final GHDeployKey newDeployKey = myRepository.addDeployKey("test", - "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDUt0RAycC5cS42JKh6SecfFZBR1RrF+2hYMctz4mk74/arBE+wFb7fnSHGzdGKX2h5CFOWODifRCJVhB7hlVxodxe+QkQQYAEL/x1WVCJnGgTGQGOrhOMj95V3UE5pQKhsKD608C+u5tSofcWXLToP1/wZ7U4/AHjqYi08OLsWToHCax55TZkvdt2jo0hbIoYU+XI9Q8Uv4ONDN1oabiOdgeKi8+crvHAuvNleiBhWVBzFh8KdfzaH5uNdw7ihhFjEd1vzqACsjCINCjdMfzl6jD9ExuWuE92nZJnucls2cEoNC6k2aPmrZDg9hA32FXVpyseY+bDUWFU6LO2LG6PB kohsuke@atlas"); + "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIATWwMLytklB44O66isWRKOB3Qd7Ysc7q7EyWTmT0bG9 test@example.com"); + try { + assertThat(newDeployKey.getId(), notNullValue()); + + GHDeployKey k = Iterables.find(myRepository.getDeployKeys(), new Predicate() { + public boolean apply(GHDeployKey deployKey) { + return newDeployKey.getId() == deployKey.getId() && !deployKey.isRead_only(); + } + }); + assertThat(k, notNullValue()); + } finally { + newDeployKey.delete(); + } + } + + /** + * Test add deploy key read-only. + * + * @throws IOException + * Signals that an I/O exception has occurred. + */ + @Test + public void testAddDeployKeyAsReadOnly() throws IOException { + GHRepository myRepository = getTestRepository(); + final GHDeployKey newDeployKey = myRepository.addDeployKey("test", + "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIATWwMLytklB44O66isWRKOB3Qd7Ysc7q7EyWTmT0bG9 test@example.com", + true); try { assertThat(newDeployKey.getId(), notNullValue()); GHDeployKey k = Iterables.find(myRepository.getDeployKeys(), new Predicate() { public boolean apply(GHDeployKey deployKey) { - return newDeployKey.getId() == deployKey.getId(); + return newDeployKey.getId() == deployKey.getId() && deployKey.isRead_only(); } }); assertThat(k, notNullValue()); diff --git a/src/test/resources/org/kohsuke/github/AppTest/wiremock/testAddDeployKey/__files/repos_hub4j-test-org_github-api-test-2.json b/src/test/resources/org/kohsuke/github/AppTest/wiremock/testAddDeployKey/__files/repos_hub4j-test-org_github-api-test-2.json new file mode 100644 index 0000000000..2d5a6b55ff --- /dev/null +++ b/src/test/resources/org/kohsuke/github/AppTest/wiremock/testAddDeployKey/__files/repos_hub4j-test-org_github-api-test-2.json @@ -0,0 +1,117 @@ +{ + "id": 611473997, + "node_id": "R_kgDOJHJaTQ", + "name": "github-api-test", + "full_name": "hub4j-test-org/github-api-test", + "private": false, + "owner": { + "login": "hub4j-test-org", + "id": 238558, + "node_id": "MDQ6VXNlcjIzODU1OA==", + "avatar_url": "https://avatars.githubusercontent.com/u/238558?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/hub4j-test-org", + "html_url": "https://github.com/hub4j-test-org", + "followers_url": "https://api.github.com/users/hub4j-test-org/followers", + "following_url": "https://api.github.com/users/hub4j-test-org/following{/other_user}", + "gists_url": "https://api.github.com/users/hub4j-test-org/gists{/gist_id}", + "starred_url": "https://api.github.com/users/hub4j-test-org/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/hub4j-test-org/subscriptions", + "organizations_url": "https://api.github.com/users/hub4j-test-org/orgs", + "repos_url": "https://api.github.com/users/hub4j-test-org/repos", + "events_url": "https://api.github.com/users/hub4j-test-org/events{/privacy}", + "received_events_url": "https://api.github.com/users/hub4j-test-org/received_events", + "type": "User", + "site_admin": false + }, + "html_url": "https://github.com/hub4j-test-org/github-api-test", + "description": "A test repository for testing the github-api project: github-api-test", + "fork": false, + "url": "https://api.github.com/repos/hub4j-test-org/github-api-test", + "forks_url": "https://api.github.com/repos/hub4j-test-org/github-api-test/forks", + "keys_url": "https://api.github.com/repos/hub4j-test-org/github-api-test/keys{/key_id}", + "collaborators_url": "https://api.github.com/repos/hub4j-test-org/github-api-test/collaborators{/collaborator}", + "teams_url": "https://api.github.com/repos/hub4j-test-org/github-api-test/teams", + "hooks_url": "https://api.github.com/repos/hub4j-test-org/github-api-test/hooks", + "issue_events_url": "https://api.github.com/repos/hub4j-test-org/github-api-test/issues/events{/number}", + "events_url": "https://api.github.com/repos/hub4j-test-org/github-api-test/events", + "assignees_url": "https://api.github.com/repos/hub4j-test-org/github-api-test/assignees{/user}", + "branches_url": "https://api.github.com/repos/hub4j-test-org/github-api-test/branches{/branch}", + "tags_url": "https://api.github.com/repos/hub4j-test-org/github-api-test/tags", + "blobs_url": "https://api.github.com/repos/hub4j-test-org/github-api-test/git/blobs{/sha}", + "git_tags_url": "https://api.github.com/repos/hub4j-test-org/github-api-test/git/tags{/sha}", + "git_refs_url": "https://api.github.com/repos/hub4j-test-org/github-api-test/git/refs{/sha}", + "trees_url": "https://api.github.com/repos/hub4j-test-org/github-api-test/git/trees{/sha}", + "statuses_url": "https://api.github.com/repos/hub4j-test-org/github-api-test/statuses/{sha}", + "languages_url": "https://api.github.com/repos/hub4j-test-org/github-api-test/languages", + "stargazers_url": "https://api.github.com/repos/hub4j-test-org/github-api-test/stargazers", + "contributors_url": "https://api.github.com/repos/hub4j-test-org/github-api-test/contributors", + "subscribers_url": "https://api.github.com/repos/hub4j-test-org/github-api-test/subscribers", + "subscription_url": "https://api.github.com/repos/hub4j-test-org/github-api-test/subscription", + "commits_url": "https://api.github.com/repos/hub4j-test-org/github-api-test/commits{/sha}", + "git_commits_url": "https://api.github.com/repos/hub4j-test-org/github-api-test/git/commits{/sha}", + "comments_url": "https://api.github.com/repos/hub4j-test-org/github-api-test/comments{/number}", + "issue_comment_url": "https://api.github.com/repos/hub4j-test-org/github-api-test/issues/comments{/number}", + "contents_url": "https://api.github.com/repos/hub4j-test-org/github-api-test/contents/{+path}", + "compare_url": "https://api.github.com/repos/hub4j-test-org/github-api-test/compare/{base}...{head}", + "merges_url": "https://api.github.com/repos/hub4j-test-org/github-api-test/merges", + "archive_url": "https://api.github.com/repos/hub4j-test-org/github-api-test/{archive_format}{/ref}", + "downloads_url": "https://api.github.com/repos/hub4j-test-org/github-api-test/downloads", + "issues_url": "https://api.github.com/repos/hub4j-test-org/github-api-test/issues{/number}", + "pulls_url": "https://api.github.com/repos/hub4j-test-org/github-api-test/pulls{/number}", + "milestones_url": "https://api.github.com/repos/hub4j-test-org/github-api-test/milestones{/number}", + "notifications_url": "https://api.github.com/repos/hub4j-test-org/github-api-test/notifications{?since,all,participating}", + "labels_url": "https://api.github.com/repos/hub4j-test-org/github-api-test/labels{/name}", + "releases_url": "https://api.github.com/repos/hub4j-test-org/github-api-test/releases{/id}", + "deployments_url": "https://api.github.com/repos/hub4j-test-org/github-api-test/deployments", + "created_at": "2023-03-08T22:36:45Z", + "updated_at": "2023-03-08T22:36:45Z", + "pushed_at": "2023-03-08T22:36:45Z", + "git_url": "git://github.com/hub4j-test-org/github-api-test.git", + "ssh_url": "git@github.com:hub4j-test-org/github-api-test.git", + "clone_url": "https://github.com/hub4j-test-org/github-api-test.git", + "svn_url": "https://github.com/hub4j-test-org/github-api-test", + "homepage": "http://github-api.kohsuke.org/", + "size": 0, + "stargazers_count": 0, + "watchers_count": 0, + "language": null, + "has_issues": true, + "has_projects": true, + "has_downloads": true, + "has_wiki": true, + "has_pages": false, + "has_discussions": false, + "forks_count": 0, + "mirror_url": null, + "archived": false, + "disabled": false, + "open_issues_count": 0, + "license": null, + "allow_forking": true, + "is_template": false, + "web_commit_signoff_required": false, + "topics": [], + "visibility": "public", + "forks": 0, + "open_issues": 0, + "watchers": 0, + "default_branch": "main", + "permissions": { + "admin": true, + "maintain": true, + "push": true, + "triage": true, + "pull": true + }, + "security_and_analysis": { + "secret_scanning": { + "status": "disabled" + }, + "secret_scanning_push_protection": { + "status": "disabled" + } + }, + "network_count": 0, + "subscribers_count": 1 +} \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/AppTest/wiremock/testAddDeployKey/__files/repos_hub4j-test-org_github-api-test_keys-3.json b/src/test/resources/org/kohsuke/github/AppTest/wiremock/testAddDeployKey/__files/repos_hub4j-test-org_github-api-test_keys-3.json new file mode 100644 index 0000000000..8433b32127 --- /dev/null +++ b/src/test/resources/org/kohsuke/github/AppTest/wiremock/testAddDeployKey/__files/repos_hub4j-test-org_github-api-test_keys-3.json @@ -0,0 +1,11 @@ +{ + "id": 78869617, + "key": "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIATWwMLytklB44O66isWRKOB3Qd7Ysc7q7EyWTmT0bG9", + "url": "https://api.github.com/repos/hub4j-test-org/github-api-test/keys/78869617", + "title": "test", + "verified": true, + "created_at": "2023-03-08T22:36:50Z", + "read_only": false, + "last_used": null, + "added_by": "hub4j-test-org" +} \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/AppTest/wiremock/testAddDeployKey/__files/repos_hub4j-test-org_github-api-test_keys-4.json b/src/test/resources/org/kohsuke/github/AppTest/wiremock/testAddDeployKey/__files/repos_hub4j-test-org_github-api-test_keys-4.json new file mode 100644 index 0000000000..92a6bea577 --- /dev/null +++ b/src/test/resources/org/kohsuke/github/AppTest/wiremock/testAddDeployKey/__files/repos_hub4j-test-org_github-api-test_keys-4.json @@ -0,0 +1,13 @@ +[ + { + "id": 78869617, + "key": "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIATWwMLytklB44O66isWRKOB3Qd7Ysc7q7EyWTmT0bG9", + "url": "https://api.github.com/repos/hub4j-test-org/github-api-test/keys/78869617", + "title": "test", + "verified": true, + "created_at": "2023-03-08T22:36:50Z", + "read_only": false, + "last_used": null, + "added_by": "hub4j-test-org" + } +] \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/AppTest/wiremock/testAddDeployKey/__files/user-1.json b/src/test/resources/org/kohsuke/github/AppTest/wiremock/testAddDeployKey/__files/user-1.json new file mode 100644 index 0000000000..92e9ace93c --- /dev/null +++ b/src/test/resources/org/kohsuke/github/AppTest/wiremock/testAddDeployKey/__files/user-1.json @@ -0,0 +1,34 @@ +{ + "login": "hub4j-test-org", + "id": 7544739, + "node_id": "MDQ6VXNlcjIzODU1OA==", + "avatar_url": "https://avatars.githubusercontent.com/u/7544739?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/hub4j-test-org", + "html_url": "https://github.com/hub4j-test-org", + "followers_url": "https://api.github.com/users/hub4j-test-org/followers", + "following_url": "https://api.github.com/users/hub4j-test-org/following{/other_user}", + "gists_url": "https://api.github.com/users/hub4j-test-org/gists{/gist_id}", + "starred_url": "https://api.github.com/users/hub4j-test-org/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/hub4j-test-org/subscriptions", + "organizations_url": "https://api.github.com/users/hub4j-test-org/orgs", + "repos_url": "https://api.github.com/users/hub4j-test-org/repos", + "events_url": "https://api.github.com/users/hub4j-test-org/events{/privacy}", + "received_events_url": "https://api.github.com/users/hub4j-test-org/received_events", + "type": "User", + "site_admin": false, + "name": "hub4j-test-org", + "company": null, + "blog": "", + "location": "", + "email": null, + "hireable": null, + "bio": "", + "twitter_username": null, + "public_repos": 13, + "public_gists": 4, + "followers": 6, + "following": 1, + "created_at": "2010-04-07T08:30:12Z", + "updated_at": "2022-11-28T20:54:46Z" +} \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/AppTest/wiremock/testAddDeployKey/mappings/repos_hub4j-test-org_github-api-test-2.json b/src/test/resources/org/kohsuke/github/AppTest/wiremock/testAddDeployKey/mappings/repos_hub4j-test-org_github-api-test-2.json new file mode 100644 index 0000000000..8764b8abec --- /dev/null +++ b/src/test/resources/org/kohsuke/github/AppTest/wiremock/testAddDeployKey/mappings/repos_hub4j-test-org_github-api-test-2.json @@ -0,0 +1,49 @@ +{ + "id": "8b7ef826-893b-4288-b625-4492949cd9b1", + "name": "repos_hub4j-test-org_github-api-test", + "request": { + "url": "/repos/hub4j-test-org/github-api-test", + "method": "GET", + "headers": { + "Accept": { + "equalTo": "application/vnd.github.v3+json" + } + } + }, + "response": { + "status": 200, + "bodyFileName": "repos_hub4j-test-org_github-api-test-2.json", + "headers": { + "Server": "GitHub.com", + "Date": "Wed, 08 Mar 2023 22:36:49 GMT", + "Content-Type": "application/json; charset=utf-8", + "Cache-Control": "private, max-age=60, s-maxage=60", + "Vary": [ + "Accept, Authorization, Cookie, X-GitHub-OTP", + "Accept-Encoding, Accept, X-Requested-With" + ], + "ETag": "W/\"9a25876ca00d328a54c1400dffe501009cdcbc3410dd90140b0c33cc19608961\"", + "Last-Modified": "Wed, 08 Mar 2023 22:36:45 GMT", + "github-authentication-token-expiration": "2023-04-07 23:24:34 +0200", + "X-GitHub-Media-Type": "github.v3; format=json", + "x-github-api-version-selected": "2022-11-28", + "X-RateLimit-Limit": "5000", + "X-RateLimit-Remaining": "4903", + "X-RateLimit-Reset": "1678317208", + "X-RateLimit-Used": "97", + "X-RateLimit-Resource": "core", + "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", + "Access-Control-Allow-Origin": "*", + "Strict-Transport-Security": "max-age=31536000; includeSubdomains; preload", + "X-Frame-Options": "deny", + "X-Content-Type-Options": "nosniff", + "X-XSS-Protection": "0", + "Referrer-Policy": "origin-when-cross-origin, strict-origin-when-cross-origin", + "Content-Security-Policy": "default-src 'none'", + "X-GitHub-Request-Id": "E5D8:ACE5:B4A8F2D:B741C36:64090E01" + } + }, + "uuid": "8b7ef826-893b-4288-b625-4492949cd9b1", + "persistent": true, + "insertionIndex": 2 +} \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/AppTest/wiremock/testAddDeployKey/mappings/repos_hub4j-test-org_github-api-test_keys-3.json b/src/test/resources/org/kohsuke/github/AppTest/wiremock/testAddDeployKey/mappings/repos_hub4j-test-org_github-api-test_keys-3.json new file mode 100644 index 0000000000..b73aab599f --- /dev/null +++ b/src/test/resources/org/kohsuke/github/AppTest/wiremock/testAddDeployKey/mappings/repos_hub4j-test-org_github-api-test_keys-3.json @@ -0,0 +1,56 @@ +{ + "id": "f648e6ad-c2ec-42b2-bc75-017ac64e67d9", + "name": "repos_hub4j-test-org_github-api-test_keys", + "request": { + "url": "/repos/hub4j-test-org/github-api-test/keys", + "method": "POST", + "headers": { + "Accept": { + "equalTo": "application/vnd.github.v3+json" + } + }, + "bodyPatterns": [ + { + "equalToJson": "{\"read_only\":false,\"title\":\"test\",\"key\":\"ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIATWwMLytklB44O66isWRKOB3Qd7Ysc7q7EyWTmT0bG9 test@example.com\"}", + "ignoreArrayOrder": true, + "ignoreExtraElements": false + } + ] + }, + "response": { + "status": 201, + "bodyFileName": "repos_hub4j-test-org_github-api-test_keys-3.json", + "headers": { + "Server": "GitHub.com", + "Date": "Wed, 08 Mar 2023 22:36:50 GMT", + "Content-Type": "application/json; charset=utf-8", + "Cache-Control": "private, max-age=60, s-maxage=60", + "Vary": [ + "Accept, Authorization, Cookie, X-GitHub-OTP", + "Accept-Encoding, Accept, X-Requested-With" + ], + "ETag": "\"0a4e82c98d34824d431a19b779f7fcc35e1a3c1142ff9c1a7132d8840630f8a6\"", + "github-authentication-token-expiration": "2023-04-07 23:24:34 +0200", + "X-GitHub-Media-Type": "github.v3; format=json", + "x-github-api-version-selected": "2022-11-28", + "X-RateLimit-Limit": "5000", + "X-RateLimit-Remaining": "4902", + "X-RateLimit-Reset": "1678317208", + "X-RateLimit-Used": "98", + "X-RateLimit-Resource": "core", + "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", + "Access-Control-Allow-Origin": "*", + "Strict-Transport-Security": "max-age=31536000; includeSubdomains; preload", + "X-Frame-Options": "deny", + "X-Content-Type-Options": "nosniff", + "X-XSS-Protection": "0", + "Referrer-Policy": "origin-when-cross-origin, strict-origin-when-cross-origin", + "Content-Security-Policy": "default-src 'none'", + "X-GitHub-Request-Id": "E5DE:A9BF:A40D94B:A69E360:64090E01", + "Location": "https://api.github.com/repos/hub4j-test-org/github-api-test/keys/78869617" + } + }, + "uuid": "f648e6ad-c2ec-42b2-bc75-017ac64e67d9", + "persistent": true, + "insertionIndex": 3 +} \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/AppTest/wiremock/testAddDeployKey/mappings/repos_hub4j-test-org_github-api-test_keys-4.json b/src/test/resources/org/kohsuke/github/AppTest/wiremock/testAddDeployKey/mappings/repos_hub4j-test-org_github-api-test_keys-4.json new file mode 100644 index 0000000000..c1372692d8 --- /dev/null +++ b/src/test/resources/org/kohsuke/github/AppTest/wiremock/testAddDeployKey/mappings/repos_hub4j-test-org_github-api-test_keys-4.json @@ -0,0 +1,48 @@ +{ + "id": "ca5ce05e-5052-4cce-9508-c33ba42ab18f", + "name": "repos_hub4j-test-org_github-api-test_keys", + "request": { + "url": "/repos/hub4j-test-org/github-api-test/keys", + "method": "GET", + "headers": { + "Accept": { + "equalTo": "application/vnd.github.v3+json" + } + } + }, + "response": { + "status": 200, + "bodyFileName": "repos_hub4j-test-org_github-api-test_keys-4.json", + "headers": { + "Server": "GitHub.com", + "Date": "Wed, 08 Mar 2023 22:36:50 GMT", + "Content-Type": "application/json; charset=utf-8", + "Cache-Control": "private, max-age=60, s-maxage=60", + "Vary": [ + "Accept, Authorization, Cookie, X-GitHub-OTP", + "Accept-Encoding, Accept, X-Requested-With" + ], + "ETag": "W/\"0a77e8787fcd166b10430624945723c4d8bdc5f131bcc1c821d56170eec9db86\"", + "github-authentication-token-expiration": "2023-04-07 23:24:34 +0200", + "X-GitHub-Media-Type": "github.v3; format=json", + "x-github-api-version-selected": "2022-11-28", + "X-RateLimit-Limit": "5000", + "X-RateLimit-Remaining": "4901", + "X-RateLimit-Reset": "1678317208", + "X-RateLimit-Used": "99", + "X-RateLimit-Resource": "core", + "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", + "Access-Control-Allow-Origin": "*", + "Strict-Transport-Security": "max-age=31536000; includeSubdomains; preload", + "X-Frame-Options": "deny", + "X-Content-Type-Options": "nosniff", + "X-XSS-Protection": "0", + "Referrer-Policy": "origin-when-cross-origin, strict-origin-when-cross-origin", + "Content-Security-Policy": "default-src 'none'", + "X-GitHub-Request-Id": "E5EA:3041:9E5EEE8:A0EE307:64090E02" + } + }, + "uuid": "ca5ce05e-5052-4cce-9508-c33ba42ab18f", + "persistent": true, + "insertionIndex": 4 +} \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/AppTest/wiremock/testAddDeployKey/mappings/repos_hub4j-test-org_github-api-test_keys_78869617-5.json b/src/test/resources/org/kohsuke/github/AppTest/wiremock/testAddDeployKey/mappings/repos_hub4j-test-org_github-api-test_keys_78869617-5.json new file mode 100644 index 0000000000..833744f03e --- /dev/null +++ b/src/test/resources/org/kohsuke/github/AppTest/wiremock/testAddDeployKey/mappings/repos_hub4j-test-org_github-api-test_keys_78869617-5.json @@ -0,0 +1,41 @@ +{ + "id": "0fc8164e-80f8-450b-a7b5-4f604f9eeaa9", + "name": "repos_hub4j-test-org_github-api-test_keys_78869617", + "request": { + "url": "/repos/hub4j-test-org/github-api-test/keys/78869617", + "method": "DELETE", + "headers": { + "Accept": { + "equalTo": "application/vnd.github.v3+json" + } + } + }, + "response": { + "status": 204, + "headers": { + "Server": "GitHub.com", + "Date": "Wed, 08 Mar 2023 22:36:51 GMT", + "github-authentication-token-expiration": "2023-04-07 23:24:34 +0200", + "X-GitHub-Media-Type": "github.v3; format=json", + "x-github-api-version-selected": "2022-11-28", + "X-RateLimit-Limit": "5000", + "X-RateLimit-Remaining": "4900", + "X-RateLimit-Reset": "1678317208", + "X-RateLimit-Used": "100", + "X-RateLimit-Resource": "core", + "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", + "Access-Control-Allow-Origin": "*", + "Strict-Transport-Security": "max-age=31536000; includeSubdomains; preload", + "X-Frame-Options": "deny", + "X-Content-Type-Options": "nosniff", + "X-XSS-Protection": "0", + "Referrer-Policy": "origin-when-cross-origin, strict-origin-when-cross-origin", + "Content-Security-Policy": "default-src 'none'", + "Vary": "Accept-Encoding, Accept, X-Requested-With", + "X-GitHub-Request-Id": "E5FA:A7AE:82F2BFE:8532045:64090E02" + } + }, + "uuid": "0fc8164e-80f8-450b-a7b5-4f604f9eeaa9", + "persistent": true, + "insertionIndex": 5 +} \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/AppTest/wiremock/testAddDeployKey/mappings/user-1.json b/src/test/resources/org/kohsuke/github/AppTest/wiremock/testAddDeployKey/mappings/user-1.json new file mode 100644 index 0000000000..d46c6d045e --- /dev/null +++ b/src/test/resources/org/kohsuke/github/AppTest/wiremock/testAddDeployKey/mappings/user-1.json @@ -0,0 +1,49 @@ +{ + "id": "9e6bf17e-5e07-4c66-ab42-eba00096c098", + "name": "user", + "request": { + "url": "/user", + "method": "GET", + "headers": { + "Accept": { + "equalTo": "application/vnd.github.v3+json" + } + } + }, + "response": { + "status": 200, + "bodyFileName": "user-1.json", + "headers": { + "Server": "GitHub.com", + "Date": "Wed, 08 Mar 2023 22:36:44 GMT", + "Content-Type": "application/json; charset=utf-8", + "Cache-Control": "private, max-age=60, s-maxage=60", + "Vary": [ + "Accept, Authorization, Cookie, X-GitHub-OTP", + "Accept-Encoding, Accept, X-Requested-With" + ], + "ETag": "W/\"e548710856e14da19e6d9c3a0b9e6751b4cec74b4ead51290d5179d92173e70e\"", + "Last-Modified": "Mon, 28 Nov 2022 20:54:46 GMT", + "github-authentication-token-expiration": "2023-04-07 23:24:34 +0200", + "X-GitHub-Media-Type": "github.v3; format=json", + "x-github-api-version-selected": "2022-11-28", + "X-RateLimit-Limit": "5000", + "X-RateLimit-Remaining": "4907", + "X-RateLimit-Reset": "1678317208", + "X-RateLimit-Used": "93", + "X-RateLimit-Resource": "core", + "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", + "Access-Control-Allow-Origin": "*", + "Strict-Transport-Security": "max-age=31536000; includeSubdomains; preload", + "X-Frame-Options": "deny", + "X-Content-Type-Options": "nosniff", + "X-XSS-Protection": "0", + "Referrer-Policy": "origin-when-cross-origin, strict-origin-when-cross-origin", + "Content-Security-Policy": "default-src 'none'", + "X-GitHub-Request-Id": "AC20:E4F4:322E5E4:32FF236:64090DFB" + } + }, + "uuid": "9e6bf17e-5e07-4c66-ab42-eba00096c098", + "persistent": true, + "insertionIndex": 1 +} \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/AppTest/wiremock/testAddDeployKeyAsReadOnly/__files/repos_hub4j-test-org_github-api-test-2.json b/src/test/resources/org/kohsuke/github/AppTest/wiremock/testAddDeployKeyAsReadOnly/__files/repos_hub4j-test-org_github-api-test-2.json new file mode 100644 index 0000000000..2d5a6b55ff --- /dev/null +++ b/src/test/resources/org/kohsuke/github/AppTest/wiremock/testAddDeployKeyAsReadOnly/__files/repos_hub4j-test-org_github-api-test-2.json @@ -0,0 +1,117 @@ +{ + "id": 611473997, + "node_id": "R_kgDOJHJaTQ", + "name": "github-api-test", + "full_name": "hub4j-test-org/github-api-test", + "private": false, + "owner": { + "login": "hub4j-test-org", + "id": 238558, + "node_id": "MDQ6VXNlcjIzODU1OA==", + "avatar_url": "https://avatars.githubusercontent.com/u/238558?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/hub4j-test-org", + "html_url": "https://github.com/hub4j-test-org", + "followers_url": "https://api.github.com/users/hub4j-test-org/followers", + "following_url": "https://api.github.com/users/hub4j-test-org/following{/other_user}", + "gists_url": "https://api.github.com/users/hub4j-test-org/gists{/gist_id}", + "starred_url": "https://api.github.com/users/hub4j-test-org/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/hub4j-test-org/subscriptions", + "organizations_url": "https://api.github.com/users/hub4j-test-org/orgs", + "repos_url": "https://api.github.com/users/hub4j-test-org/repos", + "events_url": "https://api.github.com/users/hub4j-test-org/events{/privacy}", + "received_events_url": "https://api.github.com/users/hub4j-test-org/received_events", + "type": "User", + "site_admin": false + }, + "html_url": "https://github.com/hub4j-test-org/github-api-test", + "description": "A test repository for testing the github-api project: github-api-test", + "fork": false, + "url": "https://api.github.com/repos/hub4j-test-org/github-api-test", + "forks_url": "https://api.github.com/repos/hub4j-test-org/github-api-test/forks", + "keys_url": "https://api.github.com/repos/hub4j-test-org/github-api-test/keys{/key_id}", + "collaborators_url": "https://api.github.com/repos/hub4j-test-org/github-api-test/collaborators{/collaborator}", + "teams_url": "https://api.github.com/repos/hub4j-test-org/github-api-test/teams", + "hooks_url": "https://api.github.com/repos/hub4j-test-org/github-api-test/hooks", + "issue_events_url": "https://api.github.com/repos/hub4j-test-org/github-api-test/issues/events{/number}", + "events_url": "https://api.github.com/repos/hub4j-test-org/github-api-test/events", + "assignees_url": "https://api.github.com/repos/hub4j-test-org/github-api-test/assignees{/user}", + "branches_url": "https://api.github.com/repos/hub4j-test-org/github-api-test/branches{/branch}", + "tags_url": "https://api.github.com/repos/hub4j-test-org/github-api-test/tags", + "blobs_url": "https://api.github.com/repos/hub4j-test-org/github-api-test/git/blobs{/sha}", + "git_tags_url": "https://api.github.com/repos/hub4j-test-org/github-api-test/git/tags{/sha}", + "git_refs_url": "https://api.github.com/repos/hub4j-test-org/github-api-test/git/refs{/sha}", + "trees_url": "https://api.github.com/repos/hub4j-test-org/github-api-test/git/trees{/sha}", + "statuses_url": "https://api.github.com/repos/hub4j-test-org/github-api-test/statuses/{sha}", + "languages_url": "https://api.github.com/repos/hub4j-test-org/github-api-test/languages", + "stargazers_url": "https://api.github.com/repos/hub4j-test-org/github-api-test/stargazers", + "contributors_url": "https://api.github.com/repos/hub4j-test-org/github-api-test/contributors", + "subscribers_url": "https://api.github.com/repos/hub4j-test-org/github-api-test/subscribers", + "subscription_url": "https://api.github.com/repos/hub4j-test-org/github-api-test/subscription", + "commits_url": "https://api.github.com/repos/hub4j-test-org/github-api-test/commits{/sha}", + "git_commits_url": "https://api.github.com/repos/hub4j-test-org/github-api-test/git/commits{/sha}", + "comments_url": "https://api.github.com/repos/hub4j-test-org/github-api-test/comments{/number}", + "issue_comment_url": "https://api.github.com/repos/hub4j-test-org/github-api-test/issues/comments{/number}", + "contents_url": "https://api.github.com/repos/hub4j-test-org/github-api-test/contents/{+path}", + "compare_url": "https://api.github.com/repos/hub4j-test-org/github-api-test/compare/{base}...{head}", + "merges_url": "https://api.github.com/repos/hub4j-test-org/github-api-test/merges", + "archive_url": "https://api.github.com/repos/hub4j-test-org/github-api-test/{archive_format}{/ref}", + "downloads_url": "https://api.github.com/repos/hub4j-test-org/github-api-test/downloads", + "issues_url": "https://api.github.com/repos/hub4j-test-org/github-api-test/issues{/number}", + "pulls_url": "https://api.github.com/repos/hub4j-test-org/github-api-test/pulls{/number}", + "milestones_url": "https://api.github.com/repos/hub4j-test-org/github-api-test/milestones{/number}", + "notifications_url": "https://api.github.com/repos/hub4j-test-org/github-api-test/notifications{?since,all,participating}", + "labels_url": "https://api.github.com/repos/hub4j-test-org/github-api-test/labels{/name}", + "releases_url": "https://api.github.com/repos/hub4j-test-org/github-api-test/releases{/id}", + "deployments_url": "https://api.github.com/repos/hub4j-test-org/github-api-test/deployments", + "created_at": "2023-03-08T22:36:45Z", + "updated_at": "2023-03-08T22:36:45Z", + "pushed_at": "2023-03-08T22:36:45Z", + "git_url": "git://github.com/hub4j-test-org/github-api-test.git", + "ssh_url": "git@github.com:hub4j-test-org/github-api-test.git", + "clone_url": "https://github.com/hub4j-test-org/github-api-test.git", + "svn_url": "https://github.com/hub4j-test-org/github-api-test", + "homepage": "http://github-api.kohsuke.org/", + "size": 0, + "stargazers_count": 0, + "watchers_count": 0, + "language": null, + "has_issues": true, + "has_projects": true, + "has_downloads": true, + "has_wiki": true, + "has_pages": false, + "has_discussions": false, + "forks_count": 0, + "mirror_url": null, + "archived": false, + "disabled": false, + "open_issues_count": 0, + "license": null, + "allow_forking": true, + "is_template": false, + "web_commit_signoff_required": false, + "topics": [], + "visibility": "public", + "forks": 0, + "open_issues": 0, + "watchers": 0, + "default_branch": "main", + "permissions": { + "admin": true, + "maintain": true, + "push": true, + "triage": true, + "pull": true + }, + "security_and_analysis": { + "secret_scanning": { + "status": "disabled" + }, + "secret_scanning_push_protection": { + "status": "disabled" + } + }, + "network_count": 0, + "subscribers_count": 1 +} \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/AppTest/wiremock/testAddDeployKeyAsReadOnly/__files/repos_hub4j-test-org_github-api-test_keys-3.json b/src/test/resources/org/kohsuke/github/AppTest/wiremock/testAddDeployKeyAsReadOnly/__files/repos_hub4j-test-org_github-api-test_keys-3.json new file mode 100644 index 0000000000..6b1f155ad8 --- /dev/null +++ b/src/test/resources/org/kohsuke/github/AppTest/wiremock/testAddDeployKeyAsReadOnly/__files/repos_hub4j-test-org_github-api-test_keys-3.json @@ -0,0 +1,11 @@ +{ + "id": 78869617, + "key": "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIATWwMLytklB44O66isWRKOB3Qd7Ysc7q7EyWTmT0bG9", + "url": "https://api.github.com/repos/hub4j-test-org/github-api-test/keys/78869617", + "title": "test", + "verified": true, + "created_at": "2023-03-08T22:36:50Z", + "read_only": true, + "last_used": null, + "added_by": "hub4j-test-org" +} \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/AppTest/wiremock/testAddDeployKeyAsReadOnly/__files/repos_hub4j-test-org_github-api-test_keys-4.json b/src/test/resources/org/kohsuke/github/AppTest/wiremock/testAddDeployKeyAsReadOnly/__files/repos_hub4j-test-org_github-api-test_keys-4.json new file mode 100644 index 0000000000..7c1ba9bebb --- /dev/null +++ b/src/test/resources/org/kohsuke/github/AppTest/wiremock/testAddDeployKeyAsReadOnly/__files/repos_hub4j-test-org_github-api-test_keys-4.json @@ -0,0 +1,13 @@ +[ + { + "id": 78869617, + "key": "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIATWwMLytklB44O66isWRKOB3Qd7Ysc7q7EyWTmT0bG9", + "url": "https://api.github.com/repos/hub4j-test-org/github-api-test/keys/78869617", + "title": "test", + "verified": true, + "created_at": "2023-03-08T22:36:50Z", + "read_only": true, + "last_used": null, + "added_by": "hub4j-test-org" + } +] \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/AppTest/wiremock/testAddDeployKeyAsReadOnly/__files/user-1.json b/src/test/resources/org/kohsuke/github/AppTest/wiremock/testAddDeployKeyAsReadOnly/__files/user-1.json new file mode 100644 index 0000000000..92e9ace93c --- /dev/null +++ b/src/test/resources/org/kohsuke/github/AppTest/wiremock/testAddDeployKeyAsReadOnly/__files/user-1.json @@ -0,0 +1,34 @@ +{ + "login": "hub4j-test-org", + "id": 7544739, + "node_id": "MDQ6VXNlcjIzODU1OA==", + "avatar_url": "https://avatars.githubusercontent.com/u/7544739?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/hub4j-test-org", + "html_url": "https://github.com/hub4j-test-org", + "followers_url": "https://api.github.com/users/hub4j-test-org/followers", + "following_url": "https://api.github.com/users/hub4j-test-org/following{/other_user}", + "gists_url": "https://api.github.com/users/hub4j-test-org/gists{/gist_id}", + "starred_url": "https://api.github.com/users/hub4j-test-org/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/hub4j-test-org/subscriptions", + "organizations_url": "https://api.github.com/users/hub4j-test-org/orgs", + "repos_url": "https://api.github.com/users/hub4j-test-org/repos", + "events_url": "https://api.github.com/users/hub4j-test-org/events{/privacy}", + "received_events_url": "https://api.github.com/users/hub4j-test-org/received_events", + "type": "User", + "site_admin": false, + "name": "hub4j-test-org", + "company": null, + "blog": "", + "location": "", + "email": null, + "hireable": null, + "bio": "", + "twitter_username": null, + "public_repos": 13, + "public_gists": 4, + "followers": 6, + "following": 1, + "created_at": "2010-04-07T08:30:12Z", + "updated_at": "2022-11-28T20:54:46Z" +} \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/AppTest/wiremock/testAddDeployKeyAsReadOnly/mappings/repos_hub4j-test-org_github-api-test-2.json b/src/test/resources/org/kohsuke/github/AppTest/wiremock/testAddDeployKeyAsReadOnly/mappings/repos_hub4j-test-org_github-api-test-2.json new file mode 100644 index 0000000000..8764b8abec --- /dev/null +++ b/src/test/resources/org/kohsuke/github/AppTest/wiremock/testAddDeployKeyAsReadOnly/mappings/repos_hub4j-test-org_github-api-test-2.json @@ -0,0 +1,49 @@ +{ + "id": "8b7ef826-893b-4288-b625-4492949cd9b1", + "name": "repos_hub4j-test-org_github-api-test", + "request": { + "url": "/repos/hub4j-test-org/github-api-test", + "method": "GET", + "headers": { + "Accept": { + "equalTo": "application/vnd.github.v3+json" + } + } + }, + "response": { + "status": 200, + "bodyFileName": "repos_hub4j-test-org_github-api-test-2.json", + "headers": { + "Server": "GitHub.com", + "Date": "Wed, 08 Mar 2023 22:36:49 GMT", + "Content-Type": "application/json; charset=utf-8", + "Cache-Control": "private, max-age=60, s-maxage=60", + "Vary": [ + "Accept, Authorization, Cookie, X-GitHub-OTP", + "Accept-Encoding, Accept, X-Requested-With" + ], + "ETag": "W/\"9a25876ca00d328a54c1400dffe501009cdcbc3410dd90140b0c33cc19608961\"", + "Last-Modified": "Wed, 08 Mar 2023 22:36:45 GMT", + "github-authentication-token-expiration": "2023-04-07 23:24:34 +0200", + "X-GitHub-Media-Type": "github.v3; format=json", + "x-github-api-version-selected": "2022-11-28", + "X-RateLimit-Limit": "5000", + "X-RateLimit-Remaining": "4903", + "X-RateLimit-Reset": "1678317208", + "X-RateLimit-Used": "97", + "X-RateLimit-Resource": "core", + "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", + "Access-Control-Allow-Origin": "*", + "Strict-Transport-Security": "max-age=31536000; includeSubdomains; preload", + "X-Frame-Options": "deny", + "X-Content-Type-Options": "nosniff", + "X-XSS-Protection": "0", + "Referrer-Policy": "origin-when-cross-origin, strict-origin-when-cross-origin", + "Content-Security-Policy": "default-src 'none'", + "X-GitHub-Request-Id": "E5D8:ACE5:B4A8F2D:B741C36:64090E01" + } + }, + "uuid": "8b7ef826-893b-4288-b625-4492949cd9b1", + "persistent": true, + "insertionIndex": 2 +} \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/AppTest/wiremock/testAddDeployKeyAsReadOnly/mappings/repos_hub4j-test-org_github-api-test_keys-3.json b/src/test/resources/org/kohsuke/github/AppTest/wiremock/testAddDeployKeyAsReadOnly/mappings/repos_hub4j-test-org_github-api-test_keys-3.json new file mode 100644 index 0000000000..3fee79387a --- /dev/null +++ b/src/test/resources/org/kohsuke/github/AppTest/wiremock/testAddDeployKeyAsReadOnly/mappings/repos_hub4j-test-org_github-api-test_keys-3.json @@ -0,0 +1,56 @@ +{ + "id": "f648e6ad-c2ec-42b2-bc75-017ac64e67d9", + "name": "repos_hub4j-test-org_github-api-test_keys", + "request": { + "url": "/repos/hub4j-test-org/github-api-test/keys", + "method": "POST", + "headers": { + "Accept": { + "equalTo": "application/vnd.github.v3+json" + } + }, + "bodyPatterns": [ + { + "equalToJson": "{\"read_only\":true,\"title\":\"test\",\"key\":\"ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIATWwMLytklB44O66isWRKOB3Qd7Ysc7q7EyWTmT0bG9 test@example.com\"}", + "ignoreArrayOrder": true, + "ignoreExtraElements": false + } + ] + }, + "response": { + "status": 201, + "bodyFileName": "repos_hub4j-test-org_github-api-test_keys-3.json", + "headers": { + "Server": "GitHub.com", + "Date": "Wed, 08 Mar 2023 22:36:50 GMT", + "Content-Type": "application/json; charset=utf-8", + "Cache-Control": "private, max-age=60, s-maxage=60", + "Vary": [ + "Accept, Authorization, Cookie, X-GitHub-OTP", + "Accept-Encoding, Accept, X-Requested-With" + ], + "ETag": "\"0a4e82c98d34824d431a19b779f7fcc35e1a3c1142ff9c1a7132d8840630f8a6\"", + "github-authentication-token-expiration": "2023-04-07 23:24:34 +0200", + "X-GitHub-Media-Type": "github.v3; format=json", + "x-github-api-version-selected": "2022-11-28", + "X-RateLimit-Limit": "5000", + "X-RateLimit-Remaining": "4902", + "X-RateLimit-Reset": "1678317208", + "X-RateLimit-Used": "98", + "X-RateLimit-Resource": "core", + "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", + "Access-Control-Allow-Origin": "*", + "Strict-Transport-Security": "max-age=31536000; includeSubdomains; preload", + "X-Frame-Options": "deny", + "X-Content-Type-Options": "nosniff", + "X-XSS-Protection": "0", + "Referrer-Policy": "origin-when-cross-origin, strict-origin-when-cross-origin", + "Content-Security-Policy": "default-src 'none'", + "X-GitHub-Request-Id": "E5DE:A9BF:A40D94B:A69E360:64090E01", + "Location": "https://api.github.com/repos/hub4j-test-org/github-api-test/keys/78869617" + } + }, + "uuid": "f648e6ad-c2ec-42b2-bc75-017ac64e67d9", + "persistent": true, + "insertionIndex": 3 +} \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/AppTest/wiremock/testAddDeployKeyAsReadOnly/mappings/repos_hub4j-test-org_github-api-test_keys-4.json b/src/test/resources/org/kohsuke/github/AppTest/wiremock/testAddDeployKeyAsReadOnly/mappings/repos_hub4j-test-org_github-api-test_keys-4.json new file mode 100644 index 0000000000..c1372692d8 --- /dev/null +++ b/src/test/resources/org/kohsuke/github/AppTest/wiremock/testAddDeployKeyAsReadOnly/mappings/repos_hub4j-test-org_github-api-test_keys-4.json @@ -0,0 +1,48 @@ +{ + "id": "ca5ce05e-5052-4cce-9508-c33ba42ab18f", + "name": "repos_hub4j-test-org_github-api-test_keys", + "request": { + "url": "/repos/hub4j-test-org/github-api-test/keys", + "method": "GET", + "headers": { + "Accept": { + "equalTo": "application/vnd.github.v3+json" + } + } + }, + "response": { + "status": 200, + "bodyFileName": "repos_hub4j-test-org_github-api-test_keys-4.json", + "headers": { + "Server": "GitHub.com", + "Date": "Wed, 08 Mar 2023 22:36:50 GMT", + "Content-Type": "application/json; charset=utf-8", + "Cache-Control": "private, max-age=60, s-maxage=60", + "Vary": [ + "Accept, Authorization, Cookie, X-GitHub-OTP", + "Accept-Encoding, Accept, X-Requested-With" + ], + "ETag": "W/\"0a77e8787fcd166b10430624945723c4d8bdc5f131bcc1c821d56170eec9db86\"", + "github-authentication-token-expiration": "2023-04-07 23:24:34 +0200", + "X-GitHub-Media-Type": "github.v3; format=json", + "x-github-api-version-selected": "2022-11-28", + "X-RateLimit-Limit": "5000", + "X-RateLimit-Remaining": "4901", + "X-RateLimit-Reset": "1678317208", + "X-RateLimit-Used": "99", + "X-RateLimit-Resource": "core", + "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", + "Access-Control-Allow-Origin": "*", + "Strict-Transport-Security": "max-age=31536000; includeSubdomains; preload", + "X-Frame-Options": "deny", + "X-Content-Type-Options": "nosniff", + "X-XSS-Protection": "0", + "Referrer-Policy": "origin-when-cross-origin, strict-origin-when-cross-origin", + "Content-Security-Policy": "default-src 'none'", + "X-GitHub-Request-Id": "E5EA:3041:9E5EEE8:A0EE307:64090E02" + } + }, + "uuid": "ca5ce05e-5052-4cce-9508-c33ba42ab18f", + "persistent": true, + "insertionIndex": 4 +} \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/AppTest/wiremock/testAddDeployKeyAsReadOnly/mappings/repos_hub4j-test-org_github-api-test_keys_78869617-5.json b/src/test/resources/org/kohsuke/github/AppTest/wiremock/testAddDeployKeyAsReadOnly/mappings/repos_hub4j-test-org_github-api-test_keys_78869617-5.json new file mode 100644 index 0000000000..833744f03e --- /dev/null +++ b/src/test/resources/org/kohsuke/github/AppTest/wiremock/testAddDeployKeyAsReadOnly/mappings/repos_hub4j-test-org_github-api-test_keys_78869617-5.json @@ -0,0 +1,41 @@ +{ + "id": "0fc8164e-80f8-450b-a7b5-4f604f9eeaa9", + "name": "repos_hub4j-test-org_github-api-test_keys_78869617", + "request": { + "url": "/repos/hub4j-test-org/github-api-test/keys/78869617", + "method": "DELETE", + "headers": { + "Accept": { + "equalTo": "application/vnd.github.v3+json" + } + } + }, + "response": { + "status": 204, + "headers": { + "Server": "GitHub.com", + "Date": "Wed, 08 Mar 2023 22:36:51 GMT", + "github-authentication-token-expiration": "2023-04-07 23:24:34 +0200", + "X-GitHub-Media-Type": "github.v3; format=json", + "x-github-api-version-selected": "2022-11-28", + "X-RateLimit-Limit": "5000", + "X-RateLimit-Remaining": "4900", + "X-RateLimit-Reset": "1678317208", + "X-RateLimit-Used": "100", + "X-RateLimit-Resource": "core", + "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", + "Access-Control-Allow-Origin": "*", + "Strict-Transport-Security": "max-age=31536000; includeSubdomains; preload", + "X-Frame-Options": "deny", + "X-Content-Type-Options": "nosniff", + "X-XSS-Protection": "0", + "Referrer-Policy": "origin-when-cross-origin, strict-origin-when-cross-origin", + "Content-Security-Policy": "default-src 'none'", + "Vary": "Accept-Encoding, Accept, X-Requested-With", + "X-GitHub-Request-Id": "E5FA:A7AE:82F2BFE:8532045:64090E02" + } + }, + "uuid": "0fc8164e-80f8-450b-a7b5-4f604f9eeaa9", + "persistent": true, + "insertionIndex": 5 +} \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/AppTest/wiremock/testAddDeployKeyAsReadOnly/mappings/user-1.json b/src/test/resources/org/kohsuke/github/AppTest/wiremock/testAddDeployKeyAsReadOnly/mappings/user-1.json new file mode 100644 index 0000000000..d46c6d045e --- /dev/null +++ b/src/test/resources/org/kohsuke/github/AppTest/wiremock/testAddDeployKeyAsReadOnly/mappings/user-1.json @@ -0,0 +1,49 @@ +{ + "id": "9e6bf17e-5e07-4c66-ab42-eba00096c098", + "name": "user", + "request": { + "url": "/user", + "method": "GET", + "headers": { + "Accept": { + "equalTo": "application/vnd.github.v3+json" + } + } + }, + "response": { + "status": 200, + "bodyFileName": "user-1.json", + "headers": { + "Server": "GitHub.com", + "Date": "Wed, 08 Mar 2023 22:36:44 GMT", + "Content-Type": "application/json; charset=utf-8", + "Cache-Control": "private, max-age=60, s-maxage=60", + "Vary": [ + "Accept, Authorization, Cookie, X-GitHub-OTP", + "Accept-Encoding, Accept, X-Requested-With" + ], + "ETag": "W/\"e548710856e14da19e6d9c3a0b9e6751b4cec74b4ead51290d5179d92173e70e\"", + "Last-Modified": "Mon, 28 Nov 2022 20:54:46 GMT", + "github-authentication-token-expiration": "2023-04-07 23:24:34 +0200", + "X-GitHub-Media-Type": "github.v3; format=json", + "x-github-api-version-selected": "2022-11-28", + "X-RateLimit-Limit": "5000", + "X-RateLimit-Remaining": "4907", + "X-RateLimit-Reset": "1678317208", + "X-RateLimit-Used": "93", + "X-RateLimit-Resource": "core", + "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", + "Access-Control-Allow-Origin": "*", + "Strict-Transport-Security": "max-age=31536000; includeSubdomains; preload", + "X-Frame-Options": "deny", + "X-Content-Type-Options": "nosniff", + "X-XSS-Protection": "0", + "Referrer-Policy": "origin-when-cross-origin, strict-origin-when-cross-origin", + "Content-Security-Policy": "default-src 'none'", + "X-GitHub-Request-Id": "AC20:E4F4:322E5E4:32FF236:64090DFB" + } + }, + "uuid": "9e6bf17e-5e07-4c66-ab42-eba00096c098", + "persistent": true, + "insertionIndex": 1 +} \ No newline at end of file