JwtAttributeMapperTest.java revision e440587b940248554524993d31d3e3f22997e62b
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * The contents of this file are subject to the terms of the Common Development and
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * Distribution License (the License). You may not use this file except in compliance with the
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * You can obtain a copy of the License at legal/CDDLv1.0.txt. See the License for the
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * specific language governing permission and limitations under the License.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * When distributing Covered Software, include this CDDL Header Notice in each file and include
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * the License file at legal/CDDLv1.0.txt. If applicable, add the following below the CDDL
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * Header, with the fields enclosed by brackets [] replaced by your own identifying
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * information: "Portions copyright [year] [name of copyright owner]".
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * Copyright 2014 ForgeRock AS.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Fosterpackage org.forgerock.openam.authentication.modules.oidc;
8af80418ba1ec431c8027fa9668e5678658d3611Allan Fosterimport org.forgerock.json.jose.jwt.JwtClaimsSet;
8af80418ba1ec431c8027fa9668e5678658d3611Allan FosterNot testing the lookupPrincipal method, as the AMIdentityRespository is final, and thus requires PowerMock. Introducing
8af80418ba1ec431c8027fa9668e5678658d3611Allan Fosterbyte-code engineering to test the simple consumption of the AMIdentityRepository in the DefaultPrincipalMapper not
bee2440354b4bc8796e1de0b6cbd60e1f68deba0Phill Cunningtonworth the downsides of PowerMock.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster private static final String EMAIL_VALUE = "bobo@bobo.com";
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster private static final String SUBJECT_VALUE = "112403712094132422537";
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster private static final String ISSUER = "accounts.google.com";
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster private JwtAttributeMapper defaultPrincipalMapper;
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster public void initialize() {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster attributeMappings = new HashMap<String, String>();
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster defaultPrincipalMapper = new JwtAttributeMapper();
bee2440354b4bc8796e1de0b6cbd60e1f68deba0Phill Cunnington defaultPrincipalMapper.getAttributes(attributeMappings, claimsSet);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster assertTrue(SUBJECT_VALUE.equals(attrs.get(UID).iterator().next()));