Search in sources :

Example 6 with InvalidAccessTokenException

use of com.thoughtworks.go.server.exceptions.InvalidAccessTokenException in project gocd by gocd.

the class AccessTokenServiceIntegrationTest method shouldFailToGetAccessTokenWhenProvidedTokenContainsInvalidSaltId.

@Test
public void shouldFailToGetAccessTokenWhenProvidedTokenContainsInvalidSaltId() {
    String accessToken = RandomStringUtils.randomAlphanumeric(40);
    InvalidAccessTokenException exception = assertThrows(InvalidAccessTokenException.class, () -> accessTokenService.findByAccessToken(accessToken));
    assertThat("Invalid Personal Access Token.").isEqualTo(exception.getMessage());
}
Also used : InvalidAccessTokenException(com.thoughtworks.go.server.exceptions.InvalidAccessTokenException) Test(org.junit.jupiter.api.Test)

Example 7 with InvalidAccessTokenException

use of com.thoughtworks.go.server.exceptions.InvalidAccessTokenException in project gocd by gocd.

the class AccessTokenServiceIntegrationTest method shouldFailToGetAccessTokenWhenProvidedTokenLengthIsNotEqualTo40.

@Test
public void shouldFailToGetAccessTokenWhenProvidedTokenLengthIsNotEqualTo40() {
    InvalidAccessTokenException exception = assertThrows(InvalidAccessTokenException.class, () -> accessTokenService.findByAccessToken("my-access-token"));
    assertThat("Invalid Personal Access Token.").isEqualTo(exception.getMessage());
}
Also used : InvalidAccessTokenException(com.thoughtworks.go.server.exceptions.InvalidAccessTokenException) Test(org.junit.jupiter.api.Test)

Aggregations

InvalidAccessTokenException (com.thoughtworks.go.server.exceptions.InvalidAccessTokenException)7 Test (org.junit.jupiter.api.Test)4 AccessToken (com.thoughtworks.go.domain.AccessToken)2 AuthenticationResponse (com.thoughtworks.go.plugin.domain.authorization.AuthenticationResponse)2 User (com.thoughtworks.go.plugin.domain.authorization.User)2 CaseInsensitiveString (com.thoughtworks.go.config.CaseInsensitiveString)1 PluginRoleConfig (com.thoughtworks.go.config.PluginRoleConfig)1 RevokedAccessTokenException (com.thoughtworks.go.server.exceptions.RevokedAccessTokenException)1 OnlyKnownUsersAllowedException (com.thoughtworks.go.server.security.OnlyKnownUsersAllowedException)1 GoUserPrinciple (com.thoughtworks.go.server.security.userdetail.GoUserPrinciple)1 ArrayList (java.util.ArrayList)1