1 /*******************************************************************************
2 * ============LICENSE_START====================================================
4 * * ===========================================================================
5 * * Copyright © 2017 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====================================================
21 ******************************************************************************/
23 package org.onap.aaf.cadi.principal.test;
25 import static org.junit.Assert.*;
26 import static org.hamcrest.CoreMatchers.*;
29 import org.onap.aaf.cadi.principal.OAuth2FormPrincipal;
31 public class JU_OAuth2FormPrincipal {
33 private String username = "user";
34 private String id = "id";
37 public void accessorsTest() {
38 OAuth2FormPrincipal oauth = new OAuth2FormPrincipal(id, username);
39 assertThat(oauth.getName(), is(username));
40 assertThat(oauth.client_id(), is(id));
41 assertThat(oauth.tag(), is("OAuth"));
45 public void personalNameTest() {
46 OAuth2FormPrincipal oauth = new OAuth2FormPrincipal(id, username);
47 assertThat(oauth.personalName(), is(username + "|" + id));
49 oauth = new OAuth2FormPrincipal(id, null);
50 assertThat(oauth.personalName(), is(id));
52 oauth = new OAuth2FormPrincipal(id, id);
53 assertThat(oauth.personalName(), is(id));