5c124de5c36bfc236d55578429df5f048f0d0a07Jamie Bowen * The contents of this file are subject to the terms of the Common Development and
5c124de5c36bfc236d55578429df5f048f0d0a07Jamie Bowen * Distribution License (the License). You may not use this file except in compliance with the
5c124de5c36bfc236d55578429df5f048f0d0a07Jamie Bowen * You can obtain a copy of the License at legal/CDDLv1.0.txt. See the License for the
5c124de5c36bfc236d55578429df5f048f0d0a07Jamie Bowen * specific language governing permission and limitations under the License.
5c124de5c36bfc236d55578429df5f048f0d0a07Jamie Bowen * When distributing Covered Software, include this CDDL Header Notice in each file and include
5c124de5c36bfc236d55578429df5f048f0d0a07Jamie Bowen * the License file at legal/CDDLv1.0.txt. If applicable, add the following below the CDDL
5c124de5c36bfc236d55578429df5f048f0d0a07Jamie Bowen * Header, with the fields enclosed by brackets [] replaced by your own identifying
5c124de5c36bfc236d55578429df5f048f0d0a07Jamie Bowen * information: "Portions copyright [year] [name of copyright owner]".
5c124de5c36bfc236d55578429df5f048f0d0a07Jamie Bowen * Copyright 2015 ForgeRock AS.
5c124de5c36bfc236d55578429df5f048f0d0a07Jamie Bowenpackage org.forgerock.openam.radius.server.config;
cb241c1aa2096e51864b45398cc15850b0ce4d8cjamiebowen * Test for <code>DefaultClientSecretGenerator</code>.
cb241c1aa2096e51864b45398cc15850b0ce4d8cjamiebowen * @see org.forgerock.openam.radius.server.config.DefaultClientSecretGenerator
5c124de5c36bfc236d55578429df5f048f0d0a07Jamie Bowen Logger logger = LoggerFactory.getLogger(DefaultClientSecretGeneratorTest.class.getSimpleName());
cb241c1aa2096e51864b45398cc15850b0ce4d8cjamiebowen * Test for method getDefaultValues().
cb241c1aa2096e51864b45398cc15850b0ce4d8cjamiebowen * @see org.forgerock.openam.radius.server.config.DefaultClientSecretGenerator#getDefaultValues
5c124de5c36bfc236d55578429df5f048f0d0a07Jamie Bowen final DefaultClientSecretGenerator secretGenerator = new DefaultClientSecretGenerator();
cb241c1aa2096e51864b45398cc15850b0ce4d8cjamiebowen final Set<String> secretHolder = secretGenerator.getDefaultValues();
5c124de5c36bfc236d55578429df5f048f0d0a07Jamie Bowen assertThat(secretHolder.size()).isEqualTo(expectedSize);
5c124de5c36bfc236d55578429df5f048f0d0a07Jamie Bowen final String secret = secretHolder.iterator().next();
5c124de5c36bfc236d55578429df5f048f0d0a07Jamie Bowen logger.debug("Generated secret was {}", secret);
5c124de5c36bfc236d55578429df5f048f0d0a07Jamie Bowen final boolean containsOnlyValidChars = secret.matches("[a-zA-Z0-9+/]{16}");
5c124de5c36bfc236d55578429df5f048f0d0a07Jamie Bowen logger.debug("containsOnlyValidChars is {}", containsOnlyValidChars);
5c124de5c36bfc236d55578429df5f048f0d0a07Jamie Bowen assertThat(secret.matches("[a-zA-Z0-9+/]{16}")).isTrue();