diff --git a/src/main/java/org/kohsuke/github/AbuseLimitHandler.java b/src/main/java/org/kohsuke/github/AbuseLimitHandler.java index d6894adf9a..09084080a7 100644 --- a/src/main/java/org/kohsuke/github/AbuseLimitHandler.java +++ b/src/main/java/org/kohsuke/github/AbuseLimitHandler.java @@ -5,6 +5,9 @@ import java.io.IOException; import java.io.InterruptedIOException; import java.net.HttpURLConnection; +import java.time.ZonedDateTime; +import java.time.format.DateTimeFormatter; +import java.time.temporal.ChronoUnit; import javax.annotation.Nonnull; @@ -86,13 +89,6 @@ public void onError(IOException e, HttpURLConnection uc) throws IOException { } } - private long parseWaitTime(HttpURLConnection uc) { - String v = uc.getHeaderField("Retry-After"); - if (v == null) - return 60 * 1000; // can't tell, return 1 min - - return Math.max(1000, Long.parseLong(v) * 1000); - } }; /** @@ -105,4 +101,25 @@ public void onError(IOException e, HttpURLConnection uc) throws IOException { throw e; } }; + + /* + * Exposed for testability. Given an http response, find the retry-after header field and parse it as either a + * number or a date (the spec allows both). If no header is found, wait for a reasonably amount of time. + */ + long parseWaitTime(HttpURLConnection uc) { + String v = uc.getHeaderField("Retry-After"); + if (v == null) { + // can't tell, wait for unambiguously over one minute per GitHub guidance + return 61 * 1000; + } + + try { + return Math.max(1000, Long.parseLong(v) * 1000); + } catch (NumberFormatException nfe) { + // The retry-after header could be a number in seconds, or an http-date + ZonedDateTime zdt = ZonedDateTime.parse(v, DateTimeFormatter.RFC_1123_DATE_TIME); + return ChronoUnit.MILLIS.between(ZonedDateTime.now(), zdt); + } + } + } diff --git a/src/main/java/org/kohsuke/github/GitHubAbuseLimitHandler.java b/src/main/java/org/kohsuke/github/GitHubAbuseLimitHandler.java index 0555ead239..e769604525 100644 --- a/src/main/java/org/kohsuke/github/GitHubAbuseLimitHandler.java +++ b/src/main/java/org/kohsuke/github/GitHubAbuseLimitHandler.java @@ -29,7 +29,19 @@ public abstract class GitHubAbuseLimitHandler extends GitHubConnectorResponseErr */ @Override boolean isError(@Nonnull GitHubConnectorResponse connectorResponse) { - return isForbidden(connectorResponse) && hasRetryOrLimitHeader(connectorResponse); + return isTooManyRequests(connectorResponse) + || (isForbidden(connectorResponse) && hasRetryOrLimitHeader(connectorResponse)); + } + + /** + * Checks if the response status code is TOO_MANY_REQUESTS (429). + * + * @param connectorResponse + * the response from the GitHub connector + * @return true if the status code is TOO_MANY_REQUESTS + */ + private boolean isTooManyRequests(GitHubConnectorResponse connectorResponse) { + return connectorResponse.statusCode() == TOO_MANY_REQUESTS; } /** diff --git a/src/main/java/org/kohsuke/github/GitHubConnectorResponseErrorHandler.java b/src/main/java/org/kohsuke/github/GitHubConnectorResponseErrorHandler.java index e71e81921d..0a7f7fa9fb 100644 --- a/src/main/java/org/kohsuke/github/GitHubConnectorResponseErrorHandler.java +++ b/src/main/java/org/kohsuke/github/GitHubConnectorResponseErrorHandler.java @@ -23,6 +23,17 @@ */ abstract class GitHubConnectorResponseErrorHandler { + /** + * The HTTP 429 Too Many Requests response status code indicates the user has sent too many requests in a given + * amount of time ("rate limiting"). + * + * A Retry-After header might be included to this response indicating how long to wait before making a new request. + * + * Why is this hardcoded here? The HttpURLConnection class is missing the status codes above 415, so the constant + * needs to be sourced from elsewhere. + */ + public static final int TOO_MANY_REQUESTS = 429; + /** * Called to detect an error handled by this handler. * diff --git a/src/test/java/org/kohsuke/github/AbuseLimitHandlerTest.java b/src/test/java/org/kohsuke/github/AbuseLimitHandlerTest.java index 004ba305e9..5736146c4c 100644 --- a/src/test/java/org/kohsuke/github/AbuseLimitHandlerTest.java +++ b/src/test/java/org/kohsuke/github/AbuseLimitHandlerTest.java @@ -16,6 +16,7 @@ import static org.hamcrest.CoreMatchers.*; import static org.hamcrest.CoreMatchers.notNullValue; +import static org.hamcrest.Matchers.greaterThan; import static org.hamcrest.core.IsInstanceOf.instanceOf; // TODO: Auto-generated Javadoc @@ -98,22 +99,14 @@ public void onError(IOException e, HttpURLConnection uc) throws IOException { // getting an input stream in an error case should throw IOException ioEx = Assert.assertThrows(IOException.class, () -> uc.getInputStream()); - try (InputStream errorStream = uc.getErrorStream()) { - assertThat(errorStream, notNullValue()); - String errorString = IOUtils.toString(errorStream, StandardCharsets.UTF_8); - assertThat(errorString, containsString("Must have push access to repository")); - } + checkErrorMessageMatches(uc, "Must have push access to repository"); // calling again should still error ioEx = Assert.assertThrows(IOException.class, () -> uc.getInputStream()); // calling again on a GitHubConnectorResponse should yield the same value if (uc.toString().contains("GitHubConnectorResponseHttpUrlConnectionAdapter")) { - try (InputStream errorStream = uc.getErrorStream()) { - assertThat(errorStream, notNullValue()); - String errorString = IOUtils.toString(errorStream, StandardCharsets.UTF_8); - assertThat(errorString, containsString("Must have push access to repository")); - } + checkErrorMessageMatches(uc, "Must have push access to repository"); } else { try (InputStream errorStream = uc.getErrorStream()) { assertThat(errorStream, notNullValue()); @@ -126,7 +119,7 @@ public void onError(IOException e, HttpURLConnection uc) throws IOException { } assertThat(uc.getHeaderFields(), instanceOf(Map.class)); - assertThat(uc.getHeaderFields().size(), Matchers.greaterThan(25)); + assertThat(uc.getHeaderFields().size(), greaterThan(25)); assertThat(uc.getHeaderField("Status"), equalTo("403 Forbidden")); String key = uc.getHeaderFieldKey(1); @@ -349,16 +342,203 @@ public void onError(IOException e, HttpURLConnection uc) throws IOException { assertThat(uc.getContentType(), equalTo("application/json; charset=utf-8")); assertThat(uc.getContentLength(), equalTo(-1)); assertThat(uc.getHeaderFields(), instanceOf(Map.class)); - assertThat(uc.getHeaderFields().size(), Matchers.greaterThan(25)); + assertThat(uc.getHeaderFields().size(), greaterThan(25)); assertThat(uc.getHeaderField("Status"), equalTo("403 Forbidden")); - try (InputStream errorStream = uc.getErrorStream()) { - assertThat(errorStream, notNullValue()); - String errorString = IOUtils.toString(errorStream, StandardCharsets.UTF_8); - assertThat(errorString, - containsString( - "You have exceeded a secondary rate limit. Please wait a few minutes before you try again")); - } + checkErrorMessageMatches(uc, + "You have exceeded a secondary rate limit. Please wait a few minutes before you try again"); + AbuseLimitHandler.FAIL.onError(e, uc); + } + }) + .build(); + + gitHub.getMyself(); + assertThat(mockGitHub.getRequestCount(), equalTo(1)); + try { + getTempRepository(); + fail(); + } catch (Exception e) { + assertThat(e, instanceOf(HttpException.class)); + assertThat(e.getMessage(), equalTo("Abuse limit reached")); + } + assertThat(mockGitHub.getRequestCount(), equalTo(2)); + } + + /** + * This is making an assertion about the behaviour of the mock, so it's useful for making sure we're on the right + * mock, but should not be used to validate assumptions about the behaviour of the actual GitHub API. + */ + private static void checkErrorMessageMatches(HttpURLConnection uc, String substring) throws IOException { + try (InputStream errorStream = uc.getErrorStream()) { + assertThat(errorStream, notNullValue()); + String errorString = IOUtils.toString(errorStream, StandardCharsets.UTF_8); + assertThat(errorString, containsString(substring)); + } + } + + /** + * Tests the behavior of the GitHub API client when the abuse limit handler is set to WAIT then the handler waits + * appropriately when secondary rate limits are encountered. + * + * @throws Exception + * if any error occurs during the test execution. + */ + @Test + public void testHandler_Wait_Secondary_Limits_Too_Many_Requests() throws Exception { + // Customized response that templates the date to keep things working + snapshotNotAllowed(); + final HttpURLConnection[] savedConnection = new HttpURLConnection[1]; + gitHub = getGitHubBuilder().withEndpoint(mockGitHub.apiServer().baseUrl()) + .withAbuseLimitHandler(new AbuseLimitHandler() { + /** + * Overriding method because the actual method will wait for one minute causing slowness in unit + * tests + */ + @Override + public void onError(IOException e, HttpURLConnection uc) throws IOException { + savedConnection[0] = uc; + // Verify the test data is what we expected it to be for this test case + assertThat(uc.getDate(), Matchers.greaterThanOrEqualTo(new Date().getTime() - 10000)); + assertThat(uc.getExpiration(), equalTo(0L)); + assertThat(uc.getIfModifiedSince(), equalTo(0L)); + assertThat(uc.getLastModified(), equalTo(1581014017000L)); + assertThat(uc.getRequestMethod(), equalTo("GET")); + assertThat(uc.getResponseCode(), equalTo(429)); + assertThat(uc.getResponseMessage(), containsString("Many")); + assertThat(uc.getURL().toString(), + endsWith( + "/repos/hub4j-test-org/temp-testHandler_Wait_Secondary_Limits_Too_Many_Requests")); + assertThat(uc.getContentLength(), equalTo(-1)); + assertThat(uc.getHeaderFields(), instanceOf(Map.class)); + assertThat(uc.getHeaderField("Status"), equalTo("429 Too Many Requests")); + assertThat(uc.getHeaderField("Retry-After"), equalTo("42")); + + checkErrorMessageMatches(uc, + "You have exceeded a secondary rate limit. Please wait a few minutes before you try again"); + // Because we've overridden onError to bypass the wait, we don't cover the wait calculation + // logic + // Manually invoke it to make sure it's what we intended + long waitTime = parseWaitTime(uc); + assertThat(waitTime, equalTo(42 * 1000l)); + + AbuseLimitHandler.FAIL.onError(e, uc); + } + }) + .build(); + + gitHub.getMyself(); + assertThat(mockGitHub.getRequestCount(), equalTo(1)); + try { + getTempRepository(); + fail(); + } catch (Exception e) { + assertThat(e, instanceOf(HttpException.class)); + assertThat(e.getMessage(), equalTo("Abuse limit reached")); + } + assertThat(mockGitHub.getRequestCount(), equalTo(2)); + } + + /** + * Tests the behavior of the GitHub API client when the abuse limit handler with a date retry. + * + * @throws Exception + * if any error occurs during the test execution. + */ + @Test + public void testHandler_Wait_Secondary_Limits_Too_Many_Requests_Date_Retry_After() throws Exception { + // Customized response that templates the date to keep things working + snapshotNotAllowed(); + final HttpURLConnection[] savedConnection = new HttpURLConnection[1]; + gitHub = getGitHubBuilder().withEndpoint(mockGitHub.apiServer().baseUrl()) + .withAbuseLimitHandler(new AbuseLimitHandler() { + /** + * Overriding method because the actual method will wait for one minute causing slowness in unit + * tests + */ + @Override + public void onError(IOException e, HttpURLConnection uc) throws IOException { + savedConnection[0] = uc; + // Verify the test data is what we expected it to be for this test case + assertThat(uc.getRequestMethod(), equalTo("GET")); + assertThat(uc.getResponseCode(), equalTo(429)); + assertThat(uc.getResponseMessage(), containsString("Many")); + assertThat(uc.getURL().toString(), + endsWith( + "/repos/hub4j-test-org/temp-testHandler_Wait_Secondary_Limits_Too_Many_Requests_Date_Retry_After")); + assertThat(uc.getContentLength(), equalTo(-1)); + assertThat(uc.getHeaderField("Status"), equalTo("429 Too Many Requests")); + assertThat(uc.getHeaderField("Retry-After"), startsWith("Mon")); + + checkErrorMessageMatches(uc, + "You have exceeded a secondary rate limit. Please wait a few minutes before you try again"); + + // Because we've overridden onError to bypass the wait, we don't cover the wait calculation + // logic + // Manually invoke it to make sure it's what we intended + long waitTime = parseWaitTime(uc); + // The exact value here will depend on when the test is run, but it should be positive, and huge + assertThat(waitTime, greaterThan(1000 * 1000l)); + + AbuseLimitHandler.FAIL.onError(e, uc); + } + }) + .build(); + + gitHub.getMyself(); + assertThat(mockGitHub.getRequestCount(), equalTo(1)); + try { + getTempRepository(); + fail(); + } catch (Exception e) { + assertThat(e, instanceOf(HttpException.class)); + assertThat(e.getMessage(), equalTo("Abuse limit reached")); + } + assertThat(mockGitHub.getRequestCount(), equalTo(2)); + } + + /** + * Tests the behavior of the GitHub API client when the abuse limit handler with a no retry after header. + * + * @throws Exception + * if any error occurs during the test execution. + */ + @Test + public void testHandler_Wait_Secondary_Limits_Too_Many_Requests_No_Retry_After() throws Exception { + // Customized response that templates the date to keep things working + snapshotNotAllowed(); + final HttpURLConnection[] savedConnection = new HttpURLConnection[1]; + gitHub = getGitHubBuilder().withEndpoint(mockGitHub.apiServer().baseUrl()) + .withAbuseLimitHandler(new AbuseLimitHandler() { + /** + * Overriding method because the actual method will wait for one minute causing slowness in unit + * tests + */ + @Override + public void onError(IOException e, HttpURLConnection uc) throws IOException { + savedConnection[0] = uc; + // Verify the test data is what we expected it to be for this test case + assertThat(uc.getRequestMethod(), equalTo("GET")); + assertThat(uc.getResponseCode(), equalTo(429)); + assertThat(uc.getResponseMessage(), containsString("Many")); + assertThat(uc.getURL().toString(), + endsWith( + "/repos/hub4j-test-org/temp-testHandler_Wait_Secondary_Limits_Too_Many_Requests_No_Retry_After")); + assertThat(uc.getContentEncoding(), nullValue()); + assertThat(uc.getContentType(), equalTo("application/json; charset=utf-8")); + assertThat(uc.getContentLength(), equalTo(-1)); + assertThat(uc.getHeaderFields(), instanceOf(Map.class)); + assertThat(uc.getHeaderField("Status"), equalTo("429 Too Many Requests")); + assertThat(uc.getHeaderField("Retry-After"), nullValue()); + + checkErrorMessageMatches(uc, + "You have exceeded a secondary rate limit. Please wait a few minutes before you try again"); + + // Because we've overridden onError to bypass the wait, we don't cover the wait calculation + // logic + // Manually invoke it to make sure it's what we intended + long waitTime = parseWaitTime(uc); + assertThat(waitTime, greaterThan(60000l)); + AbuseLimitHandler.FAIL.onError(e, uc); } }) diff --git a/src/test/resources/org/kohsuke/github/AbuseLimitHandlerTest/wiremock/testHandler_Wait_Secondary_Limits_Too_Many_Requests/__files/1-user.json b/src/test/resources/org/kohsuke/github/AbuseLimitHandlerTest/wiremock/testHandler_Wait_Secondary_Limits_Too_Many_Requests/__files/1-user.json new file mode 100644 index 0000000000..467313f149 --- /dev/null +++ b/src/test/resources/org/kohsuke/github/AbuseLimitHandlerTest/wiremock/testHandler_Wait_Secondary_Limits_Too_Many_Requests/__files/1-user.json @@ -0,0 +1,45 @@ +{ + "login": "bitwiseman", + "id": 1958953, + "node_id": "MDQ6VXNlcjE5NTg5NTM=", + "avatar_url": "https://avatars3.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": "Cloudbees, Inc.", + "blog": "", + "location": "Seattle, WA, USA", + "email": "bitwiseman@gmail.com", + "hireable": null, + "bio": "https://twitter.com/bitwiseman", + "public_repos": 181, + "public_gists": 7, + "followers": 146, + "following": 9, + "created_at": "2012-07-11T20:38:33Z", + "updated_at": "2020-02-06T17:29:39Z", + "private_gists": 8, + "total_private_repos": 10, + "owned_private_repos": 0, + "disk_usage": 33697, + "collaborators": 0, + "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/AbuseLimitHandlerTest/wiremock/testHandler_Wait_Secondary_Limits_Too_Many_Requests/__files/3-r_h_t_fail.json b/src/test/resources/org/kohsuke/github/AbuseLimitHandlerTest/wiremock/testHandler_Wait_Secondary_Limits_Too_Many_Requests/__files/3-r_h_t_fail.json new file mode 100644 index 0000000000..4cb1b145af --- /dev/null +++ b/src/test/resources/org/kohsuke/github/AbuseLimitHandlerTest/wiremock/testHandler_Wait_Secondary_Limits_Too_Many_Requests/__files/3-r_h_t_fail.json @@ -0,0 +1,126 @@ +{ + "id": 238757196, + "node_id": "MDEwOlJlcG9zaXRvcnkyMzg3NTcxOTY=", + "name": "temp-testHandler_Wait_Secondary_Limits_Too_Many_Requests", + "full_name": "hub4j-test-org/temp-testHandler_Wait_Secondary_Limits_Too_Many_Requests", + "private": false, + "owner": { + "login": "hub4j-test-org", + "id": 7544739, + "node_id": "MDEyOk9yZ2FuaXphdGlvbjc1NDQ3Mzk=", + "avatar_url": "https://avatars3.githubusercontent.com/u/7544739?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/hub4j-test-org", + "html_url": "https://github.com/hub4j-test-org", + "followers_url": "https://api.github.com/users/hub4j-test-org/followers", + "following_url": "https://api.github.com/users/hub4j-test-org/following{/other_user}", + "gists_url": "https://api.github.com/users/hub4j-test-org/gists{/gist_id}", + "starred_url": "https://api.github.com/users/hub4j-test-org/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/hub4j-test-org/subscriptions", + "organizations_url": "https://api.github.com/users/hub4j-test-org/orgs", + "repos_url": "https://api.github.com/users/hub4j-test-org/repos", + "events_url": "https://api.github.com/users/hub4j-test-org/events{/privacy}", + "received_events_url": "https://api.github.com/users/hub4j-test-org/received_events", + "type": "Organization", + "site_admin": false + }, + "html_url": "https://github.com/hub4j-test-org/temp-testHandler_Wait_Secondary_Limits_Too_Many_Requests", + "description": "A test repository for testing the github-api project: temp-testHandler_Wait_Secondary_Limits_Too_Many_Requests", + "fork": false, + "url": "https://api.github.com/repos/hub4j-test-org/temp-testHandler_Wait_Secondary_Limits_Too_Many_Requests", + "forks_url": "https://api.github.com/repos/hub4j-test-org/temp-testHandler_Wait_Secondary_Limits_Too_Many_Requests/forks", + "keys_url": "https://api.github.com/repos/hub4j-test-org/temp-testHandler_Wait_Secondary_Limits_Too_Many_Requests/keys{/key_id}", + "collaborators_url": "https://api.github.com/repos/hub4j-test-org/temp-testHandler_Wait_Secondary_Limits_Too_Many_Requests/collaborators{/collaborator}", + "teams_url": "https://api.github.com/repos/hub4j-test-org/temp-testHandler_Wait_Secondary_Limits_Too_Many_Requests/teams", + "hooks_url": "https://api.github.com/repos/hub4j-test-org/temp-testHandler_Wait_Secondary_Limits_Too_Many_Requests/hooks", + "issue_events_url": "https://api.github.com/repos/hub4j-test-org/temp-testHandler_Wait_Secondary_Limits_Too_Many_Requests/issues/events{/number}", + "events_url": "https://api.github.com/repos/hub4j-test-org/temp-testHandler_Wait_Secondary_Limits_Too_Many_Requests/events", + "assignees_url": "https://api.github.com/repos/hub4j-test-org/temp-testHandler_Wait_Secondary_Limits_Too_Many_Requests/assignees{/user}", + "branches_url": "https://api.github.com/repos/hub4j-test-org/temp-testHandler_Wait_Secondary_Limits_Too_Many_Requests/branches{/branch}", + "tags_url": "https://api.github.com/repos/hub4j-test-org/temp-testHandler_Wait_Secondary_Limits_Too_Many_Requests/tags", + "blobs_url": "https://api.github.com/repos/hub4j-test-org/temp-testHandler_Wait_Secondary_Limits_Too_Many_Requests/git/blobs{/sha}", + "git_tags_url": "https://api.github.com/repos/hub4j-test-org/temp-testHandler_Wait_Secondary_Limits_Too_Many_Requests/git/tags{/sha}", + "git_refs_url": "https://api.github.com/repos/hub4j-test-org/temp-testHandler_Wait_Secondary_Limits_Too_Many_Requests/git/refs{/sha}", + "trees_url": "https://api.github.com/repos/hub4j-test-org/temp-testHandler_Wait_Secondary_Limits_Too_Many_Requests/git/trees{/sha}", + "statuses_url": "https://api.github.com/repos/hub4j-test-org/temp-testHandler_Wait_Secondary_Limits_Too_Many_Requests/statuses/{sha}", + "languages_url": "https://api.github.com/repos/hub4j-test-org/temp-testHandler_Wait_Secondary_Limits_Too_Many_Requests/languages", + "stargazers_url": "https://api.github.com/repos/hub4j-test-org/temp-testHandler_Wait_Secondary_Limits_Too_Many_Requests/stargazers", + "contributors_url": "https://api.github.com/repos/hub4j-test-org/temp-testHandler_Wait_Secondary_Limits_Too_Many_Requests/contributors", + "subscribers_url": "https://api.github.com/repos/hub4j-test-org/temp-testHandler_Wait_Secondary_Limits_Too_Many_Requests/subscribers", + "subscription_url": "https://api.github.com/repos/hub4j-test-org/temp-testHandler_Wait_Secondary_Limits_Too_Many_Requests/subscription", + "commits_url": "https://api.github.com/repos/hub4j-test-org/temp-testHandler_Wait_Secondary_Limits_Too_Many_Requests/commits{/sha}", + "git_commits_url": "https://api.github.com/repos/hub4j-test-org/temp-testHandler_Wait_Secondary_Limits_Too_Many_Requests/git/commits{/sha}", + "comments_url": "https://api.github.com/repos/hub4j-test-org/temp-testHandler_Wait_Secondary_Limits_Too_Many_Requests/comments{/number}", + "issue_comment_url": "https://api.github.com/repos/hub4j-test-org/temp-testHandler_Wait_Secondary_Limits_Too_Many_Requests/issues/comments{/number}", + "contents_url": "https://api.github.com/repos/hub4j-test-org/temp-testHandler_Wait_Secondary_Limits_Too_Many_Requests/contents/{+path}", + "compare_url": "https://api.github.com/repos/hub4j-test-org/temp-testHandler_Wait_Secondary_Limits_Too_Many_Requests/compare/{base}...{head}", + "merges_url": "https://api.github.com/repos/hub4j-test-org/temp-testHandler_Wait_Secondary_Limits_Too_Many_Requests/merges", + "archive_url": "https://api.github.com/repos/hub4j-test-org/temp-testHandler_Wait_Secondary_Limits_Too_Many_Requests/{archive_format}{/ref}", + "downloads_url": "https://api.github.com/repos/hub4j-test-org/temp-testHandler_Wait_Secondary_Limits_Too_Many_Requests/downloads", + "issues_url": "https://api.github.com/repos/hub4j-test-org/temp-testHandler_Wait_Secondary_Limits_Too_Many_Requests/issues{/number}", + "pulls_url": "https://api.github.com/repos/hub4j-test-org/temp-testHandler_Wait_Secondary_Limits_Too_Many_Requests/pulls{/number}", + "milestones_url": "https://api.github.com/repos/hub4j-test-org/temp-testHandler_Wait_Secondary_Limits_Too_Many_Requests/milestones{/number}", + "notifications_url": "https://api.github.com/repos/hub4j-test-org/temp-testHandler_Wait_Secondary_Limits_Too_Many_Requests/notifications{?since,all,participating}", + "labels_url": "https://api.github.com/repos/hub4j-test-org/temp-testHandler_Wait_Secondary_Limits_Too_Many_Requests/labels{/name}", + "releases_url": "https://api.github.com/repos/hub4j-test-org/temp-testHandler_Wait_Secondary_Limits_Too_Many_Requests/releases{/id}", + "deployments_url": "https://api.github.com/repos/hub4j-test-org/temp-testHandler_Wait_Secondary_Limits_Too_Many_Requests/deployments", + "created_at": "2020-02-06T18:33:39Z", + "updated_at": "2020-02-06T18:33:43Z", + "pushed_at": "2020-02-06T18:33:41Z", + "git_url": "git://github.com/hub4j-test-org/temp-testHandler_Wait_Secondary_Limits_Too_Many_Requests.git", + "ssh_url": "git@github.com:hub4j-test-org/temp-testHandler_Wait_Secondary_Limits_Too_Many_Requests.git", + "clone_url": "https://github.com/hub4j-test-org/temp-testHandler_Wait_Secondary_Limits_Too_Many_Requests.git", + "svn_url": "https://github.com/hub4j-test-org/temp-testHandler_Wait_Secondary_Limits_Too_Many_Requests", + "homepage": "http://github-api.kohsuke.org/", + "size": 0, + "stargazers_count": 0, + "watchers_count": 0, + "language": null, + "has_issues": true, + "has_projects": true, + "has_downloads": true, + "has_wiki": true, + "has_pages": false, + "forks_count": 0, + "mirror_url": null, + "archived": false, + "disabled": false, + "open_issues_count": 0, + "license": null, + "forks": 0, + "open_issues": 0, + "watchers": 0, + "default_branch": "main", + "permissions": { + "admin": true, + "push": true, + "pull": true + }, + "temp_clone_token": "", + "allow_squash_merge": true, + "allow_merge_commit": true, + "allow_rebase_merge": true, + "delete_branch_on_merge": false, + "organization": { + "login": "hub4j-test-org", + "id": 7544739, + "node_id": "MDEyOk9yZ2FuaXphdGlvbjc1NDQ3Mzk=", + "avatar_url": "https://avatars3.githubusercontent.com/u/7544739?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/hub4j-test-org", + "html_url": "https://github.com/hub4j-test-org", + "followers_url": "https://api.github.com/users/hub4j-test-org/followers", + "following_url": "https://api.github.com/users/hub4j-test-org/following{/other_user}", + "gists_url": "https://api.github.com/users/hub4j-test-org/gists{/gist_id}", + "starred_url": "https://api.github.com/users/hub4j-test-org/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/hub4j-test-org/subscriptions", + "organizations_url": "https://api.github.com/users/hub4j-test-org/orgs", + "repos_url": "https://api.github.com/users/hub4j-test-org/repos", + "events_url": "https://api.github.com/users/hub4j-test-org/events{/privacy}", + "received_events_url": "https://api.github.com/users/hub4j-test-org/received_events", + "type": "Organization", + "site_admin": false + }, + "network_count": 0, + "subscribers_count": 6 +} \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/AbuseLimitHandlerTest/wiremock/testHandler_Wait_Secondary_Limits_Too_Many_Requests/mappings/1-user.json b/src/test/resources/org/kohsuke/github/AbuseLimitHandlerTest/wiremock/testHandler_Wait_Secondary_Limits_Too_Many_Requests/mappings/1-user.json new file mode 100644 index 0000000000..4133546851 --- /dev/null +++ b/src/test/resources/org/kohsuke/github/AbuseLimitHandlerTest/wiremock/testHandler_Wait_Secondary_Limits_Too_Many_Requests/mappings/1-user.json @@ -0,0 +1,48 @@ +{ + "id": "a60baf84-5b5c-4f86-af3d-cab0d609c7b2", + "name": "user", + "request": { + "url": "/user", + "method": "GET", + "headers": { + "Accept": { + "equalTo": "application/vnd.github+json" + } + } + }, + "response": { + "status": 200, + "bodyFileName": "1-user.json", + "headers": { + "Date": "{{now timezone='GMT' format='EEE, dd MMM yyyy HH:mm:ss z'}}", + "Content-Type": "application/json; charset=utf-8", + "Server": "GitHub.com", + "Status": "200 OK", + "X-RateLimit-Limit": "5000", + "X-RateLimit-Remaining": "4930", + "X-RateLimit-Reset": "{{now offset='3 seconds' format='unix'}}", + "Cache-Control": "private, max-age=60, s-maxage=60", + "Vary": [ + "Accept, Authorization, Cookie, X-GitHub-OTP", + "Accept-Encoding" + ], + "ETag": "W/\"1cb30f031c67c499473b3aad01c7f7a5\"", + "Last-Modified": "Thu, 06 Feb 2020 17:29:39 GMT", + "X-OAuth-Scopes": "admin:org, admin:org_hook, admin:public_key, admin:repo_hook, delete_repo, gist, notifications, repo, user, write:discussion", + "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": "CC37:2605:3F884:4E941:5E3C5BFC" + } + }, + "uuid": "a60baf84-5b5c-4f86-af3d-cab0d609c7b2", + "persistent": true, + "insertionIndex": 1 +} \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/AbuseLimitHandlerTest/wiremock/testHandler_Wait_Secondary_Limits_Too_Many_Requests/mappings/2-r_h_t_fail.json b/src/test/resources/org/kohsuke/github/AbuseLimitHandlerTest/wiremock/testHandler_Wait_Secondary_Limits_Too_Many_Requests/mappings/2-r_h_t_fail.json new file mode 100644 index 0000000000..d1127227f9 --- /dev/null +++ b/src/test/resources/org/kohsuke/github/AbuseLimitHandlerTest/wiremock/testHandler_Wait_Secondary_Limits_Too_Many_Requests/mappings/2-r_h_t_fail.json @@ -0,0 +1,52 @@ +{ + "id": "79fb1092-8bf3-4274-bc8e-ca126c9d9261", + "name": "repos_hub4j-test-org_temp-testHandler_Wait_Secondary_Limits_Too_Many_Requests", + "request": { + "url": "/repos/hub4j-test-org/temp-testHandler_Wait_Secondary_Limits_Too_Many_Requests", + "method": "GET", + "headers": { + "Accept": { + "equalTo": "application/vnd.github+json" + } + } + }, + "response": { + "status": 403, + "body": "{\"message\":\"You have exceeded a secondary rate limit. Please wait a few minutes before you try again\"}", + "headers": { + "Date": "{{now timezone='GMT' format='EEE, dd MMM yyyy HH:mm:ss z'}}", + "Content-Type": "application/json; charset=utf-8", + "Server": "GitHub.com", + "Status": "403 Forbidden", + "gh-limited-by": "search-elapsed-time-shared-grouped", + "X-RateLimit-Limit": "5000", + "X-RateLimit-Remaining": "4000", + "X-RateLimit-Reset": "{{testStartDate offset='3 seconds' format='unix'}}", + "Cache-Control": "private, max-age=60, s-maxage=60", + "Vary": [ + "Accept, Authorization, Cookie, X-GitHub-OTP", + "Accept-Encoding" + ], + "ETag": "W/\"7ff3c96399f7ddf6129622d675ca9935\"", + "Last-Modified": "Thu, 06 Feb 2020 18:33:37 GMT", + "X-OAuth-Scopes": "admin:org, admin:org_hook, admin:public_key, admin:repo_hook, delete_repo, gist, notifications, repo, user, write:discussion", + "X-Accepted-OAuth-Scopes": "repo", + "X-GitHub-Media-Type": "unknown, github.v3", + "Access-Control-Expose-Headers": "ETag, Link, Location, gh-limited-by, 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": "CC37:2605:3F982:4E949:5E3C5BFC" + } + }, + "uuid": "79fb1092-8bf3-4274-bc8e-ca126c9d9261", + "persistent": true, + "scenarioName": "scenario-1-repos-hub4j-test-org-temp-testHandler_Wait_Secondary_Limits_Too_Many_Requests", + "requiredScenarioState": "Started", + "newScenarioState": "scenario-1-repos-hub4j-test-org-temp-testHandler_Wait_Secondary_Limits_Too_Many_Requests-2", + "insertionIndex": 2 +} \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/AbuseLimitHandlerTest/wiremock/testHandler_Wait_Secondary_Limits_Too_Many_Requests/mappings/3-r_h_t_fail.json b/src/test/resources/org/kohsuke/github/AbuseLimitHandlerTest/wiremock/testHandler_Wait_Secondary_Limits_Too_Many_Requests/mappings/3-r_h_t_fail.json new file mode 100644 index 0000000000..a2dc66b59d --- /dev/null +++ b/src/test/resources/org/kohsuke/github/AbuseLimitHandlerTest/wiremock/testHandler_Wait_Secondary_Limits_Too_Many_Requests/mappings/3-r_h_t_fail.json @@ -0,0 +1,49 @@ +{ + "id": "79fb1092-8bf3-4274-bc8e-ca126c9d9261", + "name": "repos_hub4j-test-org_temp-testHandler_Wait_Secondary_Limits_Too_Many_Requests", + "request": { + "url": "/repos/hub4j-test-org/temp-testHandler_Wait_Secondary_Limits_Too_Many_Requests", + "method": "GET", + "headers": { + "Accept": { + "equalTo": "application/vnd.github+json" + } + } + }, + "response": { + "status": 429, + "body": "{\"message\":\"You have exceeded a secondary rate limit. Please wait a few minutes before you try again\"}", + "headers": { + "Date": "{{now timezone='GMT' format='EEE, dd MMM yyyy HH:mm:ss z'}}", + "Content-Type": "application/json; charset=utf-8", + "Server": "GitHub.com", + "Status": "429 Too Many Requests", + "Retry-After": "42", + "Cache-Control": "private, max-age=60, s-maxage=60", + "Vary": [ + "Accept, Authorization, Cookie, X-GitHub-OTP", + "Accept-Encoding" + ], + "ETag": "W/\"7ff3c96399f7ddf6129622d675ca9935\"", + "Last-Modified": "Thu, 06 Feb 2020 18:33:37 GMT", + "X-OAuth-Scopes": "admin:org, admin:org_hook, admin:public_key, admin:repo_hook, delete_repo, gist, notifications, repo, user, write:discussion", + "X-Accepted-OAuth-Scopes": "repo", + "X-GitHub-Media-Type": "unknown, github.v3", + "Access-Control-Expose-Headers": "ETag, Link, Location, gh-limited-by, 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": "CC37:2605:3F982:4E949:5E3C5BFC" + } + }, + "uuid": "79fb1092-8bf3-4274-bc8e-ca126c9d9261", + "persistent": true, + "scenarioName": "scenario-4-repos-hub4j-test-org-temp-testHandler_Wait_Secondary_Limits_Too_Many_Requests", + "requiredScenarioState": "Started", + "newScenarioState": "scenario-4-repos-hub4j-test-org-temp-testHandler_Wait_Secondary_Limits_Too_Many_Requests-2", + "insertionIndex": 2 +} \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/AbuseLimitHandlerTest/wiremock/testHandler_Wait_Secondary_Limits_Too_Many_Requests_Date_Retry_After/__files/1-user.json b/src/test/resources/org/kohsuke/github/AbuseLimitHandlerTest/wiremock/testHandler_Wait_Secondary_Limits_Too_Many_Requests_Date_Retry_After/__files/1-user.json new file mode 100644 index 0000000000..467313f149 --- /dev/null +++ b/src/test/resources/org/kohsuke/github/AbuseLimitHandlerTest/wiremock/testHandler_Wait_Secondary_Limits_Too_Many_Requests_Date_Retry_After/__files/1-user.json @@ -0,0 +1,45 @@ +{ + "login": "bitwiseman", + "id": 1958953, + "node_id": "MDQ6VXNlcjE5NTg5NTM=", + "avatar_url": "https://avatars3.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": "Cloudbees, Inc.", + "blog": "", + "location": "Seattle, WA, USA", + "email": "bitwiseman@gmail.com", + "hireable": null, + "bio": "https://twitter.com/bitwiseman", + "public_repos": 181, + "public_gists": 7, + "followers": 146, + "following": 9, + "created_at": "2012-07-11T20:38:33Z", + "updated_at": "2020-02-06T17:29:39Z", + "private_gists": 8, + "total_private_repos": 10, + "owned_private_repos": 0, + "disk_usage": 33697, + "collaborators": 0, + "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/AbuseLimitHandlerTest/wiremock/testHandler_Wait_Secondary_Limits_Too_Many_Requests_Date_Retry_After/__files/3-r_h_t_fail.json b/src/test/resources/org/kohsuke/github/AbuseLimitHandlerTest/wiremock/testHandler_Wait_Secondary_Limits_Too_Many_Requests_Date_Retry_After/__files/3-r_h_t_fail.json new file mode 100644 index 0000000000..5733e9a2d9 --- /dev/null +++ b/src/test/resources/org/kohsuke/github/AbuseLimitHandlerTest/wiremock/testHandler_Wait_Secondary_Limits_Too_Many_Requests_Date_Retry_After/__files/3-r_h_t_fail.json @@ -0,0 +1,126 @@ +{ + "id": 238757196, + "node_id": "MDEwOlJlcG9zaXRvcnkyMzg3NTcxOTY=", + "name": "temp-testHandler_Wait_Secondary_Limits_Too_Many_Requests_Date_Retry_After", + "full_name": "hub4j-test-org/temp-testHandler_Wait_Secondary_Limits_Too_Many_Requests_Date_Retry_After", + "private": false, + "owner": { + "login": "hub4j-test-org", + "id": 7544739, + "node_id": "MDEyOk9yZ2FuaXphdGlvbjc1NDQ3Mzk=", + "avatar_url": "https://avatars3.githubusercontent.com/u/7544739?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/hub4j-test-org", + "html_url": "https://github.com/hub4j-test-org", + "followers_url": "https://api.github.com/users/hub4j-test-org/followers", + "following_url": "https://api.github.com/users/hub4j-test-org/following{/other_user}", + "gists_url": "https://api.github.com/users/hub4j-test-org/gists{/gist_id}", + "starred_url": "https://api.github.com/users/hub4j-test-org/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/hub4j-test-org/subscriptions", + "organizations_url": "https://api.github.com/users/hub4j-test-org/orgs", + "repos_url": "https://api.github.com/users/hub4j-test-org/repos", + "events_url": "https://api.github.com/users/hub4j-test-org/events{/privacy}", + "received_events_url": "https://api.github.com/users/hub4j-test-org/received_events", + "type": "Organization", + "site_admin": false + }, + "html_url": "https://github.com/hub4j-test-org/temp-testHandler_Wait_Secondary_Limits_Too_Many_Requests_Date_Retry_After", + "description": "A test repository for testing the github-api project: temp-testHandler_Wait_Secondary_Limits_Too_Many_Requests_Date_Retry_After", + "fork": false, + "url": "https://api.github.com/repos/hub4j-test-org/temp-testHandler_Wait_Secondary_Limits_Too_Many_Requests_Date_Retry_After", + "forks_url": "https://api.github.com/repos/hub4j-test-org/temp-testHandler_Wait_Secondary_Limits_Too_Many_Requests_Date_Retry_After/forks", + "keys_url": "https://api.github.com/repos/hub4j-test-org/temp-testHandler_Wait_Secondary_Limits_Too_Many_Requests_Date_Retry_After/keys{/key_id}", + "collaborators_url": "https://api.github.com/repos/hub4j-test-org/temp-testHandler_Wait_Secondary_Limits_Too_Many_Requests_Date_Retry_After/collaborators{/collaborator}", + "teams_url": "https://api.github.com/repos/hub4j-test-org/temp-testHandler_Wait_Secondary_Limits_Too_Many_Requests_Date_Retry_After/teams", + "hooks_url": "https://api.github.com/repos/hub4j-test-org/temp-testHandler_Wait_Secondary_Limits_Too_Many_Requests_Date_Retry_After/hooks", + "issue_events_url": "https://api.github.com/repos/hub4j-test-org/temp-testHandler_Wait_Secondary_Limits_Too_Many_Requests_Date_Retry_After/issues/events{/number}", + "events_url": "https://api.github.com/repos/hub4j-test-org/temp-testHandler_Wait_Secondary_Limits_Too_Many_Requests_Date_Retry_After/events", + "assignees_url": "https://api.github.com/repos/hub4j-test-org/temp-testHandler_Wait_Secondary_Limits_Too_Many_Requests_Date_Retry_After/assignees{/user}", + "branches_url": "https://api.github.com/repos/hub4j-test-org/temp-testHandler_Wait_Secondary_Limits_Too_Many_Requests_Date_Retry_After/branches{/branch}", + "tags_url": "https://api.github.com/repos/hub4j-test-org/temp-testHandler_Wait_Secondary_Limits_Too_Many_Requests_Date_Retry_After/tags", + "blobs_url": "https://api.github.com/repos/hub4j-test-org/temp-testHandler_Wait_Secondary_Limits_Too_Many_Requests_Date_Retry_After/git/blobs{/sha}", + "git_tags_url": "https://api.github.com/repos/hub4j-test-org/temp-testHandler_Wait_Secondary_Limits_Too_Many_Requests_Date_Retry_After/git/tags{/sha}", + "git_refs_url": "https://api.github.com/repos/hub4j-test-org/temp-testHandler_Wait_Secondary_Limits_Too_Many_Requests_Date_Retry_After/git/refs{/sha}", + "trees_url": "https://api.github.com/repos/hub4j-test-org/temp-testHandler_Wait_Secondary_Limits_Too_Many_Requests_Date_Retry_After/git/trees{/sha}", + "statuses_url": "https://api.github.com/repos/hub4j-test-org/temp-testHandler_Wait_Secondary_Limits_Too_Many_Requests_Date_Retry_After/statuses/{sha}", + "languages_url": "https://api.github.com/repos/hub4j-test-org/temp-testHandler_Wait_Secondary_Limits_Too_Many_Requests_Date_Retry_After/languages", + "stargazers_url": "https://api.github.com/repos/hub4j-test-org/temp-testHandler_Wait_Secondary_Limits_Too_Many_Requests_Date_Retry_After/stargazers", + "contributors_url": "https://api.github.com/repos/hub4j-test-org/temp-testHandler_Wait_Secondary_Limits_Too_Many_Requests_Date_Retry_After/contributors", + "subscribers_url": "https://api.github.com/repos/hub4j-test-org/temp-testHandler_Wait_Secondary_Limits_Too_Many_Requests_Date_Retry_After/subscribers", + "subscription_url": "https://api.github.com/repos/hub4j-test-org/temp-testHandler_Wait_Secondary_Limits_Too_Many_Requests_Date_Retry_After/subscription", + "commits_url": "https://api.github.com/repos/hub4j-test-org/temp-testHandler_Wait_Secondary_Limits_Too_Many_Requests_Date_Retry_After/commits{/sha}", + "git_commits_url": "https://api.github.com/repos/hub4j-test-org/temp-testHandler_Wait_Secondary_Limits_Too_Many_Requests_Date_Retry_After/git/commits{/sha}", + "comments_url": "https://api.github.com/repos/hub4j-test-org/temp-testHandler_Wait_Secondary_Limits_Too_Many_Requests_Date_Retry_After/comments{/number}", + "issue_comment_url": "https://api.github.com/repos/hub4j-test-org/temp-testHandler_Wait_Secondary_Limits_Too_Many_Requests_Date_Retry_After/issues/comments{/number}", + "contents_url": "https://api.github.com/repos/hub4j-test-org/temp-testHandler_Wait_Secondary_Limits_Too_Many_Requests_Date_Retry_After/contents/{+path}", + "compare_url": "https://api.github.com/repos/hub4j-test-org/temp-testHandler_Wait_Secondary_Limits_Too_Many_Requests_Date_Retry_After/compare/{base}...{head}", + "merges_url": "https://api.github.com/repos/hub4j-test-org/temp-testHandler_Wait_Secondary_Limits_Too_Many_Requests_Date_Retry_After/merges", + "archive_url": "https://api.github.com/repos/hub4j-test-org/temp-testHandler_Wait_Secondary_Limits_Too_Many_Requests_Date_Retry_After/{archive_format}{/ref}", + "downloads_url": "https://api.github.com/repos/hub4j-test-org/temp-testHandler_Wait_Secondary_Limits_Too_Many_Requests_Date_Retry_After/downloads", + "issues_url": "https://api.github.com/repos/hub4j-test-org/temp-testHandler_Wait_Secondary_Limits_Too_Many_Requests_Date_Retry_After/issues{/number}", + "pulls_url": "https://api.github.com/repos/hub4j-test-org/temp-testHandler_Wait_Secondary_Limits_Too_Many_Requests_Date_Retry_After/pulls{/number}", + "milestones_url": "https://api.github.com/repos/hub4j-test-org/temp-testHandler_Wait_Secondary_Limits_Too_Many_Requests_Date_Retry_After/milestones{/number}", + "notifications_url": "https://api.github.com/repos/hub4j-test-org/temp-testHandler_Wait_Secondary_Limits_Too_Many_Requests_Date_Retry_After/notifications{?since,all,participating}", + "labels_url": "https://api.github.com/repos/hub4j-test-org/temp-testHandler_Wait_Secondary_Limits_Too_Many_Requests_Date_Retry_After/labels{/name}", + "releases_url": "https://api.github.com/repos/hub4j-test-org/temp-testHandler_Wait_Secondary_Limits_Too_Many_Requests_Date_Retry_After/releases{/id}", + "deployments_url": "https://api.github.com/repos/hub4j-test-org/temp-testHandler_Wait_Secondary_Limits_Too_Many_Requests_Date_Retry_After/deployments", + "created_at": "2020-02-06T18:33:39Z", + "updated_at": "2020-02-06T18:33:43Z", + "pushed_at": "2020-02-06T18:33:41Z", + "git_url": "git://github.com/hub4j-test-org/temp-testHandler_Wait_Secondary_Limits_Too_Many_Requests_Date_Retry_After.git", + "ssh_url": "git@github.com:hub4j-test-org/temp-testHandler_Wait_Secondary_Limits_Too_Many_Requests_Date_Retry_After.git", + "clone_url": "https://github.com/hub4j-test-org/temp-testHandler_Wait_Secondary_Limits_Too_Many_Requests_Date_Retry_After.git", + "svn_url": "https://github.com/hub4j-test-org/temp-testHandler_Wait_Secondary_Limits_Too_Many_Requests_Date_Retry_After", + "homepage": "http://github-api.kohsuke.org/", + "size": 0, + "stargazers_count": 0, + "watchers_count": 0, + "language": null, + "has_issues": true, + "has_projects": true, + "has_downloads": true, + "has_wiki": true, + "has_pages": false, + "forks_count": 0, + "mirror_url": null, + "archived": false, + "disabled": false, + "open_issues_count": 0, + "license": null, + "forks": 0, + "open_issues": 0, + "watchers": 0, + "default_branch": "main", + "permissions": { + "admin": true, + "push": true, + "pull": true + }, + "temp_clone_token": "", + "allow_squash_merge": true, + "allow_merge_commit": true, + "allow_rebase_merge": true, + "delete_branch_on_merge": false, + "organization": { + "login": "hub4j-test-org", + "id": 7544739, + "node_id": "MDEyOk9yZ2FuaXphdGlvbjc1NDQ3Mzk=", + "avatar_url": "https://avatars3.githubusercontent.com/u/7544739?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/hub4j-test-org", + "html_url": "https://github.com/hub4j-test-org", + "followers_url": "https://api.github.com/users/hub4j-test-org/followers", + "following_url": "https://api.github.com/users/hub4j-test-org/following{/other_user}", + "gists_url": "https://api.github.com/users/hub4j-test-org/gists{/gist_id}", + "starred_url": "https://api.github.com/users/hub4j-test-org/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/hub4j-test-org/subscriptions", + "organizations_url": "https://api.github.com/users/hub4j-test-org/orgs", + "repos_url": "https://api.github.com/users/hub4j-test-org/repos", + "events_url": "https://api.github.com/users/hub4j-test-org/events{/privacy}", + "received_events_url": "https://api.github.com/users/hub4j-test-org/received_events", + "type": "Organization", + "site_admin": false + }, + "network_count": 0, + "subscribers_count": 6 +} \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/AbuseLimitHandlerTest/wiremock/testHandler_Wait_Secondary_Limits_Too_Many_Requests_Date_Retry_After/mappings/1-user.json b/src/test/resources/org/kohsuke/github/AbuseLimitHandlerTest/wiremock/testHandler_Wait_Secondary_Limits_Too_Many_Requests_Date_Retry_After/mappings/1-user.json new file mode 100644 index 0000000000..4133546851 --- /dev/null +++ b/src/test/resources/org/kohsuke/github/AbuseLimitHandlerTest/wiremock/testHandler_Wait_Secondary_Limits_Too_Many_Requests_Date_Retry_After/mappings/1-user.json @@ -0,0 +1,48 @@ +{ + "id": "a60baf84-5b5c-4f86-af3d-cab0d609c7b2", + "name": "user", + "request": { + "url": "/user", + "method": "GET", + "headers": { + "Accept": { + "equalTo": "application/vnd.github+json" + } + } + }, + "response": { + "status": 200, + "bodyFileName": "1-user.json", + "headers": { + "Date": "{{now timezone='GMT' format='EEE, dd MMM yyyy HH:mm:ss z'}}", + "Content-Type": "application/json; charset=utf-8", + "Server": "GitHub.com", + "Status": "200 OK", + "X-RateLimit-Limit": "5000", + "X-RateLimit-Remaining": "4930", + "X-RateLimit-Reset": "{{now offset='3 seconds' format='unix'}}", + "Cache-Control": "private, max-age=60, s-maxage=60", + "Vary": [ + "Accept, Authorization, Cookie, X-GitHub-OTP", + "Accept-Encoding" + ], + "ETag": "W/\"1cb30f031c67c499473b3aad01c7f7a5\"", + "Last-Modified": "Thu, 06 Feb 2020 17:29:39 GMT", + "X-OAuth-Scopes": "admin:org, admin:org_hook, admin:public_key, admin:repo_hook, delete_repo, gist, notifications, repo, user, write:discussion", + "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": "CC37:2605:3F884:4E941:5E3C5BFC" + } + }, + "uuid": "a60baf84-5b5c-4f86-af3d-cab0d609c7b2", + "persistent": true, + "insertionIndex": 1 +} \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/AbuseLimitHandlerTest/wiremock/testHandler_Wait_Secondary_Limits_Too_Many_Requests_Date_Retry_After/mappings/2-r_h_t_fail.json b/src/test/resources/org/kohsuke/github/AbuseLimitHandlerTest/wiremock/testHandler_Wait_Secondary_Limits_Too_Many_Requests_Date_Retry_After/mappings/2-r_h_t_fail.json new file mode 100644 index 0000000000..41af8b707d --- /dev/null +++ b/src/test/resources/org/kohsuke/github/AbuseLimitHandlerTest/wiremock/testHandler_Wait_Secondary_Limits_Too_Many_Requests_Date_Retry_After/mappings/2-r_h_t_fail.json @@ -0,0 +1,52 @@ +{ + "id": "79fb1092-8bf3-4274-bc8e-ca126c9d9261", + "name": "repos_hub4j-test-org_temp-testHandler_Wait_Secondary_Limits_Too_Many_Requests_Date_Retry_After", + "request": { + "url": "/repos/hub4j-test-org/temp-testHandler_Wait_Secondary_Limits_Too_Many_Requests_Date_Retry_After", + "method": "GET", + "headers": { + "Accept": { + "equalTo": "application/vnd.github+json" + } + } + }, + "response": { + "status": 403, + "body": "{\"message\":\"You have exceeded a secondary rate limit. Please wait a few minutes before you try again\"}", + "headers": { + "Date": "{{now timezone='GMT' format='EEE, dd MMM yyyy HH:mm:ss z'}}", + "Content-Type": "application/json; charset=utf-8", + "Server": "GitHub.com", + "Status": "403 Forbidden", + "gh-limited-by": "search-elapsed-time-shared-grouped", + "X-RateLimit-Limit": "5000", + "X-RateLimit-Remaining": "4000", + "X-RateLimit-Reset": "{{testStartDate offset='3 seconds' format='unix'}}", + "Cache-Control": "private, max-age=60, s-maxage=60", + "Vary": [ + "Accept, Authorization, Cookie, X-GitHub-OTP", + "Accept-Encoding" + ], + "ETag": "W/\"7ff3c96399f7ddf6129622d675ca9935\"", + "Last-Modified": "Thu, 06 Feb 2020 18:33:37 GMT", + "X-OAuth-Scopes": "admin:org, admin:org_hook, admin:public_key, admin:repo_hook, delete_repo, gist, notifications, repo, user, write:discussion", + "X-Accepted-OAuth-Scopes": "repo", + "X-GitHub-Media-Type": "unknown, github.v3", + "Access-Control-Expose-Headers": "ETag, Link, Location, gh-limited-by, 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": "CC37:2605:3F982:4E949:5E3C5BFC" + } + }, + "uuid": "79fb1092-8bf3-4274-bc8e-ca126c9d9261", + "persistent": true, + "scenarioName": "scenario-1-repos-hub4j-test-org-temp-testHandler_Wait_Secondary_Limits_Too_Many_Requests_Date_Retry_After", + "requiredScenarioState": "Started", + "newScenarioState": "scenario-1-repos-hub4j-test-org-temp-testHandler_Wait_Secondary_Limits_Too_Many_Requests_Date_Retry_After-2", + "insertionIndex": 2 +} \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/AbuseLimitHandlerTest/wiremock/testHandler_Wait_Secondary_Limits_Too_Many_Requests_Date_Retry_After/mappings/3-r_h_t_fail.json b/src/test/resources/org/kohsuke/github/AbuseLimitHandlerTest/wiremock/testHandler_Wait_Secondary_Limits_Too_Many_Requests_Date_Retry_After/mappings/3-r_h_t_fail.json new file mode 100644 index 0000000000..a29ef6ac2d --- /dev/null +++ b/src/test/resources/org/kohsuke/github/AbuseLimitHandlerTest/wiremock/testHandler_Wait_Secondary_Limits_Too_Many_Requests_Date_Retry_After/mappings/3-r_h_t_fail.json @@ -0,0 +1,49 @@ +{ + "id": "79fb1092-8bf3-4274-bc8e-ca126c9d9261", + "name": "repos_hub4j-test-org_temp-testHandler_Wait_Secondary_Limits_Too_Many_Requests_Date_Retry_After", + "request": { + "url": "/repos/hub4j-test-org/temp-testHandler_Wait_Secondary_Limits_Too_Many_Requests_Date_Retry_After", + "method": "GET", + "headers": { + "Accept": { + "equalTo": "application/vnd.github+json" + } + } + }, + "response": { + "status": 429, + "body": "{\"message\":\"You have exceeded a secondary rate limit. Please wait a few minutes before you try again\"}", + "headers": { + "Date": "{{now timezone='GMT' format='EEE, dd MMM yyyy HH:mm:ss z'}}", + "Content-Type": "application/json; charset=utf-8", + "Server": "GitHub.com", + "Status": "429 Too Many Requests", + "Retry-After": "Mon, 21 Oct 2115 07:28:00 GMT", + "Cache-Control": "private, max-age=60, s-maxage=60", + "Vary": [ + "Accept, Authorization, Cookie, X-GitHub-OTP", + "Accept-Encoding" + ], + "ETag": "W/\"7ff3c96399f7ddf6129622d675ca9935\"", + "Last-Modified": "Thu, 06 Feb 2020 18:33:37 GMT", + "X-OAuth-Scopes": "admin:org, admin:org_hook, admin:public_key, admin:repo_hook, delete_repo, gist, notifications, repo, user, write:discussion", + "X-Accepted-OAuth-Scopes": "repo", + "X-GitHub-Media-Type": "unknown, github.v3", + "Access-Control-Expose-Headers": "ETag, Link, Location, gh-limited-by, 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": "CC37:2605:3F982:4E949:5E3C5BFC" + } + }, + "uuid": "79fb1092-8bf3-4274-bc8e-ca126c9d9261", + "persistent": true, + "scenarioName": "scenario-4-repos-hub4j-test-org-temp-testHandler_Wait_Secondary_Limits_Too_Many_Requests_Date_Retry_After", + "requiredScenarioState": "Started", + "newScenarioState": "scenario-4-repos-hub4j-test-org-temp-testHandler_Wait_Secondary_Limits_Too_Many_Requests_Date_Retry_After-2", + "insertionIndex": 2 +} \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/AbuseLimitHandlerTest/wiremock/testHandler_Wait_Secondary_Limits_Too_Many_Requests_No_Retry_After/__files/1-user.json b/src/test/resources/org/kohsuke/github/AbuseLimitHandlerTest/wiremock/testHandler_Wait_Secondary_Limits_Too_Many_Requests_No_Retry_After/__files/1-user.json new file mode 100644 index 0000000000..467313f149 --- /dev/null +++ b/src/test/resources/org/kohsuke/github/AbuseLimitHandlerTest/wiremock/testHandler_Wait_Secondary_Limits_Too_Many_Requests_No_Retry_After/__files/1-user.json @@ -0,0 +1,45 @@ +{ + "login": "bitwiseman", + "id": 1958953, + "node_id": "MDQ6VXNlcjE5NTg5NTM=", + "avatar_url": "https://avatars3.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": "Cloudbees, Inc.", + "blog": "", + "location": "Seattle, WA, USA", + "email": "bitwiseman@gmail.com", + "hireable": null, + "bio": "https://twitter.com/bitwiseman", + "public_repos": 181, + "public_gists": 7, + "followers": 146, + "following": 9, + "created_at": "2012-07-11T20:38:33Z", + "updated_at": "2020-02-06T17:29:39Z", + "private_gists": 8, + "total_private_repos": 10, + "owned_private_repos": 0, + "disk_usage": 33697, + "collaborators": 0, + "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/AbuseLimitHandlerTest/wiremock/testHandler_Wait_Secondary_Limits_Too_Many_Requests_No_Retry_After/__files/3-r_h_t_fail.json b/src/test/resources/org/kohsuke/github/AbuseLimitHandlerTest/wiremock/testHandler_Wait_Secondary_Limits_Too_Many_Requests_No_Retry_After/__files/3-r_h_t_fail.json new file mode 100644 index 0000000000..4cb1b145af --- /dev/null +++ b/src/test/resources/org/kohsuke/github/AbuseLimitHandlerTest/wiremock/testHandler_Wait_Secondary_Limits_Too_Many_Requests_No_Retry_After/__files/3-r_h_t_fail.json @@ -0,0 +1,126 @@ +{ + "id": 238757196, + "node_id": "MDEwOlJlcG9zaXRvcnkyMzg3NTcxOTY=", + "name": "temp-testHandler_Wait_Secondary_Limits_Too_Many_Requests", + "full_name": "hub4j-test-org/temp-testHandler_Wait_Secondary_Limits_Too_Many_Requests", + "private": false, + "owner": { + "login": "hub4j-test-org", + "id": 7544739, + "node_id": "MDEyOk9yZ2FuaXphdGlvbjc1NDQ3Mzk=", + "avatar_url": "https://avatars3.githubusercontent.com/u/7544739?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/hub4j-test-org", + "html_url": "https://github.com/hub4j-test-org", + "followers_url": "https://api.github.com/users/hub4j-test-org/followers", + "following_url": "https://api.github.com/users/hub4j-test-org/following{/other_user}", + "gists_url": "https://api.github.com/users/hub4j-test-org/gists{/gist_id}", + "starred_url": "https://api.github.com/users/hub4j-test-org/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/hub4j-test-org/subscriptions", + "organizations_url": "https://api.github.com/users/hub4j-test-org/orgs", + "repos_url": "https://api.github.com/users/hub4j-test-org/repos", + "events_url": "https://api.github.com/users/hub4j-test-org/events{/privacy}", + "received_events_url": "https://api.github.com/users/hub4j-test-org/received_events", + "type": "Organization", + "site_admin": false + }, + "html_url": "https://github.com/hub4j-test-org/temp-testHandler_Wait_Secondary_Limits_Too_Many_Requests", + "description": "A test repository for testing the github-api project: temp-testHandler_Wait_Secondary_Limits_Too_Many_Requests", + "fork": false, + "url": "https://api.github.com/repos/hub4j-test-org/temp-testHandler_Wait_Secondary_Limits_Too_Many_Requests", + "forks_url": "https://api.github.com/repos/hub4j-test-org/temp-testHandler_Wait_Secondary_Limits_Too_Many_Requests/forks", + "keys_url": "https://api.github.com/repos/hub4j-test-org/temp-testHandler_Wait_Secondary_Limits_Too_Many_Requests/keys{/key_id}", + "collaborators_url": "https://api.github.com/repos/hub4j-test-org/temp-testHandler_Wait_Secondary_Limits_Too_Many_Requests/collaborators{/collaborator}", + "teams_url": "https://api.github.com/repos/hub4j-test-org/temp-testHandler_Wait_Secondary_Limits_Too_Many_Requests/teams", + "hooks_url": "https://api.github.com/repos/hub4j-test-org/temp-testHandler_Wait_Secondary_Limits_Too_Many_Requests/hooks", + "issue_events_url": "https://api.github.com/repos/hub4j-test-org/temp-testHandler_Wait_Secondary_Limits_Too_Many_Requests/issues/events{/number}", + "events_url": "https://api.github.com/repos/hub4j-test-org/temp-testHandler_Wait_Secondary_Limits_Too_Many_Requests/events", + "assignees_url": "https://api.github.com/repos/hub4j-test-org/temp-testHandler_Wait_Secondary_Limits_Too_Many_Requests/assignees{/user}", + "branches_url": "https://api.github.com/repos/hub4j-test-org/temp-testHandler_Wait_Secondary_Limits_Too_Many_Requests/branches{/branch}", + "tags_url": "https://api.github.com/repos/hub4j-test-org/temp-testHandler_Wait_Secondary_Limits_Too_Many_Requests/tags", + "blobs_url": "https://api.github.com/repos/hub4j-test-org/temp-testHandler_Wait_Secondary_Limits_Too_Many_Requests/git/blobs{/sha}", + "git_tags_url": "https://api.github.com/repos/hub4j-test-org/temp-testHandler_Wait_Secondary_Limits_Too_Many_Requests/git/tags{/sha}", + "git_refs_url": "https://api.github.com/repos/hub4j-test-org/temp-testHandler_Wait_Secondary_Limits_Too_Many_Requests/git/refs{/sha}", + "trees_url": "https://api.github.com/repos/hub4j-test-org/temp-testHandler_Wait_Secondary_Limits_Too_Many_Requests/git/trees{/sha}", + "statuses_url": "https://api.github.com/repos/hub4j-test-org/temp-testHandler_Wait_Secondary_Limits_Too_Many_Requests/statuses/{sha}", + "languages_url": "https://api.github.com/repos/hub4j-test-org/temp-testHandler_Wait_Secondary_Limits_Too_Many_Requests/languages", + "stargazers_url": "https://api.github.com/repos/hub4j-test-org/temp-testHandler_Wait_Secondary_Limits_Too_Many_Requests/stargazers", + "contributors_url": "https://api.github.com/repos/hub4j-test-org/temp-testHandler_Wait_Secondary_Limits_Too_Many_Requests/contributors", + "subscribers_url": "https://api.github.com/repos/hub4j-test-org/temp-testHandler_Wait_Secondary_Limits_Too_Many_Requests/subscribers", + "subscription_url": "https://api.github.com/repos/hub4j-test-org/temp-testHandler_Wait_Secondary_Limits_Too_Many_Requests/subscription", + "commits_url": "https://api.github.com/repos/hub4j-test-org/temp-testHandler_Wait_Secondary_Limits_Too_Many_Requests/commits{/sha}", + "git_commits_url": "https://api.github.com/repos/hub4j-test-org/temp-testHandler_Wait_Secondary_Limits_Too_Many_Requests/git/commits{/sha}", + "comments_url": "https://api.github.com/repos/hub4j-test-org/temp-testHandler_Wait_Secondary_Limits_Too_Many_Requests/comments{/number}", + "issue_comment_url": "https://api.github.com/repos/hub4j-test-org/temp-testHandler_Wait_Secondary_Limits_Too_Many_Requests/issues/comments{/number}", + "contents_url": "https://api.github.com/repos/hub4j-test-org/temp-testHandler_Wait_Secondary_Limits_Too_Many_Requests/contents/{+path}", + "compare_url": "https://api.github.com/repos/hub4j-test-org/temp-testHandler_Wait_Secondary_Limits_Too_Many_Requests/compare/{base}...{head}", + "merges_url": "https://api.github.com/repos/hub4j-test-org/temp-testHandler_Wait_Secondary_Limits_Too_Many_Requests/merges", + "archive_url": "https://api.github.com/repos/hub4j-test-org/temp-testHandler_Wait_Secondary_Limits_Too_Many_Requests/{archive_format}{/ref}", + "downloads_url": "https://api.github.com/repos/hub4j-test-org/temp-testHandler_Wait_Secondary_Limits_Too_Many_Requests/downloads", + "issues_url": "https://api.github.com/repos/hub4j-test-org/temp-testHandler_Wait_Secondary_Limits_Too_Many_Requests/issues{/number}", + "pulls_url": "https://api.github.com/repos/hub4j-test-org/temp-testHandler_Wait_Secondary_Limits_Too_Many_Requests/pulls{/number}", + "milestones_url": "https://api.github.com/repos/hub4j-test-org/temp-testHandler_Wait_Secondary_Limits_Too_Many_Requests/milestones{/number}", + "notifications_url": "https://api.github.com/repos/hub4j-test-org/temp-testHandler_Wait_Secondary_Limits_Too_Many_Requests/notifications{?since,all,participating}", + "labels_url": "https://api.github.com/repos/hub4j-test-org/temp-testHandler_Wait_Secondary_Limits_Too_Many_Requests/labels{/name}", + "releases_url": "https://api.github.com/repos/hub4j-test-org/temp-testHandler_Wait_Secondary_Limits_Too_Many_Requests/releases{/id}", + "deployments_url": "https://api.github.com/repos/hub4j-test-org/temp-testHandler_Wait_Secondary_Limits_Too_Many_Requests/deployments", + "created_at": "2020-02-06T18:33:39Z", + "updated_at": "2020-02-06T18:33:43Z", + "pushed_at": "2020-02-06T18:33:41Z", + "git_url": "git://github.com/hub4j-test-org/temp-testHandler_Wait_Secondary_Limits_Too_Many_Requests.git", + "ssh_url": "git@github.com:hub4j-test-org/temp-testHandler_Wait_Secondary_Limits_Too_Many_Requests.git", + "clone_url": "https://github.com/hub4j-test-org/temp-testHandler_Wait_Secondary_Limits_Too_Many_Requests.git", + "svn_url": "https://github.com/hub4j-test-org/temp-testHandler_Wait_Secondary_Limits_Too_Many_Requests", + "homepage": "http://github-api.kohsuke.org/", + "size": 0, + "stargazers_count": 0, + "watchers_count": 0, + "language": null, + "has_issues": true, + "has_projects": true, + "has_downloads": true, + "has_wiki": true, + "has_pages": false, + "forks_count": 0, + "mirror_url": null, + "archived": false, + "disabled": false, + "open_issues_count": 0, + "license": null, + "forks": 0, + "open_issues": 0, + "watchers": 0, + "default_branch": "main", + "permissions": { + "admin": true, + "push": true, + "pull": true + }, + "temp_clone_token": "", + "allow_squash_merge": true, + "allow_merge_commit": true, + "allow_rebase_merge": true, + "delete_branch_on_merge": false, + "organization": { + "login": "hub4j-test-org", + "id": 7544739, + "node_id": "MDEyOk9yZ2FuaXphdGlvbjc1NDQ3Mzk=", + "avatar_url": "https://avatars3.githubusercontent.com/u/7544739?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/hub4j-test-org", + "html_url": "https://github.com/hub4j-test-org", + "followers_url": "https://api.github.com/users/hub4j-test-org/followers", + "following_url": "https://api.github.com/users/hub4j-test-org/following{/other_user}", + "gists_url": "https://api.github.com/users/hub4j-test-org/gists{/gist_id}", + "starred_url": "https://api.github.com/users/hub4j-test-org/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/hub4j-test-org/subscriptions", + "organizations_url": "https://api.github.com/users/hub4j-test-org/orgs", + "repos_url": "https://api.github.com/users/hub4j-test-org/repos", + "events_url": "https://api.github.com/users/hub4j-test-org/events{/privacy}", + "received_events_url": "https://api.github.com/users/hub4j-test-org/received_events", + "type": "Organization", + "site_admin": false + }, + "network_count": 0, + "subscribers_count": 6 +} \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/AbuseLimitHandlerTest/wiremock/testHandler_Wait_Secondary_Limits_Too_Many_Requests_No_Retry_After/mappings/1-user.json b/src/test/resources/org/kohsuke/github/AbuseLimitHandlerTest/wiremock/testHandler_Wait_Secondary_Limits_Too_Many_Requests_No_Retry_After/mappings/1-user.json new file mode 100644 index 0000000000..4133546851 --- /dev/null +++ b/src/test/resources/org/kohsuke/github/AbuseLimitHandlerTest/wiremock/testHandler_Wait_Secondary_Limits_Too_Many_Requests_No_Retry_After/mappings/1-user.json @@ -0,0 +1,48 @@ +{ + "id": "a60baf84-5b5c-4f86-af3d-cab0d609c7b2", + "name": "user", + "request": { + "url": "/user", + "method": "GET", + "headers": { + "Accept": { + "equalTo": "application/vnd.github+json" + } + } + }, + "response": { + "status": 200, + "bodyFileName": "1-user.json", + "headers": { + "Date": "{{now timezone='GMT' format='EEE, dd MMM yyyy HH:mm:ss z'}}", + "Content-Type": "application/json; charset=utf-8", + "Server": "GitHub.com", + "Status": "200 OK", + "X-RateLimit-Limit": "5000", + "X-RateLimit-Remaining": "4930", + "X-RateLimit-Reset": "{{now offset='3 seconds' format='unix'}}", + "Cache-Control": "private, max-age=60, s-maxage=60", + "Vary": [ + "Accept, Authorization, Cookie, X-GitHub-OTP", + "Accept-Encoding" + ], + "ETag": "W/\"1cb30f031c67c499473b3aad01c7f7a5\"", + "Last-Modified": "Thu, 06 Feb 2020 17:29:39 GMT", + "X-OAuth-Scopes": "admin:org, admin:org_hook, admin:public_key, admin:repo_hook, delete_repo, gist, notifications, repo, user, write:discussion", + "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": "CC37:2605:3F884:4E941:5E3C5BFC" + } + }, + "uuid": "a60baf84-5b5c-4f86-af3d-cab0d609c7b2", + "persistent": true, + "insertionIndex": 1 +} \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/AbuseLimitHandlerTest/wiremock/testHandler_Wait_Secondary_Limits_Too_Many_Requests_No_Retry_After/mappings/3-r_h_t_fail.json b/src/test/resources/org/kohsuke/github/AbuseLimitHandlerTest/wiremock/testHandler_Wait_Secondary_Limits_Too_Many_Requests_No_Retry_After/mappings/3-r_h_t_fail.json new file mode 100644 index 0000000000..d6522df8e3 --- /dev/null +++ b/src/test/resources/org/kohsuke/github/AbuseLimitHandlerTest/wiremock/testHandler_Wait_Secondary_Limits_Too_Many_Requests_No_Retry_After/mappings/3-r_h_t_fail.json @@ -0,0 +1,49 @@ +{ + "id": "79fb1092-8bf3-4274-bc8e-ca126c9d9261", + "name": "repos_hub4j-test-org_temp-testHandler_Wait_Secondary_Limits_Too_Many_Requests_No_Retry_After", + "request": { + "url": "/repos/hub4j-test-org/temp-testHandler_Wait_Secondary_Limits_Too_Many_Requests_No_Retry_After", + "method": "GET", + "headers": { + "Accept": { + "equalTo": "application/vnd.github+json" + } + } + }, + "response": { + "status": 429, + "body": "{\"message\":\"You have exceeded a secondary rate limit. Please wait a few minutes before you try again\"}", + "headers": { + "Date": "{{now timezone='GMT' format='EEE, dd MMM yyyy HH:mm:ss z'}}", + "Content-Type": "application/json; charset=utf-8", + "Server": "GitHub.com", + "Status": "429 Too Many Requests", + "gh-limited-by": "search-elapsed-time-shared-grouped", + "Cache-Control": "private, max-age=60, s-maxage=60", + "Vary": [ + "Accept, Authorization, Cookie, X-GitHub-OTP", + "Accept-Encoding" + ], + "ETag": "W/\"7ff3c96399f7ddf6129622d675ca9935\"", + "Last-Modified": "Thu, 06 Feb 2020 18:33:37 GMT", + "X-OAuth-Scopes": "admin:org, admin:org_hook, admin:public_key, admin:repo_hook, delete_repo, gist, notifications, repo, user, write:discussion", + "X-Accepted-OAuth-Scopes": "repo", + "X-GitHub-Media-Type": "unknown, github.v3", + "Access-Control-Expose-Headers": "ETag, Link, Location, gh-limited-by, 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": "CC37:2605:3F982:4E949:5E3C5BFC" + } + }, + "uuid": "79fb1092-8bf3-4274-bc8e-ca126c9d9261", + "persistent": true, + "scenarioName": "scenario-4-repos-hub4j-test-org-temp-testHandler_Wait_Secondary_Limits_Too_Many_Requests_No_Retry_After", + "requiredScenarioState": "Started", + "newScenarioState": "scenario-4-repos-hub4j-test-org-temp-testHandler_Wait_Secondary_Limits_Too_Many_Requests_No_Retry_After-2", + "insertionIndex": 2 +} \ No newline at end of file