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.sso.test;
24 import static org.hamcrest.CoreMatchers.is;
25 import static org.hamcrest.CoreMatchers.nullValue;
26 import static org.junit.Assert.assertThat;
28 import java.io.ByteArrayInputStream;
30 import java.io.IOException;
32 import org.junit.After;
33 import org.junit.Before;
34 import org.junit.Test;
35 import org.onap.aaf.cadi.CadiException;
36 import org.onap.aaf.cadi.PropAccess;
37 import org.onap.aaf.cadi.config.Config;
38 import org.onap.aaf.cadi.sso.AAFSSO;
40 public class JU_AAFSSO {
42 private static final String resourceDirString = "src/test/resources";
43 private static final String aafDir = resourceDirString + "/aaf";
45 private ByteArrayInputStream inStream;
49 System.setProperty("user.home", aafDir);
51 // Simulate user input
52 inStream = new ByteArrayInputStream("test\npassword".getBytes());
53 System.setIn(inStream);
57 public void tearDown() {
58 // recursiveDelete(new File(aafDir));
64 // Note this is desctructive of personal dirs, and doesn't really test anything. Needs redoing.
68 // args = new String[] {
73 // sso = new AAFSSO(args);
75 // assertThat(new File(aafDir).exists(), is(true));
76 // assertThat(new File(aafDir + "/.aaf").exists(), is(true));
77 // assertThat(new File(aafDir + "/.aaf/keyfile").exists(), is(true));
78 // assertThat(new File(aafDir + "/.aaf/sso.out").exists(), is(true));
79 // assertThat(sso.loginOnly(), is(true));
81 //// Not necessarily true
82 //// assertThat(new File(aafDir + "/.aaf/sso.props").exists(), is(true));
84 // sso.setLogDefault();
85 // sso.setStdErrDefault();
88 // args = new String[] {
93 // sso = new AAFSSO(args);
95 // assertThat(new File(aafDir).exists(), is(true));
96 // assertThat(new File(aafDir + "/.aaf").exists(), is(true));
97 // assertThat(new File(aafDir + "/.aaf/keyfile").exists(), is(false));
98 // assertThat(new File(aafDir + "/.aaf/sso.out").exists(), is(true));
99 // assertThat(sso.loginOnly(), is(false));
101 // PropAccess access = sso.access();
102 // assertThat(sso.enc_pass(), is(access.getProperty(Config.AAF_APPPASS)));
103 // assertThat(sso.user(), is(access.getProperty(Config.AAF_APPID)));
105 // sso.addProp("key", "value");
106 // assertThat(sso.err(), is(nullValue()));
108 // assertThat(sso.useX509(), is(false));
111 // } catch (IOException | CadiException e) {
112 // e.printStackTrace();
117 private void recursiveDelete(File file) {
118 for (File f : file.listFiles()) {
119 if (f.isDirectory()) {