Skip to content

Commit

Permalink
Merge pull request #1945 from bitwiseman/feature/testGetEmails
Browse files Browse the repository at this point in the history
Test getEmails
  • Loading branch information
bitwiseman authored Sep 17, 2024
2 parents d9f8fff + f14aa53 commit 6e6c2c2
Show file tree
Hide file tree
Showing 6 changed files with 171 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/main/java/org/kohsuke/github/GHMyself.java
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,11 @@ public enum RepositoryListFilter {
* @return the emails
* @throws IOException
* the io exception
* @deprecated Use {@link #getEmails2()}
* @deprecated Use {@link #listEmails()}
*/
@Deprecated
public List<String> getEmails() throws IOException {
return listEmails().toList().stream().map(email -> email.getEmail()).collect(Collectors.toList());
return getEmails2().stream().map(email -> email.getEmail()).collect(Collectors.toList());
}

/**
Expand Down
13 changes: 13 additions & 0 deletions src/test/java/org/kohsuke/github/AppTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -1043,6 +1043,19 @@ public void testUserPublicEventApi() throws Exception {
}
}

/**
* Test getEmails.
*
* @throws IOException
* Signals that an I/O exception has occurred.
*/
@Test
public void testGetEmails() throws IOException {
List<String> emails = gitHub.getMyself().getEmails();
assertThat(emails.size(), equalTo(2));
assertThat(emails, contains("bitwiseman@gmail.com", "bitwiseman@users.noreply.github.com"));
}

/**
* Test app.
*
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
{
"login": "bitwiseman",
"id": 1958953,
"node_id": "MDQ6VXNlcjE5NTg5NTM=",
"avatar_url": "https://avatars.githubusercontent.com/u/1958953?v=4",
"gravatar_id": "",
"url": "https://api.github.com/users/bitwiseman",
"html_url": "https://github.com/bitwiseman",
"followers_url": "https://api.github.com/users/bitwiseman/followers",
"following_url": "https://api.github.com/users/bitwiseman/following{/other_user}",
"gists_url": "https://api.github.com/users/bitwiseman/gists{/gist_id}",
"starred_url": "https://api.github.com/users/bitwiseman/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/bitwiseman/subscriptions",
"organizations_url": "https://api.github.com/users/bitwiseman/orgs",
"repos_url": "https://api.github.com/users/bitwiseman/repos",
"events_url": "https://api.github.com/users/bitwiseman/events{/privacy}",
"received_events_url": "https://api.github.com/users/bitwiseman/received_events",
"type": "User",
"site_admin": false,
"name": "Liam Newman",
"company": null,
"blog": "",
"location": "Seattle, WA, USA",
"email": "bitwiseman@gmail.com",
"hireable": null,
"bio": null,
"twitter_username": "bitwiseman",
"notification_email": "bitwiseman@gmail.com",
"public_repos": 212,
"public_gists": 8,
"followers": 258,
"following": 12,
"created_at": "2012-07-11T20:38:33Z",
"updated_at": "2024-07-11T16:46:55Z",
"private_gists": 19,
"total_private_repos": 3,
"owned_private_repos": 3,
"disk_usage": 34051,
"collaborators": 4,
"two_factor_authentication": true,
"plan": {
"name": "free",
"space": 976562499,
"collaborators": 0,
"private_repos": 10000
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
[
{
"email": "bitwiseman@gmail.com",
"primary": true,
"verified": true,
"visibility": "public"
},
{
"email": "bitwiseman@users.noreply.github.com",
"primary": false,
"verified": true,
"visibility": null
}
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
{
"id": "ccd6f98f-7d6f-44a8-87ab-375e3a49d8f2",
"name": "user",
"request": {
"url": "/user",
"method": "GET",
"headers": {
"Accept": {
"equalTo": "application/vnd.github+json"
}
}
},
"response": {
"status": 200,
"bodyFileName": "1-user.json",
"headers": {
"Date": "Tue, 17 Sep 2024 18:41:52 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/\"a27242a466c3df86c7421f5da77e7af0282d7b11679db48547af0b315d2eb3c1\"",
"Last-Modified": "Thu, 11 Jul 2024 16:46:55 GMT",
"X-OAuth-Scopes": "read:user, repo, user:email",
"X-Accepted-OAuth-Scopes": "",
"github-authentication-token-expiration": "2024-10-17 18:38:10 UTC",
"X-GitHub-Media-Type": "github.v3; format=json",
"x-github-api-version-selected": "2022-11-28",
"X-RateLimit-Limit": "5000",
"X-RateLimit-Remaining": "4991",
"X-RateLimit-Reset": "1726601960",
"X-RateLimit-Used": "9",
"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'",
"Server": "github.com",
"X-GitHub-Request-Id": "6A1F:A6CDA:12AE1BE:12C74DE:66E9CD70"
}
},
"uuid": "ccd6f98f-7d6f-44a8-87ab-375e3a49d8f2",
"persistent": true,
"insertionIndex": 1
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
{
"id": "f17d4d94-f19c-425e-8133-f9f3ad2bafea",
"name": "user_emails",
"request": {
"url": "/user/emails",
"method": "GET",
"headers": {
"Accept": {
"equalTo": "application/vnd.github+json"
}
}
},
"response": {
"status": 200,
"bodyFileName": "2-user_emails.json",
"headers": {
"Date": "Tue, 17 Sep 2024 18:41:52 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/\"6e974566422ee9f8351add9d3450581b14045944d67d5b0d45d93816f7526d77\"",
"X-OAuth-Scopes": "read:user, repo, user:email",
"X-Accepted-OAuth-Scopes": "user, user:email",
"github-authentication-token-expiration": "2024-10-17 18:38:10 UTC",
"X-GitHub-Media-Type": "github.v3; format=json",
"x-github-api-version-selected": "2022-11-28",
"X-RateLimit-Limit": "5000",
"X-RateLimit-Remaining": "4989",
"X-RateLimit-Reset": "1726601960",
"X-RateLimit-Used": "11",
"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'",
"Server": "github.com",
"X-GitHub-Request-Id": "9EA1:32201C:118116E:119A333:66E9CD70"
}
},
"uuid": "f17d4d94-f19c-425e-8133-f9f3ad2bafea",
"persistent": true,
"insertionIndex": 2
}

0 comments on commit 6e6c2c2

Please sign in to comment.