2 * ============LICENSE_START====================================================
4 * ===========================================================================
5 * Copyright (c) 2018 AT&T Intellectual Property. All rights reserved.
6 * ===========================================================================
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 * ============LICENSE_END====================================================
22 package org.onap.aaf.cadi.oauth.test;
24 import static org.junit.Assert.*;
27 import java.util.UUID;
29 import org.onap.aaf.cadi.CadiException;
30 import org.onap.aaf.cadi.oauth.AAFToken;
32 public class JU_AAFToken {
35 public void testMax() throws CadiException {
36 UUID uuid = new UUID(Long.MAX_VALUE,Long.MAX_VALUE);
37 String token = AAFToken.toToken(uuid);
38 UUID uuid2 = AAFToken.fromToken(token);
39 assertEquals(uuid, uuid2);
43 public void testMin() throws CadiException {
44 UUID uuid = new UUID(Long.MIN_VALUE,Long.MIN_VALUE);
45 String token = AAFToken.toToken(uuid);
46 UUID uuid2 = AAFToken.fromToken(token);
47 assertEquals(uuid, uuid2);
51 public void testRandom() throws CadiException {
52 for(int i=0;i<100;++i) {
53 UUID uuid = UUID.randomUUID();
54 String token = AAFToken.toToken(uuid);
55 UUID uuid2 = AAFToken.fromToken(token);
56 assertEquals(uuid, uuid2);
61 public void nullTest() {
63 assertNull(AAFToken.fromToken("~~invalid characters~~"));
65 // Invalid CADI tokens
66 assertNull(AAFToken.fromToken("ABCDEF"));
67 assertNull(AAFToken.fromToken("12345678901234567890123456789012345678"));