Search in sources :

Example 71 with Token

use of org.forgerock.openam.cts.api.tokens.Token in project OpenAM by OpenRock.

the class OAuthAdapterTest method shouldNotDeserialiseATokenWhichDoesntContainAMap.

@Test
public void shouldNotDeserialiseATokenWhichDoesntContainAMap() {
    // Given
    JSONSerialisation serialisation = new JSONSerialisation(new ObjectMapper());
    OAuthAdapter adapter = generateOAuthAdapter();
    Token token = new Token("", TokenType.OAUTH);
    token.setBlob(serialisation.serialise("badger").getBytes());
    // When
    JsonValue fromToken = adapter.fromToken(token);
    // Then
    assertThat(fromToken).isNull();
}
Also used : JSONSerialisation(org.forgerock.openam.cts.utils.JSONSerialisation) JsonValue(org.forgerock.json.JsonValue) Token(org.forgerock.openam.cts.api.tokens.Token) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) Test(org.testng.annotations.Test)

Example 72 with Token

use of org.forgerock.openam.cts.api.tokens.Token in project OpenAM by OpenRock.

the class CTSMonitoringStoreImplTest method shouldNotAddTokenOperationForSpecificTokenTypeIfTokenIsNull.

@Test
public void shouldNotAddTokenOperationForSpecificTokenTypeIfTokenIsNull() throws InterruptedException {
    //Given
    Token token = null;
    CTSOperation operation = CTSOperation.READ;
    boolean successful = true;
    //When
    ctsOperationsMonitoringStore.addTokenOperation(token, operation, successful);
    //Then
    verify(tokenOperationsStore, never()).addTokenOperation(Matchers.<TokenType>anyObject(), eq(operation), eq(successful));
}
Also used : CTSOperation(org.forgerock.openam.cts.CTSOperation) Token(org.forgerock.openam.cts.api.tokens.Token) Test(org.testng.annotations.Test)

Example 73 with Token

use of org.forgerock.openam.cts.api.tokens.Token in project OpenAM by OpenRock.

the class JSONSerialisationTest method shouldDeserialiseSerialisedToken.

@Test
public void shouldDeserialiseSerialisedToken() {
    // Given
    Token token = new Token("id", TokenType.OAUTH);
    // When
    Token result = serialization.deserialise(serialization.serialise(token), Token.class);
    // Then
    TokenTestUtils.assertTokenEquals(result, token);
}
Also used : Token(org.forgerock.openam.cts.api.tokens.Token) Test(org.testng.annotations.Test)

Example 74 with Token

use of org.forgerock.openam.cts.api.tokens.Token in project OpenAM by OpenRock.

the class LdapTokenAttributeConversionTest method shouldUnderstandEmptyStrings.

@Test
public void shouldUnderstandEmptyStrings() {
    // Given
    Entry entry = new LinkedHashMapEntry();
    entry.addAttribute(CoreTokenField.TOKEN_ID.toString(), "id");
    entry.addAttribute(CoreTokenField.TOKEN_TYPE.toString(), TokenType.OAUTH.toString());
    entry.addAttribute(CoreTokenField.STRING_ONE.toString(), LdapTokenAttributeConversion.EMPTY);
    LdapTokenAttributeConversion conversion = generateTokenAttributeConversion();
    // When
    Token result = conversion.tokenFromEntry(entry);
    // Then
    String string = result.getValue(CoreTokenField.STRING_ONE);
    assertTrue(string.isEmpty());
}
Also used : LinkedHashMapEntry(org.forgerock.opendj.ldap.LinkedHashMapEntry) Entry(org.forgerock.opendj.ldap.Entry) LinkedHashMapEntry(org.forgerock.opendj.ldap.LinkedHashMapEntry) Token(org.forgerock.openam.cts.api.tokens.Token) Test(org.testng.annotations.Test)

Example 75 with Token

use of org.forgerock.openam.cts.api.tokens.Token in project OpenAM by OpenRock.

the class LdapTokenAttributeConversionTest method shouldHandleEmptyStrings.

@Test
public void shouldHandleEmptyStrings() {
    // Given
    Token token = new Token("id", TokenType.OAUTH);
    token.setAttribute(CoreTokenField.STRING_ONE, "");
    LdapTokenAttributeConversion conversion = generateTokenAttributeConversion();
    // When
    Entry result = conversion.getEntry(token);
    // Then
    Attribute attribute = result.getAttribute(CoreTokenField.STRING_ONE.toString());
    assertNull(attribute);
}
Also used : LinkedHashMapEntry(org.forgerock.opendj.ldap.LinkedHashMapEntry) Entry(org.forgerock.opendj.ldap.Entry) Attribute(org.forgerock.opendj.ldap.Attribute) Token(org.forgerock.openam.cts.api.tokens.Token) Test(org.testng.annotations.Test)

Aggregations

Token (org.forgerock.openam.cts.api.tokens.Token)86 Test (org.testng.annotations.Test)58 Task (org.forgerock.openam.sm.datalayer.api.Task)17 ResultHandler (org.forgerock.openam.sm.datalayer.api.ResultHandler)16 PartialToken (org.forgerock.openam.sm.datalayer.api.query.PartialToken)16 InvocationOnMock (org.mockito.invocation.InvocationOnMock)14 CoreTokenException (org.forgerock.openam.cts.exceptions.CoreTokenException)13 InternalSession (com.iplanet.dpro.session.service.InternalSession)8 DataLayerException (org.forgerock.openam.sm.datalayer.api.DataLayerException)8 Calendar (java.util.Calendar)7 JsonValue (org.forgerock.json.JsonValue)7 SessionID (com.iplanet.dpro.session.SessionID)6 TokenFilter (org.forgerock.openam.cts.api.filter.TokenFilter)6 Collection (java.util.Collection)5 HashMap (java.util.HashMap)5 Entry (org.forgerock.opendj.ldap.Entry)5 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)4 SAMLToken (org.forgerock.openam.cts.api.tokens.SAMLToken)4 Connection (org.forgerock.opendj.ldap.Connection)4 LinkedHashMapEntry (org.forgerock.opendj.ldap.LinkedHashMapEntry)4