Fix sonar issues & modify deploy property
[aaf/authz.git] / auth / auth-core / src / test / java / org / onap / aaf / auth / org / test / JU_Organization.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.auth.org.test;
23
24 import static org.mockito.Mockito.mock;
25
26 import java.util.ArrayList;
27 import java.util.GregorianCalendar;
28 import java.util.HashSet;
29
30 import org.junit.Before;
31 import org.junit.Test;
32 import org.onap.aaf.auth.env.AuthzTrans;
33 import org.onap.aaf.auth.org.EmailWarnings;
34 import org.onap.aaf.auth.org.Organization;
35 import org.onap.aaf.auth.org.Organization.Expiration;
36 import org.onap.aaf.auth.org.Organization.Identity;
37 import org.onap.aaf.auth.org.Organization.Notify;
38 import org.onap.aaf.auth.org.Organization.Policy;
39 import org.onap.aaf.auth.org.Organization.Response;
40 import org.onap.aaf.auth.org.OrganizationException;
41
42 import junit.framework.Assert;
43
44 public class JU_Organization {
45
46         AuthzTrans trans;
47         GregorianCalendar gc;
48         @Before
49         public void setUp() {
50                 gc = new GregorianCalendar(1900, 1, 1);
51                 trans = mock(AuthzTrans.class);
52         }
53         
54         @Test
55         public void test() throws OrganizationException {               
56                 //tests for Org null
57                 Assert.assertEquals("n/a",Organization.NULL.getName());
58                 Assert.assertEquals("n/a",Organization.NULL.getDomain());
59                 Assert.assertEquals("n/a",Organization.NULL.getRealm());
60                 Assert.assertTrue(Organization.NULL.getIdentity(trans, "test") instanceof Identity);
61                 Assert.assertEquals("n/a",Organization.NULL.isValidID(trans, null));
62                 Assert.assertEquals("n/a",Organization.NULL.isValidPassword(trans, null, null, null));
63                 Assert.assertTrue(Organization.NULL.getIdentityTypes() instanceof HashSet);
64                 Assert.assertTrue(Organization.NULL.notify(trans, Notify.PasswordExpiration, null, null, null, null, null) instanceof Response);
65                 Assert.assertEquals(0,Organization.NULL.sendEmail(trans, null, null, null, null, null));
66                 Assert.assertEquals(gc.getTime(),Organization.NULL.whenToValidate(null, null));
67                 Assert.assertEquals(gc,Organization.NULL.expiration(gc, Expiration.Password));
68                 Assert.assertTrue(Organization.NULL.getApprovers(trans, null) instanceof ArrayList);
69                 Assert.assertEquals("",Organization.NULL.getApproverType());
70                 Assert.assertEquals(0,Organization.NULL.startOfDay());
71                 Assert.assertFalse(Organization.NULL.canHaveMultipleCreds(null));
72                 Assert.assertFalse(Organization.NULL.isValidCred(trans, null));
73                 Assert.assertEquals("Null Organization rejects all Policies",Organization.NULL.validate(trans, Policy.CHANGE_JOB, null, null));
74                 Assert.assertFalse(Organization.NULL.isTestEnv());
75                 Organization.NULL.setTestMode(true);
76                 
77                 //tests for org emailWarnings
78                 Assert.assertTrue(Organization.NULL.emailWarningPolicy() instanceof EmailWarnings);     
79                 Assert.assertEquals(604800000L, Organization.NULL.emailWarningPolicy().credEmailInterval());
80                 Assert.assertEquals(604800000L, Organization.NULL.emailWarningPolicy().roleEmailInterval());
81                 Assert.assertEquals(259200000L, Organization.NULL.emailWarningPolicy().apprEmailInterval());
82                 Assert.assertEquals(2592000000L, Organization.NULL.emailWarningPolicy().credExpirationWarning());
83                 Assert.assertEquals(2592000000L, Organization.NULL.emailWarningPolicy().roleExpirationWarning());
84                 Assert.assertEquals(1209600000L, Organization.NULL.emailWarningPolicy().emailUrgentWarning());
85                 Assert.assertTrue(Organization.NULL.getPasswordRules() instanceof String[]);
86
87         }
88
89 }