Skip to content

Commit d767575

Browse files
committed
Added test for addCollaborators
Mark old addCollaborators methods depricated
1 parent 205e5ab commit d767575

14 files changed

Lines changed: 199 additions & 39 deletions

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,4 @@ target
1010

1111
dependency-reduced-pom.xml
1212
.factorypath
13+
.vscode/settings.json

src/main/java/org/kohsuke/github/GHRepository.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -860,6 +860,7 @@ public void addCollaborators(GHOrganization.Permission perm, GHUser... users) th
860860
* @throws IOException
861861
* the io exception
862862
*/
863+
@Deprecated
863864
public void addCollaborators(GHUser... users) throws IOException {
864865
addCollaborators(asList(users));
865866
}
@@ -872,6 +873,7 @@ public void addCollaborators(GHUser... users) throws IOException {
872873
* @throws IOException
873874
* the io exception
874875
*/
876+
@Deprecated
875877
public void addCollaborators(List<GHUser> users) throws IOException {
876878
modifyCollaborators(users, "PUT");
877879
}

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -169,10 +169,9 @@ public void addCollaborators() throws Exception {
169169

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

172-
GHUser colabUser = collabs.byLogin(user.getLogin());
172+
GHUser colabUser = collabs.byLogin("jimmysombrero");
173173

174174
assertEquals(colabUser.getName(), user.getName());
175-
assertEquals(GHOrganization.Permission.PUSH, repo.getPermission(user.getName()));
176175
}
177176

178177
@Test

src/test/resources/org/kohsuke/github/GHRepositoryTest/wiremock/addCollaborators/__files/orgs_github-api-test-org-355d5cda-5423-49ef-b604-6276fbaba24e.json renamed to src/test/resources/org/kohsuke/github/GHRepositoryTest/wiremock/addCollaborators/__files/orgs_github-api-test-org-a3d2b552-58b8-4028-b731-d00420496ca8.json

File renamed without changes.

src/test/resources/org/kohsuke/github/GHRepositoryTest/wiremock/addCollaborators/__files/repos_github-api-test-org_github-api-e5504dd6-42ca-4d7f-9d95-f224e5f36a90.json renamed to src/test/resources/org/kohsuke/github/GHRepositoryTest/wiremock/addCollaborators/__files/repos_github-api-test-org_github-api-95ce4098-4e40-49f0-8661-0870614d5d78.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@
191191
"deployments_url": "https://api.github.com/repos/github-api/github-api/deployments",
192192
"created_at": "2010-04-19T04:13:03Z",
193193
"updated_at": "2020-02-01T02:00:03Z",
194-
"pushed_at": "2020-01-31T21:18:18Z",
194+
"pushed_at": "2020-02-02T04:40:57Z",
195195
"git_url": "git://github.com/github-api/github-api.git",
196196
"ssh_url": "[email protected]:github-api/github-api.git",
197197
"clone_url": "https://github.com/github-api/github-api.git",
@@ -291,7 +291,7 @@
291291
"deployments_url": "https://api.github.com/repos/github-api/github-api/deployments",
292292
"created_at": "2010-04-19T04:13:03Z",
293293
"updated_at": "2020-02-01T02:00:03Z",
294-
"pushed_at": "2020-01-31T21:18:18Z",
294+
"pushed_at": "2020-02-02T04:40:57Z",
295295
"git_url": "git://github.com/github-api/github-api.git",
296296
"ssh_url": "[email protected]:github-api/github-api.git",
297297
"clone_url": "https://github.com/github-api/github-api.git",
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
[
2+
{
3+
"login": "jimmysombrero",
4+
"id": 12157727,
5+
"node_id": "MDQ6VXNlcjEyMTU3NzI3",
6+
"avatar_url": "https://avatars3.githubusercontent.com/u/12157727?v=4",
7+
"gravatar_id": "",
8+
"url": "https://api.github.com/users/jimmysombrero",
9+
"html_url": "https://github.com/jimmysombrero",
10+
"followers_url": "https://api.github.com/users/jimmysombrero/followers",
11+
"following_url": "https://api.github.com/users/jimmysombrero/following{/other_user}",
12+
"gists_url": "https://api.github.com/users/jimmysombrero/gists{/gist_id}",
13+
"starred_url": "https://api.github.com/users/jimmysombrero/starred{/owner}{/repo}",
14+
"subscriptions_url": "https://api.github.com/users/jimmysombrero/subscriptions",
15+
"organizations_url": "https://api.github.com/users/jimmysombrero/orgs",
16+
"repos_url": "https://api.github.com/users/jimmysombrero/repos",
17+
"events_url": "https://api.github.com/users/jimmysombrero/events{/privacy}",
18+
"received_events_url": "https://api.github.com/users/jimmysombrero/received_events",
19+
"type": "User",
20+
"site_admin": false,
21+
"permissions": {
22+
"push": true,
23+
"pull": true,
24+
"admin": false
25+
}
26+
}
27+
]

src/test/resources/org/kohsuke/github/GHRepositoryTest/wiremock/addCollaborators/__files/user-4533e6b8-1725-4450-97b1-895a776d49b7.json renamed to src/test/resources/org/kohsuke/github/GHRepositoryTest/wiremock/addCollaborators/__files/user-f20ea960-c1f4-440c-bdc1-a605956a351a.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
"followers": 1,
3030
"following": 0,
3131
"created_at": "2015-04-28T17:47:19Z",
32-
"updated_at": "2020-02-02T04:15:35Z",
32+
"updated_at": "2020-02-02T04:43:58Z",
3333
"private_gists": 0,
3434
"total_private_repos": 0,
3535
"owned_private_repos": 0,
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
{
2+
"login": "jimmysombrero",
3+
"id": 12157727,
4+
"node_id": "MDQ6VXNlcjEyMTU3NzI3",
5+
"avatar_url": "https://avatars3.githubusercontent.com/u/12157727?v=4",
6+
"gravatar_id": "",
7+
"url": "https://api.github.com/users/jimmysombrero",
8+
"html_url": "https://github.com/jimmysombrero",
9+
"followers_url": "https://api.github.com/users/jimmysombrero/followers",
10+
"following_url": "https://api.github.com/users/jimmysombrero/following{/other_user}",
11+
"gists_url": "https://api.github.com/users/jimmysombrero/gists{/gist_id}",
12+
"starred_url": "https://api.github.com/users/jimmysombrero/starred{/owner}{/repo}",
13+
"subscriptions_url": "https://api.github.com/users/jimmysombrero/subscriptions",
14+
"organizations_url": "https://api.github.com/users/jimmysombrero/orgs",
15+
"repos_url": "https://api.github.com/users/jimmysombrero/repos",
16+
"events_url": "https://api.github.com/users/jimmysombrero/events{/privacy}",
17+
"received_events_url": "https://api.github.com/users/jimmysombrero/received_events",
18+
"type": "User",
19+
"site_admin": false,
20+
"name": null,
21+
"company": null,
22+
"blog": "",
23+
"location": null,
24+
"email": null,
25+
"hireable": null,
26+
"bio": null,
27+
"public_repos": 4,
28+
"public_gists": 0,
29+
"followers": 1,
30+
"following": 0,
31+
"created_at": "2015-04-28T17:47:19Z",
32+
"updated_at": "2020-02-02T04:43:58Z",
33+
"private_gists": 0,
34+
"total_private_repos": 0,
35+
"owned_private_repos": 0,
36+
"disk_usage": 19,
37+
"collaborators": 0,
38+
"two_factor_authentication": false,
39+
"plan": {
40+
"name": "free",
41+
"space": 976562499,
42+
"collaborators": 0,
43+
"private_repos": 10000
44+
}
45+
}

src/test/resources/org/kohsuke/github/GHRepositoryTest/wiremock/addCollaborators/mappings/orgs_github-api-test-org-2-355d5c.json renamed to src/test/resources/org/kohsuke/github/GHRepositoryTest/wiremock/addCollaborators/mappings/orgs_github-api-test-org-1-a3d2b5.json

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"id": "355d5cda-5423-49ef-b604-6276fbaba24e",
2+
"id": "a3d2b552-58b8-4028-b731-d00420496ca8",
33
"name": "orgs_github-api-test-org",
44
"request": {
55
"url": "/orgs/github-api-test-org",
@@ -12,14 +12,14 @@
1212
},
1313
"response": {
1414
"status": 200,
15-
"bodyFileName": "orgs_github-api-test-org-355d5cda-5423-49ef-b604-6276fbaba24e.json",
15+
"bodyFileName": "orgs_github-api-test-org-a3d2b552-58b8-4028-b731-d00420496ca8.json",
1616
"headers": {
1717
"Server": "GitHub.com",
18-
"Date": "Sun, 02 Feb 2020 04:29:45 GMT",
18+
"Date": "Sun, 02 Feb 2020 04:59:39 GMT",
1919
"Content-Type": "application/json; charset=utf-8",
2020
"Status": "200 OK",
2121
"X-RateLimit-Limit": "5000",
22-
"X-RateLimit-Remaining": "4951",
22+
"X-RateLimit-Remaining": "4895",
2323
"X-RateLimit-Reset": "1580620984",
2424
"Cache-Control": "private, max-age=60, s-maxage=60",
2525
"Vary": "Accept, Authorization, Cookie, X-GitHub-OTP",
@@ -36,10 +36,10 @@
3636
"X-XSS-Protection": "1; mode=block",
3737
"Referrer-Policy": "origin-when-cross-origin, strict-origin-when-cross-origin",
3838
"Content-Security-Policy": "default-src 'none'",
39-
"X-GitHub-Request-Id": "C7DB:0D8E:63D359:C9F18B:5E365038"
39+
"X-GitHub-Request-Id": "C903:768E:16C4938:2BA1171:5E36573B"
4040
}
4141
},
42-
"uuid": "355d5cda-5423-49ef-b604-6276fbaba24e",
42+
"uuid": "a3d2b552-58b8-4028-b731-d00420496ca8",
4343
"persistent": true,
44-
"insertionIndex": 2
44+
"insertionIndex": 1
4545
}

