com.atlassian.crowd.acceptance.tests.rest.service
Class TokenResourceTest

java.lang.Object
  extended by junit.framework.Assert
      extended by junit.framework.TestCase
          extended by com.atlassian.crowd.acceptance.tests.rest.service.RestCrowdServiceAcceptanceTestCase
              extended by com.atlassian.crowd.acceptance.tests.rest.service.TokenResourceTest
All Implemented Interfaces:
junit.framework.Test
Direct Known Subclasses:
HordeTokenResourceTest

public class TokenResourceTest
extends RestCrowdServiceAcceptanceTestCase


Field Summary
 
Fields inherited from class com.atlassian.crowd.acceptance.tests.rest.service.RestCrowdServiceAcceptanceTestCase
APPLICATION_NAME, APPLICATION_PASSWORD, ATTRIBUTES_RESOURCE, AUTHENTICATION_RESOURCE, EVENTS_RESOURCE, GROUPS_RESOURCE, MT, REST_SERVICE_NAME, SESSION_RESOURCE, USERS_RESOURCE, WEBHOOKS_RESOURCE
 
Constructor Summary
TokenResourceTest(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
 void sessionCannotBeCreatedWithAliasThroughUnaliasedApplication()
           
protected  void setAliasForUsername(String alias)
           
 void setUp()
           
 void testAliasChangesAreReflectedInSessionUsername()
           
 void testAliasedApplicationAlsoAcceptsUnaliasedUsername()
          Log in to an aliased application using the original username.
 void testAllSessionsForUserAreInvalidatedByDeleteWithUsernameSpecified()
           
 void testCreatedTokenUsesDirectoryCaseForUsername()
           
 void testGetUserFromToken()
          Tests that getUserFromToken returns the correct user.
 void testGetUserFromTokenEnforcesApplicationAuthenticationChecks()
          Tests that a token from a login against one application cannot be used with another application where that user has no permission.
 void testInvalidateToken()
          Tests that the token really is invalidated.
 void testInvalidUserAuthentication()
          Tests that if a bad user credential is given, an error response is returned.
 void testMultipleTokensWithDifferentPrivilegesDoNotInterfereWithEachOther()
          Tests the scenario in which different tokens are issued for the same user with different privileges.
 void testSessionCreatedThroughAliasedApplicationShowsOriginalNameWhenRetrievedWithNonAliasingApplication()
           
 void testSessionCreatedThroughAliasWithDifferentCaseReturnsCorrectCase()
           
 void testSessionCreatedWithDifferentCaseReturnsCorrectCaseForUsername()
           
 void testSessionCreatedWithUnaliasedApplicationShowsAliasedNameWhenRetrievedWithAliasingApplication()
           
 void testSessionCreatedWithUnaliasedApplicationShowsAliasedNameWhenValidatedWithAliasingApplication()
          The other alias tests GET the session.
 void testSessionForAliasedApplicationIncludesUnaliasedUsernameAsAnExtraField()
           
 void testShortLivedTokenExpiresImmediately()
           
 void testSpecifiedUserSessionIsExcludedFromDeletionByUsername()
           
 void testStatusNotFoundWhenDeletingTokensForNonexistentUser()
           
 void testUserAuthentication_WithoutPasswordValidation()
          Tests that a user can successfully authenticate with an application without password validation when the query parameter "validate-password" is false.
 void testUserAuthentication()
          Tests that a user can successfully authenticate with an application.
 void testValidateToken_InvalidToken()
          Tests that when the token is invalid, a 404 (Not Found) status is returned.
 void testValidateToken_InvalidValidationFactors()
          Tests that when the validation factors are not correct, a 400 (Bad request) response is returned.
 void testValidateToken()
          Tests that when the validation factors are correct, and the token is correct, no errors are thrown.
 
Methods inherited from class com.atlassian.crowd.acceptance.tests.rest.service.RestCrowdServiceAcceptanceTestCase
authenticateUser, getBaseUriBuilder, getBaseUriBuilder, getBaseUriBuilder, getRootWebResource, getWebResource, getWebResource, setRestServer, statusToString, 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
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

TokenResourceTest

public TokenResourceTest(String name)
Constructs a test case with the given name.

Parameters:
name - the test name

TokenResourceTest

public TokenResourceTest(String name,
                         RestServer restServer)
Constructs a test case with the given name, using the given RestServer.

Parameters:
name - the test name
restServer - the RestServer
Method Detail

setUp

public void setUp()
           throws Exception
Overrides:
setUp in class RestCrowdServiceAcceptanceTestCase
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.


testInvalidUserAuthentication

public void testInvalidUserAuthentication()
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()

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.


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()

sessionCannotBeCreatedWithAliasThroughUnaliasedApplication

public void sessionCannotBeCreatedWithAliasThroughUnaliasedApplication()

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

protected void setAliasForUsername(String alias)

testAliasChangesAreReflectedInSessionUsername

public void testAliasChangesAreReflectedInSessionUsername()

testSessionForAliasedApplicationIncludesUnaliasedUsernameAsAnExtraField

public void testSessionForAliasedApplicationIncludesUnaliasedUsernameAsAnExtraField()


Copyright © 2013 Atlassian. All Rights Reserved.