1 /*******************************************************************************
2 * ============LICENSE_START====================================================
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
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====================================================
21 ******************************************************************************/
22 package org.onap.aaf.auth.service.validation.test;
24 import static org.junit.Assert.assertFalse;
25 import static org.junit.Assert.assertTrue;
27 import java.util.HashSet;
30 import org.junit.Before;
31 import org.junit.Test;
32 import org.onap.aaf.auth.dao.cass.PermDAO;
33 import org.onap.aaf.auth.dao.cass.RoleDAO;
34 import org.onap.aaf.auth.layer.Result;
35 import org.onap.aaf.auth.service.validation.ServiceValidator;
36 import org.onap.aaf.auth.validation.Validator;
38 public class JU_ServiceValidator {
40 ServiceValidator validator;
44 validator = new ServiceValidator();
48 public void permNotOk() {
50 Result<PermDAO.Data> rpd = Result.err(1, "ERR_Security");
53 assertTrue(validator.errs().equals("ERR_Security\n"));
58 public void permOkNull() {
60 Result rpd = Result.ok();
63 assertTrue(validator.errs().equals("Perm Data is null.\n"));
68 public void roleOkNull() {
70 Result rrd = Result.ok();
73 assertTrue(validator.errs().equals("Role Data is null.\n"));
77 public void roleOk() {
78 RoleDAO.Data to = new RoleDAO.Data();
81 to.description = "description";
82 Set<String> permissions = new HashSet<String>();
83 permissions.add("perm1");
84 to.perms = permissions;
86 Result<RoleDAO.Data> rrd = Result.ok(to);
90 validator.errs().equals("Perm [perm1] in Role [namespace.name] is not correctly separated with '|'\n"));
94 public void roleNotOk() {
96 Result rrd = Result.err(1, "ERR_Security");
99 assertTrue(validator.errs().equals("ERR_Security\n"));