1 /*******************************************************************************
\r
2 * ============LICENSE_START====================================================
\r
4 * * ===========================================================================
\r
5 * * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
\r
6 * * ===========================================================================
\r
7 * * Licensed under the Apache License, Version 2.0 (the "License");
\r
8 * * you may not use this file except in compliance with the License.
\r
9 * * You may obtain a copy of the License at
\r
11 * * http://www.apache.org/licenses/LICENSE-2.0
\r
13 * * Unless required by applicable law or agreed to in writing, software
\r
14 * * distributed under the License is distributed on an "AS IS" BASIS,
\r
15 * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
\r
16 * * See the License for the specific language governing permissions and
\r
17 * * limitations under the License.
\r
18 * * ============LICENSE_END====================================================
\r
20 * * ECOMP is a trademark and service mark of AT&T Intellectual Property.
\r
22 ******************************************************************************/
\r
23 package org.onap.aaf.cadi.http;
\r
25 import static org.junit.Assert.*;
\r
27 import java.io.IOException;
\r
29 import org.junit.Before;
\r
30 import org.junit.Test;
\r
32 public class JU_HBasicAuthSSTest {
\r
35 public void setUp() throws Exception {
\r
39 public void testHBasicAuthSSStringStringSecurityInfoCOfHttpURLConnection() throws IOException {
\r
40 HBasicAuthSS basicAuth = new HBasicAuthSS("user", "pass", null);
\r
42 assertEquals(basicAuth.getID(), "user");
\r
43 assertFalse(basicAuth.isDenied());
\r
44 assertEquals(basicAuth.count(), 0);
\r
45 assertEquals(basicAuth.setLastResponse(401), 1);
\r
49 public void testHBasicAuthSSStringStringSecurityInfoCOfHttpURLConnection_one() throws IOException {
\r
50 HBasicAuthSS basicAuth = new HBasicAuthSS("demo", "demopass", null);
\r
52 assertEquals(basicAuth.getID(), "demo");
\r
53 assertFalse(basicAuth.isDenied());
\r
54 assertEquals(basicAuth.count(), 0);
\r
55 assertEquals(basicAuth.setLastResponse(401), 1);
\r
59 public void testHBasicAuthSSStringStringSecurityInfoCOfHttpURLConnectionTwo() throws IOException {
\r
60 HBasicAuthSS basicAuth = new HBasicAuthSS("user 1", "user 2", null);
\r
62 assertEquals(basicAuth.getID(), "user 1");
\r
63 assertFalse(basicAuth.isDenied());
\r
64 assertEquals(basicAuth.count(), 0);
\r
65 assertEquals(basicAuth.setLastResponse(401), 1);
\r
69 public void testHBasicAuthSSStringStringSecurityInfoCOfHttpURLConnectionThree() throws IOException {
\r
70 HBasicAuthSS basicAuth = new HBasicAuthSS("onap", "onap", null);
\r
72 assertEquals(basicAuth.getID(), "onap");
\r
73 assertFalse(basicAuth.isDenied());
\r
74 assertEquals(basicAuth.count(), 0);
\r
75 assertEquals(basicAuth.setLastResponse(401), 1);
\r