ch.elca.el4j.tests.services.security
Class AuthorizationLocalTest

java.lang.Object
  extended by ch.elca.el4j.tests.services.security.AuthorizationLocalTest

public class AuthorizationLocalTest
extends Object

Tests various logins and authorization in a local environment.

Author:
Raphael Boog (RBO)
File-location:
AuthorizationLocalTest
Last check-in date:
2010-01-15 12:21:07 +0100 (Fr, 15. Jan 2010) by jonasha for revision 4091

Field Summary
private  ApplicationContext m_ac
          Application context.
private  String[] m_configLocations
          Config locations.
private static String METHOD_ACCESS_ROLE
          Method access role.
private static org.slf4j.Logger s_logger
          The static logger.
 
Constructor Summary
AuthorizationLocalTest()
           
 
Method Summary
private  void createSecureContext(String principal, String credential, String role)
          Create a secure context, i.e. login, with a TestingAuthenticationToken, i.e. a token where the user can define which roles it possesses.
private  void destroySecureContext()
          Delete the secure context, i.e. logging out the user.
private  ExtendedTestingAuthenticationProvider getAuthenticationProvider()
          Returns the local authentication provider.
private  SampleService getSampleService()
           
 void testCorrectAuthorization()
          Test does a correct authorization.
 void testCorrectAuthorizationAfterLogoutNoAccess()
          Test does a correct authorization.
 void testFailedAuthentication()
          Test tries to authenticate with a wrong username/password combination.
 void testFailedAuthorization()
          Test does a correct login with the wrong role.
 void testMethodCallWithoutLogin()
          Test tries to execute the target method without authentication.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

s_logger

private static org.slf4j.Logger s_logger
The static logger.


METHOD_ACCESS_ROLE

private static final String METHOD_ACCESS_ROLE
Method access role.

See Also:
Constant Field Values

m_configLocations

private String[] m_configLocations
Config locations.


m_ac

private ApplicationContext m_ac
Application context.

Constructor Detail

AuthorizationLocalTest

public AuthorizationLocalTest()
Method Detail

testMethodCallWithoutLogin

public void testMethodCallWithoutLogin()
                                throws Exception
Test tries to execute the target method without authentication.

Throws:
Exception - If something.

testCorrectAuthorization

public void testCorrectAuthorization()
                              throws Exception
Test does a correct authorization. Then it does a remote call to the sample service.

Throws:
Exception - If something.

testCorrectAuthorizationAfterLogoutNoAccess

public void testCorrectAuthorizationAfterLogoutNoAccess()
                                                 throws Exception
Test does a correct authorization. Then it does a remote call to the sample service. Afterwards, it logs out, tries to call the method again and fails.

Throws:
Exception - If something.

testFailedAuthorization

public void testFailedAuthorization()
                             throws Exception
Test does a correct login with the wrong role. Then it does a remote call to the sample service. Since the required permission is not given, the call should throw an exception.

Throws:
Exception - If something.

testFailedAuthentication

public void testFailedAuthentication()
                              throws Exception
Test tries to authenticate with a wrong username/password combination. An exception should be thrown.

Throws:
Exception - If something.

getAuthenticationProvider

private ExtendedTestingAuthenticationProvider getAuthenticationProvider()
Returns the local authentication provider.

Returns:
The ExtendedTestingAuthenticationProvider of this application context.

getSampleService

private SampleService getSampleService()
Returns:
Returns the sample service.

createSecureContext

private void createSecureContext(String principal,
                                 String credential,
                                 String role)
Create a secure context, i.e. login, with a TestingAuthenticationToken, i.e. a token where the user can define which roles it possesses.

Parameters:
principal - The username
credential - The password
role - The role

destroySecureContext

private void destroySecureContext()
Delete the secure context, i.e. logging out the user.



Copyright © 2005-2011 ELCA. All Rights Reserved.