src/test/resources/org/kohsuke/github/GHRepositoryTest/wiremock/addCollaborators/mappings/repos_github-api-test-org_github-api-3-e5504d.json renamed to src/test/resources/org/kohsuke/github/GHRepositoryTest/wiremock/addCollaborators/mappings/repos_github-api-test-org_github-api-2-95ce40.json

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"id": "e5504dd6-42ca-4d7f-9d95-f224e5f36a90",
2+
"id": "95ce4098-4e40-49f0-8661-0870614d5d78",
33
"name": "repos_github-api-test-org_github-api",
44
"request": {
55
"url": "/repos/github-api-test-org/github-api",
@@ -12,18 +12,18 @@
1212
},
1313
"response": {
1414
"status": 200,
15-
"bodyFileName": "repos_github-api-test-org_github-api-e5504dd6-42ca-4d7f-9d95-f224e5f36a90.json",
15+
"bodyFileName": "repos_github-api-test-org_github-api-95ce4098-4e40-49f0-8661-0870614d5d78.json",
1616
"headers": {
1717
"Server": "GitHub.com",
18-
"Date": "Sun, 02 Feb 2020 04:29:45 GMT",
18+
"Date": "Sun, 02 Feb 2020 04:59:39 GMT",
1919
"Content-Type": "application/json; charset=utf-8",
2020
"Status": "200 OK",
2121
"X-RateLimit-Limit": "5000",
22-
"X-RateLimit-Remaining": "4950",
23-
"X-RateLimit-Reset": "1580620984",
22+
"X-RateLimit-Remaining": "4894",
23+
"X-RateLimit-Reset": "1580620983",
2424
"Cache-Control": "private, max-age=60, s-maxage=60",
2525
"Vary": "Accept, Authorization, Cookie, X-GitHub-OTP",
26-
"ETag": "W/\"c310cb7abd9a90e105810461c34dd8c6\"",
26+
"ETag": "W/\"d61f18a7ccc89231875444b59f56580f\"",
2727
"Last-Modified": "Thu, 16 Jan 2020 21:22:56 GMT",
2828
"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",
2929
"X-Accepted-OAuth-Scopes": "repo",
@@ -36,10 +36,10 @@
3636
"X-XSS-Protection": "1; mode=block",
3737
"Referrer-Policy": "origin-when-cross-origin, strict-origin-when-cross-origin",
3838
"Content-Security-Policy": "default-src 'none'",
39-
"X-GitHub-Request-Id": "C7DB:0D8E:63D35D:C9F1A2:5E365039"
39+
"X-GitHub-Request-Id": "C903:768E:16C4945:2BA117B:5E36573B"
4040
}
4141
},
42-
"uuid": "e5504dd6-42ca-4d7f-9d95-f224e5f36a90",
42+
"uuid": "95ce4098-4e40-49f0-8661-0870614d5d78",
4343
"persistent": true,
44-
"insertionIndex": 3
44+
"insertionIndex": 2
4545
}

0 commit comments

Comments
 (0)