Skip to content

Commit 7db2ec0

Browse files
styner9karl-kcd
andauthored
add GHUser.suspendedAt (#1906)
Co-authored-by: 김 병구 <karl@kcd.co.kr>
1 parent af5bde7 commit 7db2ec0

File tree

6 files changed

+184
-0
lines changed

6 files changed

+184
-0
lines changed

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

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,9 @@ public class GHUser extends GHPerson {
3939
/** The ldap dn. */
4040
protected String ldap_dn;
4141

42+
/** The suspended_at */
43+
private String suspendedAt;
44+
4245
/**
4346
* Gets keys.
4447
*
@@ -264,6 +267,17 @@ public Optional<String> getLdapDn() throws IOException {
264267
return Optional.ofNullable(ldap_dn);
265268
}
266269

270+
/**
271+
* When was this user suspended?.
272+
*
273+
* @return updated date
274+
* @throws IOException
275+
* on error
276+
*/
277+
public Date getSuspendedAt() throws IOException {
278+
return GitHubClient.parseDate(suspendedAt);
279+
}
280+
267281
/**
268282
* Hash code.
269283
*

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

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import org.junit.Test;
44

55
import java.io.IOException;
6+
import java.time.Instant;
67
import java.util.*;
78

89
import static org.hamcrest.CoreMatchers.*;
@@ -227,4 +228,20 @@ public void verifyLdapdn() throws IOException {
227228
GHUser u = gitHub.getUser("kartikpatodi");
228229
assertThat(u.getLdapDn().orElse(""), not(emptyString()));
229230
}
231+
232+
/**
233+
* Verify suspended_at.
234+
*
235+
* @throws IOException
236+
* Signals that an I/O exception has occurred.
237+
*/
238+
@Test
239+
public void verifySuspendedAt() throws IOException {
240+
GHUser normal = gitHub.getUser("normal");
241+
assertThat(normal.getSuspendedAt(), is(nullValue()));
242+
243+
GHUser suspended = gitHub.getUser("suspended");
244+
Date suspendedAt = new Date(Instant.parse("2024-08-08T00:00:00Z").toEpochMilli());
245+
assertThat(suspended.getSuspendedAt(), equalTo(suspendedAt));
246+
}
230247
}
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
{
2+
"login": "kartikpatodi",
3+
"id": 23272937,
4+
"node_id": "MDQ6VXNlcjIzMjcyOTM3",
5+
"avatar_url": "https://avatars.githubusercontent.com/u/23272937?v=4",
6+
"gravatar_id": "",
7+
"url": "https://api.github.com/users/kartikpatodi",
8+
"html_url": "https://github.com/kartikpatodi",
9+
"followers_url": "https://api.github.com/users/kartikpatodi/followers",
10+
"following_url": "https://api.github.com/users/kartikpatodi/following{/other_user}",
11+
"gists_url": "https://api.github.com/users/kartikpatodi/gists{/gist_id}",
12+
"starred_url": "https://api.github.com/users/kartikpatodi/starred{/owner}{/repo}",
13+
"subscriptions_url": "https://api.github.com/users/kartikpatodi/subscriptions",
14+
"organizations_url": "https://api.github.com/users/kartikpatodi/orgs",
15+
"repos_url": "https://api.github.com/users/kartikpatodi/repos",
16+
"events_url": "https://api.github.com/users/kartikpatodi/events{/privacy}",
17+
"received_events_url": "https://api.github.com/users/kartikpatodi/received_events",
18+
"type": "User",
19+
"ldap_dn": "CN=kartikpatodi,OU=Users,DC=github,DC=com",
20+
"site_admin": false,
21+
"name": "Kartik Patodi",
22+
"company": null,
23+
"blog": "",
24+
"location": "Nimbahera, Rajasthan, India",
25+
"email": null,
26+
"hireable": null,
27+
"bio": null,
28+
"twitter_username": "kartikpatodi",
29+
"public_repos": 12,
30+
"public_gists": 0,
31+
"followers": 2,
32+
"following": 7,
33+
"created_at": "2016-11-05T05:01:41Z",
34+
"updated_at": "2022-02-24T13:54:34Z"
35+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
{
2+
"login": "kartikpatodi",
3+
"id": 23272937,
4+
"node_id": "MDQ6VXNlcjIzMjcyOTM3",
5+
"avatar_url": "https://avatars.githubusercontent.com/u/23272937?v=4",
6+
"gravatar_id": "",
7+
"url": "https://api.github.com/users/kartikpatodi",
8+
"html_url": "https://github.com/kartikpatodi",
9+
"followers_url": "https://api.github.com/users/kartikpatodi/followers",
10+
"following_url": "https://api.github.com/users/kartikpatodi/following{/other_user}",
11+
"gists_url": "https://api.github.com/users/kartikpatodi/gists{/gist_id}",
12+
"starred_url": "https://api.github.com/users/kartikpatodi/starred{/owner}{/repo}",
13+
"subscriptions_url": "https://api.github.com/users/kartikpatodi/subscriptions",
14+
"organizations_url": "https://api.github.com/users/kartikpatodi/orgs",
15+
"repos_url": "https://api.github.com/users/kartikpatodi/repos",
16+
"events_url": "https://api.github.com/users/kartikpatodi/events{/privacy}",
17+
"received_events_url": "https://api.github.com/users/kartikpatodi/received_events",
18+
"type": "User",
19+
"ldap_dn": "CN=kartikpatodi,OU=Users,DC=github,DC=com",
20+
"site_admin": false,
21+
"name": "Kartik Patodi",
22+
"company": null,
23+
"blog": "",
24+
"location": "Nimbahera, Rajasthan, India",
25+
"email": null,
26+
"hireable": null,
27+
"bio": null,
28+
"twitter_username": "kartikpatodi",
29+
"public_repos": 12,
30+
"public_gists": 0,
31+
"followers": 2,
32+
"following": 7,
33+
"created_at": "2016-11-05T05:01:41Z",
34+
"updated_at": "2022-02-24T13:54:34Z",
35+
"suspended_at": "2024-08-08T00:00:00Z"
36+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
{
2+
"name": "users_normal",
3+
"request": {
4+
"url": "/users/normal",
5+
"method": "GET",
6+
"headers": {
7+
"Accept": {
8+
"equalTo": "application/vnd.github+json"
9+
}
10+
}
11+
},
12+
"response": {
13+
"status": 200,
14+
"bodyFileName": "1-users_normal.json",
15+
"headers": {
16+
"server": "GitHub.com",
17+
"date": "Mon, 04 Apr 2022 19:10:00 GMT",
18+
"content-type": "application/json; charset=utf-8",
19+
"status": "200 OK",
20+
"cache-control": "public, max-age=60, s-maxage=60",
21+
"vary": "Accept, Accept-Encoding, Accept, X-Requested-With",
22+
"etag": "W/\"960f568b7a2dd1591a136e36748cc44e\"",
23+
"last-modified": "Thu, 24 Feb 2022 13:54:34 GMT",
24+
"x-github-media-type": "unknown, github.v3",
25+
"strict-transport-security": "max-age=31536000; includeSubdomains; preload",
26+
"x-frame-options": "deny",
27+
"x-content-type-options": "nosniff",
28+
"x-xss-protection": "1; mode=block",
29+
"referrer-policy": "origin-when-cross-origin, strict-origin-when-cross-origin",
30+
"content-security-policy": "default-src 'none'",
31+
"X-Ratelimit-Limit": "60",
32+
"X-Ratelimit-Remaining": "47",
33+
"X-Ratelimit-Reset": "1649100347",
34+
"Accept-Ranges": "bytes",
35+
"X-GitHub-Request-Id": "45F4:0D15:1B4EE4:373E4C:624B4288"
36+
}
37+
},
38+
"uuid": "39860a04-002b-45da-aae7-70c97031c79e",
39+
"persistent": true,
40+
"insertionIndex": 1
41+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
{
2+
"name": "users_suspended",
3+
"request": {
4+
"url": "/users/suspended",
5+
"method": "GET",
6+
"headers": {
7+
"Accept": {
8+
"equalTo": "application/vnd.github+json"
9+
}
10+
}
11+
},
12+
"response": {
13+
"status": 200,
14+
"bodyFileName": "1-users_suspended.json",
15+
"headers": {
16+
"server": "GitHub.com",
17+
"date": "Mon, 04 Apr 2022 19:10:00 GMT",
18+
"content-type": "application/json; charset=utf-8",
19+
"status": "200 OK",
20+
"cache-control": "public, max-age=60, s-maxage=60",
21+
"vary": "Accept, Accept-Encoding, Accept, X-Requested-With",
22+
"etag": "W/\"960f568b7a2dd1591a136e36748cc44e\"",
23+
"last-modified": "Thu, 24 Feb 2022 13:54:34 GMT",
24+
"x-github-media-type": "unknown, github.v3",
25+
"strict-transport-security": "max-age=31536000; includeSubdomains; preload",
26+
"x-frame-options": "deny",
27+
"x-content-type-options": "nosniff",
28+
"x-xss-protection": "1; mode=block",
29+
"referrer-policy": "origin-when-cross-origin, strict-origin-when-cross-origin",
30+
"content-security-policy": "default-src 'none'",
31+
"X-Ratelimit-Limit": "60",
32+
"X-Ratelimit-Remaining": "47",
33+
"X-Ratelimit-Reset": "1649100347",
34+
"Accept-Ranges": "bytes",
35+
"X-GitHub-Request-Id": "45F4:0D15:1B4EE4:373E4C:624B4288"
36+
}
37+
},
38+
"uuid": "39860a04-002b-45da-aae7-70c97031c79e",
39+
"persistent": true,
40+
"insertionIndex": 1
41+
}

0 commit comments

Comments
 (0)