Class TokenResourceTest
java.lang.Object
junit.framework.Assert
junit.framework.TestCase
com.atlassian.crowd.acceptance.tests.rest.service.RestCrowdServiceAcceptanceTestCase
com.atlassian.crowd.acceptance.tests.rest.service.TokenResourceTest
- All Implemented Interfaces:
junit.framework.Test
-
Field Summary
Fields inherited from class com.atlassian.crowd.acceptance.tests.rest.service.RestCrowdServiceAcceptanceTestCase
ADMIN_PASSWORD, ADMIN_USERNAME, APPLICATION_NAME, APPLICATION_PASSWORD, ATTRIBUTES_RESOURCE, AUTHENTICATION_RESOURCE, EEEEP_PASSWORD, EEEEP_USERNAME, EVENTS_RESOURCE, GROUP_BADGERS, GROUP_BADGERS_DESCRIPTION, GROUP_CROWD_ADMINS, GROUP_CROWD_TESTERS, GROUP_CROWD_USERS, GROUPS_RESOURCE, MT, NON_ADMIN_USER_NAME, NON_ADMIN_USER_PASSWORD, NON_CROWD_USER_PASSWORD, NON_CROWD_USER_USERNAME, NON_EXISTENT_GROUP, NON_EXISTENT_USER, PENNY_USERNAME, REST_SERVICE_NAME, restServer, SECOND_ADMIN_PASSWORD, SECOND_ADMIN_USERNAME, SESSION_RESOURCE, USERNAME_PARAM, USERS_RESOURCE, WEBHOOKS_RESOURCE
-
Constructor Summary
ConstructorDescriptionTokenResourceTest
(String name) Constructs a test case with the given name.TokenResourceTest
(String name, RestServer restServer) Constructs a test case with the given name, using the given RestServer. -
Method Summary
Modifier and TypeMethodDescriptionprotected void
setAliasForUsername
(String alias) void
setUp()
void
void
Log in to an aliased application using the original username.void
void
void
Tests that getUserFromToken returns the correct user.void
Tests that a token from a login against one application cannot be used with another application where that user has no permission.void
Tests that all tokens get invalidated when calledvoid
Tests that the token really is invalidated.void
See CWD-3768.void
Tests the scenario in which different tokens are issued for the same user with different privileges.void
void
testSessionCreatedThroughAliasedApplicationShowsOriginalNameWhenRetrievedWithNonAliasingApplication()
void
void
void
void
The other alias tests GET the session.void
void
void
void
void
Tests that the token is invalidated when the user changes their own passwordvoid
Test that the token is invalidated if the user is deactivatedvoid
Tests that the token is invalidated if the user is deletedvoid
Tests that a user can successfully authenticate with an application.void
Tests that if a bad user credential is given, an error response is returned.void
Tests that an inactive user cannot create a session.void
Tests that a user can successfully authenticate with an application without password validation when the query parameter "validate-password" is false.void
Tests that when the validation factors are correct, and the token is correct, no errors are thrown.void
Tests that when the token is invalid, a 404 (Not Found) status is returned.void
Tests that when the validation factors are not correct, a 400 (Bad request) response is returned.Methods inherited from class com.atlassian.crowd.acceptance.tests.rest.service.RestCrowdServiceAcceptanceTestCase
authenticateUser, authenticateUser, deactivateUser, getBaseUriBuilder, getBaseUriBuilder, getBaseUriBuilder, getRootWebTarget, getServerUriBuilder, getWebTarget, getWebTarget, requestEvents, requestEventToken, setRestServer, tearDown
Methods inherited from class junit.framework.TestCase
assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertFalse, assertFalse, assertNotNull, assertNotNull, assertNotSame, assertNotSame, assertNull, assertNull, assertSame, assertSame, assertTrue, assertTrue, countTestCases, createResult, fail, fail, failNotEquals, failNotSame, failSame, format, getName, run, run, runBare, runTest, setName, toString
-
Constructor Details
-
TokenResourceTest
Constructs a test case with the given name.- Parameters:
name
- the test name
-
TokenResourceTest
Constructs a test case with the given name, using the given RestServer.- Parameters:
name
- the test namerestServer
- the RestServer
-
-
Method Details
-
setUp
- Overrides:
setUp
in classRestCrowdServiceAcceptanceTestCase
- Throws:
Exception
-
testUserAuthentication
public void testUserAuthentication()Tests that a user can successfully authenticate with an application. -
testUserAuthentication_WithoutPasswordValidation
public void testUserAuthentication_WithoutPasswordValidation()Tests that a user can successfully authenticate with an application without password validation when the query parameter "validate-password" is false. -
testUserAuthentication_InactiveUser
public void testUserAuthentication_InactiveUser()Tests that an inactive user cannot create a session. -
testUserAuthentication_BadPassword
public void testUserAuthentication_BadPassword()Tests that if a bad user credential is given, an error response is returned. -
testGetUserFromToken
public void testGetUserFromToken()Tests that getUserFromToken returns the correct user. -
testValidateToken
public void testValidateToken()Tests that when the validation factors are correct, and the token is correct, no errors are thrown. -
testShortLivedTokenExpiresImmediately
public void testShortLivedTokenExpiresImmediately() -
testMultipleShortLivedSessionsShouldNotDeadlock
See CWD-3768. Requesting a new token should not deadlock if there is an expired token in database.- Throws:
Exception
-
testMultipleTokensWithDifferentPrivilegesDoNotInterfereWithEachOther
public void testMultipleTokensWithDifferentPrivilegesDoNotInterfereWithEachOther()Tests the scenario in which different tokens are issued for the same user with different privileges. -
testCreatedTokenUsesDirectoryCaseForUsername
public void testCreatedTokenUsesDirectoryCaseForUsername() -
testValidateToken_InvalidToken
public void testValidateToken_InvalidToken()Tests that when the token is invalid, a 404 (Not Found) status is returned. -
testValidateToken_InvalidValidationFactors
public void testValidateToken_InvalidValidationFactors()Tests that when the validation factors are not correct, a 400 (Bad request) response is returned. -
testInvalidateToken
public void testInvalidateToken()Tests that the token really is invalidated. -
testInvalidateAllTokens
public void testInvalidateAllTokens()Tests that all tokens get invalidated when called -
testTokenIsDeletedWhenUserIsRemoved
public void testTokenIsDeletedWhenUserIsRemoved()Tests that the token is invalidated if the user is deleted -
testTokenIsDeletedWhenUserChangesPassword
public void testTokenIsDeletedWhenUserChangesPassword()Tests that the token is invalidated when the user changes their own password -
testTokenIsDeletedWhenUserIsMadeInactive
public void testTokenIsDeletedWhenUserIsMadeInactive()Test that the token is invalidated if the user is deactivated -
testGetUserFromTokenEnforcesApplicationAuthenticationChecks
public void testGetUserFromTokenEnforcesApplicationAuthenticationChecks()Tests that a token from a login against one application cannot be used with another application where that user has no permission. -
testAllSessionsForUserAreInvalidatedByDeleteWithUsernameSpecified
public void testAllSessionsForUserAreInvalidatedByDeleteWithUsernameSpecified() -
testSpecifiedUserSessionIsExcludedFromDeletionByUsername
public void testSpecifiedUserSessionIsExcludedFromDeletionByUsername() -
testStatusNotFoundWhenDeletingTokensForNonexistentUser
public void testStatusNotFoundWhenDeletingTokensForNonexistentUser() -
testSessionCreatedWithUnaliasedApplicationShowsAliasedNameWhenRetrievedWithAliasingApplication
public void testSessionCreatedWithUnaliasedApplicationShowsAliasedNameWhenRetrievedWithAliasingApplication() -
testSessionCreatedWithUnaliasedApplicationShowsAliasedNameWhenValidatedWithAliasingApplication
public void testSessionCreatedWithUnaliasedApplicationShowsAliasedNameWhenValidatedWithAliasingApplication()The other alias tests GET the session. Ensure that aliases are also resolved for a POST validation. -
testSessionCreatedThroughAliasedApplicationShowsOriginalNameWhenRetrievedWithNonAliasingApplication
public void testSessionCreatedThroughAliasedApplicationShowsOriginalNameWhenRetrievedWithNonAliasingApplication() -
testSessionCreatedWithDifferentCaseReturnsCorrectCaseForUsername
public void testSessionCreatedWithDifferentCaseReturnsCorrectCaseForUsername() -
testSessionCreatedThroughAliasWithDifferentCaseReturnsCorrectCase
public void testSessionCreatedThroughAliasWithDifferentCaseReturnsCorrectCase() -
testSessionCannotBeCreatedWithAliasThroughUnaliasedApplication
public void testSessionCannotBeCreatedWithAliasThroughUnaliasedApplication() -
testAliasedApplicationAlsoAcceptsUnaliasedUsername
public void testAliasedApplicationAlsoAcceptsUnaliasedUsername()Log in to an aliased application using the original username. This succeeds but, arguably, shouldn't: that user is aliased so the original username should be invisible. -
setAliasForUsername
-
testAliasChangesAreReflectedInSessionUsername
public void testAliasChangesAreReflectedInSessionUsername() -
testSessionForAliasedApplicationIncludesUnaliasedUsernameAsAnExtraField
public void testSessionForAliasedApplicationIncludesUnaliasedUsernameAsAnExtraField()
-