f42184df7519d281202f33b5a774aa416e29f0a3
[aaf/authz.git] / cadi / core / src / test / java / org / onap / aaf / cadi / taf / test / JU_NullTaf.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 package org.onap.aaf.cadi.taf.test;
23
24 import static org.junit.Assert.*;
25 import static org.hamcrest.CoreMatchers.*;
26 import org.junit.*;
27
28 import java.io.IOException;
29
30 import org.onap.aaf.cadi.Access;
31 import org.onap.aaf.cadi.CachedPrincipal.Resp;
32 import org.onap.aaf.cadi.taf.TafResp;
33 import org.onap.aaf.cadi.taf.TafResp.RESP;
34
35 import org.onap.aaf.cadi.taf.NullTaf;
36
37 public class JU_NullTaf {
38
39         @Test
40         public void test() throws IOException {
41                 NullTaf nt = new NullTaf();
42                 TafResp singleton1 = nt.validate(null);
43                 TafResp singleton2 = nt.validate(null, null, null);
44                 Resp singleton3 = nt.revalidate(null, null);
45                 
46                 assertThat(singleton1, is(singleton2));
47                 
48                 assertFalse(singleton1.isValid());
49                 
50                 assertThat(singleton1.isAuthenticated(), is(RESP.NO_FURTHER_PROCESSING));
51                 
52                 assertThat(singleton1.desc(), is("All Authentication denied"));
53                 
54                 assertThat(singleton1.authenticate(), is(RESP.NO_FURTHER_PROCESSING));
55                 
56                 assertThat(singleton1.getPrincipal(), is(nullValue()));
57                 
58                 assertThat(singleton1.getAccess(), is(Access.NULL));
59                 
60                 assertTrue(singleton1.isFailedAttempt());
61
62                 assertThat(singleton3, is(Resp.NOT_MINE));
63         }
64
65 }