c0b1c2af95c44ffea2c57f8eb4d0aef362054b1f
[aaf/authz.git] / cadi / core / src / test / java / org / onap / aaf / cadi / principal / test / JU_OAuth2FormPrincipal.java
1 /*******************************************************************************
2  * ============LICENSE_START====================================================
3  * * org.onap.aaf
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
10  * * 
11  *  *      http://www.apache.org/licenses/LICENSE-2.0
12  * * 
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====================================================
19  * *
20  * *
21  ******************************************************************************/
22
23 package org.onap.aaf.cadi.principal.test;
24
25 import static org.junit.Assert.*;
26 import static org.hamcrest.CoreMatchers.*;
27 import org.junit.*;
28
29 import org.onap.aaf.cadi.principal.OAuth2FormPrincipal;
30
31 public class JU_OAuth2FormPrincipal {
32
33         private String username = "user";
34         private String id = "id";
35
36         @Test
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"));
42         }
43
44         @Test
45         public void personalNameTest() {
46                 OAuth2FormPrincipal oauth = new OAuth2FormPrincipal(id, username);
47                 assertThat(oauth.personalName(), is(username + "|" + id));
48
49                 oauth = new OAuth2FormPrincipal(id, null);
50                 assertThat(oauth.personalName(), is(id));
51
52                 oauth = new OAuth2FormPrincipal(id, id);
53                 assertThat(oauth.personalName(), is(id));
54         }
55
56 }