diff --git a/src/test/java/hudson/plugins/git/GitStatusTest.java b/src/test/java/hudson/plugins/git/GitStatusTest.java index cad26f9c47..ce0a133867 100644 --- a/src/test/java/hudson/plugins/git/GitStatusTest.java +++ b/src/test/java/hudson/plugins/git/GitStatusTest.java @@ -591,19 +591,6 @@ public void testDoNotifyCommitWithUnauthenticatedPollingAllowed() throws Excepti Mockito.verify(trigger).run(); } - @Test - @Issue("SECURITY-284") - public void testDoNotifyCommitWithSha1AndAllowModePoll() throws Exception { - GitStatus.NOTIFY_COMMIT_ACCESS_CONTROL = "disabled-for-polling"; - setupProjectWithTrigger("a", "master", false); - StaplerResponse res = mock(StaplerResponse.class); - - HttpResponse httpResponse = this.gitStatus.doNotifyCommit(requestWithNoParameter, "a", "master", sha1, null); - httpResponse.generateResponse(null, res, null); - - Mockito.verify(res).sendError(401, "An access token is required when using the sha1 parameter. Please refer to Git plugin documentation (https://plugins.jenkins.io/git/#plugin-content-push-notification-from-repository) for details."); - } - @Test @Issue("SECURITY-284") public void testDoNotifyCommitWithAllowModeSha1() throws Exception { diff --git a/src/test/java/hudson/plugins/git/GitStepTest.java b/src/test/java/hudson/plugins/git/GitStepTest.java index e4838e5575..a5322cdfde 100644 --- a/src/test/java/hudson/plugins/git/GitStepTest.java +++ b/src/test/java/hudson/plugins/git/GitStepTest.java @@ -347,10 +347,10 @@ public void testDoNotifyCommitWithSha1AndAllowModePollWithInvalidToken() throws assumeTrue("Test class max time " + MAX_SECONDS_FOR_THESE_TESTS + " exceeded", isTimeAvailable()); GitStatus.NOTIFY_COMMIT_ACCESS_CONTROL = "disabled-for-polling"; createJob(); - /* sha1 is ignored because no access token is provided */ + /* sha1 is ignored because invalid access token is provided */ String sha1 = "4b714b66959463a98e9dfb1983db5a39a39fa6d6"; - String response = sampleRepo.notifyCommit(r, null, sha1); - assertThat(response, containsString("An access token is required when using the sha1 parameter")); + String response = sampleRepo.notifyCommit(r, GitSampleRepoRule.INVALID_NOTIFY_COMMIT_TOKEN, sha1); + assertThat(response, containsString("Invalid access token")); } @Test @@ -359,10 +359,10 @@ public void testDoNotifyCommitWithSha1AndAllowModePoll() throws Exception { assumeTrue("Test class max time " + MAX_SECONDS_FOR_THESE_TESTS + " exceeded", isTimeAvailable()); GitStatus.NOTIFY_COMMIT_ACCESS_CONTROL = "disabled-for-polling"; createJob(); - /* sha1 is ignored because invalid access token is provided */ + /* sha1 is ignored because no access token is provided */ String sha1 = "4b714b66959463a98e9dfb1983db5a39a39fa6d6"; - String response = sampleRepo.notifyCommit(r, GitSampleRepoRule.INVALID_NOTIFY_COMMIT_TOKEN, sha1); - assertThat(response, containsString("Invalid access token")); + String response = sampleRepo.notifyCommit(r, null, sha1); + assertThat(response, containsString("An access token is required when using the sha1 parameter")); } }