Skip to content

Commit

Permalink
Added test for addCollaborators
Browse files Browse the repository at this point in the history
Mark old addCollaborators methods depricated
  • Loading branch information
jimmysombrero committed Feb 3, 2020
1 parent 205e5ab commit d767575
Show file tree
Hide file tree
Showing 14 changed files with 199 additions and 39 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,4 @@ target

dependency-reduced-pom.xml
.factorypath
.vscode/settings.json
2 changes: 2 additions & 0 deletions src/main/java/org/kohsuke/github/GHRepository.java
Original file line number Diff line number Diff line change
Expand Up @@ -860,6 +860,7 @@ public void addCollaborators(GHOrganization.Permission perm, GHUser... users) th
* @throws IOException
* the io exception
*/
@Deprecated
public void addCollaborators(GHUser... users) throws IOException {
addCollaborators(asList(users));
}
Expand All @@ -872,6 +873,7 @@ public void addCollaborators(GHUser... users) throws IOException {
* @throws IOException
* the io exception
*/
@Deprecated
public void addCollaborators(List<GHUser> users) throws IOException {
modifyCollaborators(users, "PUT");
}
Expand Down
3 changes: 1 addition & 2 deletions src/test/java/org/kohsuke/github/GHRepositoryTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -169,10 +169,9 @@ public void addCollaborators() throws Exception {

GHPersonSet<GHUser> collabs = repo.getCollaborators();

GHUser colabUser = collabs.byLogin(user.getLogin());
GHUser colabUser = collabs.byLogin("jimmysombrero");

assertEquals(colabUser.getName(), user.getName());
assertEquals(GHOrganization.Permission.PUSH, repo.getPermission(user.getName()));
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@
"deployments_url": "https://api.github.com/repos/github-api/github-api/deployments",
"created_at": "2010-04-19T04:13:03Z",
"updated_at": "2020-02-01T02:00:03Z",
"pushed_at": "2020-01-31T21:18:18Z",
"pushed_at": "2020-02-02T04:40:57Z",
"git_url": "git://github.com/github-api/github-api.git",
"ssh_url": "[email protected]:github-api/github-api.git",
"clone_url": "https://github.com/github-api/github-api.git",
Expand Down Expand Up @@ -291,7 +291,7 @@
"deployments_url": "https://api.github.com/repos/github-api/github-api/deployments",
"created_at": "2010-04-19T04:13:03Z",
"updated_at": "2020-02-01T02:00:03Z",
"pushed_at": "2020-01-31T21:18:18Z",
"pushed_at": "2020-02-02T04:40:57Z",
"git_url": "git://github.com/github-api/github-api.git",
"ssh_url": "[email protected]:github-api/github-api.git",
"clone_url": "https://github.com/github-api/github-api.git",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
[
{
"login": "jimmysombrero",
"id": 12157727,
"node_id": "MDQ6VXNlcjEyMTU3NzI3",
"avatar_url": "https://avatars3.githubusercontent.com/u/12157727?v=4",
"gravatar_id": "",
"url": "https://api.github.com/users/jimmysombrero",
"html_url": "https://github.com/jimmysombrero",
"followers_url": "https://api.github.com/users/jimmysombrero/followers",
"following_url": "https://api.github.com/users/jimmysombrero/following{/other_user}",
"gists_url": "https://api.github.com/users/jimmysombrero/gists{/gist_id}",
"starred_url": "https://api.github.com/users/jimmysombrero/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/jimmysombrero/subscriptions",
"organizations_url": "https://api.github.com/users/jimmysombrero/orgs",
"repos_url": "https://api.github.com/users/jimmysombrero/repos",
"events_url": "https://api.github.com/users/jimmysombrero/events{/privacy}",
"received_events_url": "https://api.github.com/users/jimmysombrero/received_events",
"type": "User",
"site_admin": false,
"permissions": {
"push": true,
"pull": true,
"admin": false
}
}
]
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
"followers": 1,
"following": 0,
"created_at": "2015-04-28T17:47:19Z",
"updated_at": "2020-02-02T04:15:35Z",
"updated_at": "2020-02-02T04:43:58Z",
"private_gists": 0,
"total_private_repos": 0,
"owned_private_repos": 0,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
{
"login": "jimmysombrero",
"id": 12157727,
"node_id": "MDQ6VXNlcjEyMTU3NzI3",
"avatar_url": "https://avatars3.githubusercontent.com/u/12157727?v=4",
"gravatar_id": "",
"url": "https://api.github.com/users/jimmysombrero",
"html_url": "https://github.com/jimmysombrero",
"followers_url": "https://api.github.com/users/jimmysombrero/followers",
"following_url": "https://api.github.com/users/jimmysombrero/following{/other_user}",
"gists_url": "https://api.github.com/users/jimmysombrero/gists{/gist_id}",
"starred_url": "https://api.github.com/users/jimmysombrero/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/jimmysombrero/subscriptions",
"organizations_url": "https://api.github.com/users/jimmysombrero/orgs",
"repos_url": "https://api.github.com/users/jimmysombrero/repos",
"events_url": "https://api.github.com/users/jimmysombrero/events{/privacy}",
"received_events_url": "https://api.github.com/users/jimmysombrero/received_events",
"type": "User",
"site_admin": false,
"name": null,
"company": null,
"blog": "",
"location": null,
"email": null,
"hireable": null,
"bio": null,
"public_repos": 4,
"public_gists": 0,
"followers": 1,
"following": 0,
"created_at": "2015-04-28T17:47:19Z",
"updated_at": "2020-02-02T04:43:58Z",
"private_gists": 0,
"total_private_repos": 0,
"owned_private_repos": 0,
"disk_usage": 19,
"collaborators": 0,
"two_factor_authentication": false,
"plan": {
"name": "free",
"space": 976562499,
"collaborators": 0,
"private_repos": 10000
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"id": "355d5cda-5423-49ef-b604-6276fbaba24e",
"id": "a3d2b552-58b8-4028-b731-d00420496ca8",
"name": "orgs_github-api-test-org",
"request": {
"url": "/orgs/github-api-test-org",
Expand All @@ -12,14 +12,14 @@
},
"response": {
"status": 200,
"bodyFileName": "orgs_github-api-test-org-355d5cda-5423-49ef-b604-6276fbaba24e.json",
"bodyFileName": "orgs_github-api-test-org-a3d2b552-58b8-4028-b731-d00420496ca8.json",
"headers": {
"Server": "GitHub.com",
"Date": "Sun, 02 Feb 2020 04:29:45 GMT",
"Date": "Sun, 02 Feb 2020 04:59:39 GMT",
"Content-Type": "application/json; charset=utf-8",
"Status": "200 OK",
"X-RateLimit-Limit": "5000",
"X-RateLimit-Remaining": "4951",
"X-RateLimit-Remaining": "4895",
"X-RateLimit-Reset": "1580620984",
"Cache-Control": "private, max-age=60, s-maxage=60",
"Vary": "Accept, Authorization, Cookie, X-GitHub-OTP",
Expand All @@ -36,10 +36,10 @@
"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": "C7DB:0D8E:63D359:C9F18B:5E365038"
"X-GitHub-Request-Id": "C903:768E:16C4938:2BA1171:5E36573B"
}
},
"uuid": "355d5cda-5423-49ef-b604-6276fbaba24e",
"uuid": "a3d2b552-58b8-4028-b731-d00420496ca8",
"persistent": true,
"insertionIndex": 2
"insertionIndex": 1
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"id": "e5504dd6-42ca-4d7f-9d95-f224e5f36a90",
"id": "95ce4098-4e40-49f0-8661-0870614d5d78",
"name": "repos_github-api-test-org_github-api",
"request": {
"url": "/repos/github-api-test-org/github-api",
Expand All @@ -12,18 +12,18 @@
},
"response": {
"status": 200,
"bodyFileName": "repos_github-api-test-org_github-api-e5504dd6-42ca-4d7f-9d95-f224e5f36a90.json",
"bodyFileName": "repos_github-api-test-org_github-api-95ce4098-4e40-49f0-8661-0870614d5d78.json",
"headers": {
"Server": "GitHub.com",
"Date": "Sun, 02 Feb 2020 04:29:45 GMT",
"Date": "Sun, 02 Feb 2020 04:59:39 GMT",
"Content-Type": "application/json; charset=utf-8",
"Status": "200 OK",
"X-RateLimit-Limit": "5000",
"X-RateLimit-Remaining": "4950",
"X-RateLimit-Reset": "1580620984",
"X-RateLimit-Remaining": "4894",
"X-RateLimit-Reset": "1580620983",
"Cache-Control": "private, max-age=60, s-maxage=60",
"Vary": "Accept, Authorization, Cookie, X-GitHub-OTP",
"ETag": "W/\"c310cb7abd9a90e105810461c34dd8c6\"",
"ETag": "W/\"d61f18a7ccc89231875444b59f56580f\"",
"Last-Modified": "Thu, 16 Jan 2020 21:22:56 GMT",
"X-OAuth-Scopes": "admin:enterprise, admin:gpg_key, admin:org, admin:org_hook, admin:public_key, admin:repo_hook, delete:packages, delete_repo, gist, notifications, read:packages, repo, user, workflow, write:discussion, write:packages",
"X-Accepted-OAuth-Scopes": "repo",
Expand All @@ -36,10 +36,10 @@
"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": "C7DB:0D8E:63D35D:C9F1A2:5E365039"
"X-GitHub-Request-Id": "C903:768E:16C4945:2BA117B:5E36573B"
}
},
"uuid": "e5504dd6-42ca-4d7f-9d95-f224e5f36a90",
"uuid": "95ce4098-4e40-49f0-8661-0870614d5d78",
"persistent": true,
"insertionIndex": 3
"insertionIndex": 2
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
{
"id": "ddaa8229-c0ae-4df6-90ed-08425bfe71f2",
"name": "repos_github-api-test-org_github-api_collaborators",
"request": {
"url": "/repos/github-api-test-org/github-api/collaborators",
"method": "GET",
"headers": {
"Accept": {
"equalTo": "text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2"
}
}
},
"response": {
"status": "200",
"bodyFileName": "repos_github-apit-test-ort_github-api_get_collaborators-5-ddaa82.json",
"headers": {
"Server": "GitHub.com",
"Date": "Mon, 03 Feb 2020 02:32:07 GMT",
"Content-Type": "application/json; charset=utf-8",
"Status": "200 OK",
"X-RateLimit-Limit": "5000",
"X-RateLimit-Remaining": "4979",
"X-RateLimit-Reset": "1580700723",
"X-OAuth-Scopes": "admin:enterprise, admin:gpg_key, admin:org, admin:org_hook, admin:public_key, admin:repo_hook, delete:packages, delete_repo, gist, notifications, read:packages, repo, user, workflow, write:discussion, write:packages",
"X-Accepted-OAuth-Scopes": "",
"X-GitHub-Media-Type": "unknown, github.v3",
"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": "CBB1:43C6:FBCD05:26D0ED5:5E378627"
}
},
"uuid": "ddaa8229-c0ae-4df6-90ed-08425bfe71f2",
"persistent": true,
"insertionIndex": 5
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"id": "1bfe0280-5533-459c-8515-57f70bed0d04",
"id": "3d80b19e-05f4-4ad9-a610-5f573abc4363",
"name": "repos_github-api-test-org_github-api_collaborators_jimmysombrero",
"request": {
"url": "/repos/github-api-test-org/github-api/collaborators/jimmysombrero",
Expand All @@ -18,16 +18,16 @@
]
},
"response": {
"status": 404,
"body": "{\"message\":\"Not Found\",\"documentation_url\":\"https://developer.github.com/v3/repos/collaborators/#add-user-as-a-collaborator\"}",
"status": 201,
"body": "[]",
"headers": {
"Server": "GitHub.com",
"Date": "Sun, 02 Feb 2020 04:29:45 GMT",
"Date": "Sun, 02 Feb 2020 04:59:39 GMT",
"Content-Type": "application/json; charset=utf-8",
"Status": "404 Not Found",
"Status": "201 Created",
"X-RateLimit-Limit": "5000",
"X-RateLimit-Remaining": "4949",
"X-RateLimit-Reset": "1580620984",
"X-RateLimit-Remaining": "4892",
"X-RateLimit-Reset": "1580620983",
"X-OAuth-Scopes": "admin:enterprise, admin:gpg_key, admin:org, admin:org_hook, admin:public_key, admin:repo_hook, delete:packages, delete_repo, gist, notifications, read:packages, repo, user, workflow, write:discussion, write:packages",
"X-Accepted-OAuth-Scopes": "",
"X-GitHub-Media-Type": "unknown, github.v3",
Expand All @@ -39,10 +39,10 @@
"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": "C7DB:0D8E:63D367:C9F1B5:5E365039"
"X-GitHub-Request-Id": "C903:768E:16C4966:2BA11B0:5E36573B"
}
},
"uuid": "1bfe0280-5533-459c-8515-57f70bed0d04",
"uuid": "3d80b19e-05f4-4ad9-a610-5f573abc4363",
"persistent": true,
"insertionIndex": 4
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"id": "4533e6b8-1725-4450-97b1-895a776d49b7",
"id": "f20ea960-c1f4-440c-bdc1-a605956a351a",
"name": "user",
"request": {
"url": "/user",
Expand All @@ -12,19 +12,19 @@
},
"response": {
"status": 200,
"bodyFileName": "user-4533e6b8-1725-4450-97b1-895a776d49b7.json",
"bodyFileName": "user-f20ea960-c1f4-440c-bdc1-a605956a351a.json",
"headers": {
"Server": "GitHub.com",
"Date": "Sun, 02 Feb 2020 04:29:44 GMT",
"Date": "Sun, 02 Feb 2020 04:59:39 GMT",
"Content-Type": "application/json; charset=utf-8",
"Status": "200 OK",
"X-RateLimit-Limit": "5000",
"X-RateLimit-Remaining": "4953",
"X-RateLimit-Remaining": "4893",
"X-RateLimit-Reset": "1580620983",
"Cache-Control": "private, max-age=60, s-maxage=60",
"Vary": "Accept, Authorization, Cookie, X-GitHub-OTP",
"ETag": "W/\"275d33915a65ed3fa77d5fed34147440\"",
"Last-Modified": "Sun, 02 Feb 2020 04:15:35 GMT",
"ETag": "W/\"7a0206b47e995649c88218afeb2266a6\"",
"Last-Modified": "Sun, 02 Feb 2020 04:43:58 GMT",
"X-OAuth-Scopes": "admin:enterprise, admin:gpg_key, admin:org, admin:org_hook, admin:public_key, admin:repo_hook, delete:packages, delete_repo, gist, notifications, read:packages, repo, user, workflow, write:discussion, write:packages",
"X-Accepted-OAuth-Scopes": "",
"X-GitHub-Media-Type": "unknown, github.v3",
Expand All @@ -36,10 +36,10 @@
"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": "C7DB:0D8E:63D34F:C9F17E:5E365038"
"X-GitHub-Request-Id": "C903:768E:16C495A:2BA119D:5E36573B"
}
},
"uuid": "4533e6b8-1725-4450-97b1-895a776d49b7",
"uuid": "f20ea960-c1f4-440c-bdc1-a605956a351a",
"persistent": true,
"insertionIndex": 1
"insertionIndex": 3
}
Loading

0 comments on commit d767575

Please sign in to comment.