From f14aa53aa4b8b248b0af447a2e3664c873b3ab91 Mon Sep 17 00:00:00 2001 From: Liam Newman Date: Tue, 17 Sep 2024 11:46:17 -0700 Subject: [PATCH 1/2] Test getEmails --- .../java/org/kohsuke/github/GHMyself.java | 4 +- src/test/java/org/kohsuke/github/AppTest.java | 13 +++++ .../testGetEmails/__files/1-user.json | 47 ++++++++++++++++++ .../testGetEmails/__files/2-user_emails.json | 14 ++++++ .../testGetEmails/mappings/1-user.json | 48 +++++++++++++++++++ .../testGetEmails/mappings/2-user_emails.json | 47 ++++++++++++++++++ 6 files changed, 171 insertions(+), 2 deletions(-) create mode 100644 src/test/resources/org/kohsuke/github/AppTest/wiremock/testGetEmails/__files/1-user.json create mode 100644 src/test/resources/org/kohsuke/github/AppTest/wiremock/testGetEmails/__files/2-user_emails.json create mode 100644 src/test/resources/org/kohsuke/github/AppTest/wiremock/testGetEmails/mappings/1-user.json create mode 100644 src/test/resources/org/kohsuke/github/AppTest/wiremock/testGetEmails/mappings/2-user_emails.json diff --git a/src/main/java/org/kohsuke/github/GHMyself.java b/src/main/java/org/kohsuke/github/GHMyself.java index 95f1bf397d..784f120b15 100644 --- a/src/main/java/org/kohsuke/github/GHMyself.java +++ b/src/main/java/org/kohsuke/github/GHMyself.java @@ -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 getEmails() throws IOException { - return listEmails().toList().stream().map(email -> email.getEmail()).collect(Collectors.toList()); + return getEmails2().stream().map(email -> email.getEmail()).collect(Collectors.toList()); } /** diff --git a/src/test/java/org/kohsuke/github/AppTest.java b/src/test/java/org/kohsuke/github/AppTest.java index ae22ea010e..9f73194b15 100755 --- a/src/test/java/org/kohsuke/github/AppTest.java +++ b/src/test/java/org/kohsuke/github/AppTest.java @@ -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 emails = gitHub.getMyself().getEmails(); + assertThat(emails.size(), equalTo(2)); + assertThat(emails, contains("bitwiseman@gmail.com", "bitwiseman@users.noreply.github.com")); + } + /** * Test app. * diff --git a/src/test/resources/org/kohsuke/github/AppTest/wiremock/testGetEmails/__files/1-user.json b/src/test/resources/org/kohsuke/github/AppTest/wiremock/testGetEmails/__files/1-user.json new file mode 100644 index 0000000000..9e0ff60437 --- /dev/null +++ b/src/test/resources/org/kohsuke/github/AppTest/wiremock/testGetEmails/__files/1-user.json @@ -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 + } +} \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/AppTest/wiremock/testGetEmails/__files/2-user_emails.json b/src/test/resources/org/kohsuke/github/AppTest/wiremock/testGetEmails/__files/2-user_emails.json new file mode 100644 index 0000000000..b5e4d9f5bc --- /dev/null +++ b/src/test/resources/org/kohsuke/github/AppTest/wiremock/testGetEmails/__files/2-user_emails.json @@ -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 + } +] \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/AppTest/wiremock/testGetEmails/mappings/1-user.json b/src/test/resources/org/kohsuke/github/AppTest/wiremock/testGetEmails/mappings/1-user.json new file mode 100644 index 0000000000..dedf690872 --- /dev/null +++ b/src/test/resources/org/kohsuke/github/AppTest/wiremock/testGetEmails/mappings/1-user.json @@ -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 +} \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/AppTest/wiremock/testGetEmails/mappings/2-user_emails.json b/src/test/resources/org/kohsuke/github/AppTest/wiremock/testGetEmails/mappings/2-user_emails.json new file mode 100644 index 0000000000..067a6a1d93 --- /dev/null +++ b/src/test/resources/org/kohsuke/github/AppTest/wiremock/testGetEmails/mappings/2-user_emails.json @@ -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 +} \ No newline at end of file From 4ed653778946ba5da38490ec37a4590d24e12032 Mon Sep 17 00:00:00 2001 From: Liam Newman Date: Tue, 17 Sep 2024 12:54:25 -0700 Subject: [PATCH 2/2] Update japicmp to 0.23.0 (#1946) --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index b06287181d..cc4035e8a9 100644 --- a/pom.xml +++ b/pom.xml @@ -381,7 +381,7 @@ com.github.siom79.japicmp japicmp-maven-plugin - 0.21.2 + 0.23.0