summaryrefslogtreecommitdiffstats
path: root/auth/auth-oauth/src/test
diff options
context:
space:
mode:
authorInstrumental <jonathan.gathman@att.com>2018-09-07 12:21:34 -0500
committerInstrumental <jonathan.gathman@att.com>2018-09-07 12:22:50 -0500
commit4b5a7d721d994a49057e9bfb403c7bff1b376660 (patch)
treea36d03227b63a3e60346d6c3ca87b061087dae85 /auth/auth-oauth/src/test
parent824dc7b5fc0e1ccdf7f460479aff344727f0f01e (diff)
Mass removal of all Tabs (Style Warnings)
Issue-ID: AAF-473 Change-Id: Iaf0ef8120882937959bb0065f2f6ba74a021940f Signed-off-by: Instrumental <jonathan.gathman@att.com>
Diffstat (limited to 'auth/auth-oauth/src/test')
-rw-r--r--auth/auth-oauth/src/test/java/org/onap/aaf/auth/oauth/JU_DirectOAuthTAF.java146
-rw-r--r--auth/auth-oauth/src/test/java/org/onap/aaf/auth/oauth/JU_OACodeTest.java42
-rw-r--r--auth/auth-oauth/src/test/java/org/onap/aaf/auth/oauth/JU_OAuth2FilterTest.java94
-rw-r--r--auth/auth-oauth/src/test/java/org/onap/aaf/auth/oauth/JU_OAuth2FormHttpTafRespTest.java36
-rw-r--r--auth/auth-oauth/src/test/java/org/onap/aaf/auth/oauth/facade/JU_DirectOAFacadeImplTest.java10
-rw-r--r--auth/auth-oauth/src/test/java/org/onap/aaf/auth/oauth/facade/JU_OAFacadeFactory.java70
-rw-r--r--auth/auth-oauth/src/test/java/org/onap/aaf/auth/oauth/mapper/JU_Mapper1_0Test.java266
-rw-r--r--auth/auth-oauth/src/test/java/org/onap/aaf/auth/oauth/mapper/JU_MapperIntrospect1_0Test.java70
-rw-r--r--auth/auth-oauth/src/test/java/org/onap/aaf/auth/oauth/service/JU_JSONPermLoaderFactoryTest.java208
-rw-r--r--auth/auth-oauth/src/test/java/org/onap/aaf/auth/oauth/service/JU_OCredsTest.java38
10 files changed, 490 insertions, 490 deletions
diff --git a/auth/auth-oauth/src/test/java/org/onap/aaf/auth/oauth/JU_DirectOAuthTAF.java b/auth/auth-oauth/src/test/java/org/onap/aaf/auth/oauth/JU_DirectOAuthTAF.java
index ed80b10c..61608a17 100644
--- a/auth/auth-oauth/src/test/java/org/onap/aaf/auth/oauth/JU_DirectOAuthTAF.java
+++ b/auth/auth-oauth/src/test/java/org/onap/aaf/auth/oauth/JU_DirectOAuthTAF.java
@@ -50,78 +50,78 @@ import aafoauth.v2_0.Introspect;
public class JU_DirectOAuthTAF {
- @Mock
- private AuthzEnv env;
-
- @Mock
- private PropAccess access;
-
- private Properties props = new Properties();
-
- @Mock
- private HttpServletRequest req;
-
- private Map<String, String[]> parameterMap;
- @Mock
- private DirectIntrospect<Introspect> facade;
- @Mock
- private AuthzTrans trans;
- @Mock
- private Result<Introspect> ri;
-
- @Before
- public void setup() {
- initMocks(this);
- parameterMap = new TreeMap<String, String[]>();
-
- }
-
- @Test
- public void testValidateWithoutSecret() throws APIException, CadiException {
- parameterMap.put("client_id", new String[] { "Client1" });
- // parameterMap.put("client_secret", new String[] { "Secret1" });
- parameterMap.put("username", new String[] { "User1" });
- parameterMap.put("password", new String[] { "Pass1" });
- parameterMap.put("token", new String[] { "token1" });
- when(env.access()).thenReturn(access);
- when(access.getProperties()).thenReturn(props);
- when(req.getContentType()).thenReturn("application/x-www-form-urlencoded");
- when(req.getParameterMap()).thenReturn(parameterMap);
-
- DirectOAuthTAF oAuthTaf = new DirectOAuthTAF(env, null, null);
-
- TafResp validate = oAuthTaf.validate(null, req, null);
-
- assertNotNull(validate);
- assertEquals(validate.getAccess(), access);
- assertEquals(validate.desc(), "client_id and client_secret required");
- }
-
- @Test
- public void testValidateWithSecret() throws APIException, CadiException {
- parameterMap.put("client_id", new String[] { "Client1" });
- parameterMap.put("client_secret", new String[] { "Secret1" });
- parameterMap.put("username", new String[] { "User1" });
- parameterMap.put("password", new String[] { "Pass1" });
- parameterMap.put("token", new String[] { "token1" });
-
- when(env.access()).thenReturn(access);
- when(access.getProperties()).thenReturn(props);
- when(req.getContentType()).thenReturn("application/x-www-form-urlencoded");
- when(req.getParameterMap()).thenReturn(parameterMap);
- when(req.getAttribute(TransFilter.TRANS_TAG)).thenReturn(trans);
- when(facade.mappedIntrospect(trans, "token1")).thenReturn(ri);
-
- DirectOAuthTAF oAuthTaf = new DirectOAuthTAF(env, null, facade);
-
- TafResp validate = oAuthTaf.validate(null, req, null);
-
- assertNotNull(validate);
- assertEquals(validate.getAccess(), access);
- assertEquals(validate.desc(), ri.errorString());
-
- assertNull(oAuthTaf.revalidate(null, null));
- assertNotNull(oAuthTaf.directUserPass());
- }
+ @Mock
+ private AuthzEnv env;
+
+ @Mock
+ private PropAccess access;
+
+ private Properties props = new Properties();
+
+ @Mock
+ private HttpServletRequest req;
+
+ private Map<String, String[]> parameterMap;
+ @Mock
+ private DirectIntrospect<Introspect> facade;
+ @Mock
+ private AuthzTrans trans;
+ @Mock
+ private Result<Introspect> ri;
+
+ @Before
+ public void setup() {
+ initMocks(this);
+ parameterMap = new TreeMap<String, String[]>();
+
+ }
+
+ @Test
+ public void testValidateWithoutSecret() throws APIException, CadiException {
+ parameterMap.put("client_id", new String[] { "Client1" });
+ // parameterMap.put("client_secret", new String[] { "Secret1" });
+ parameterMap.put("username", new String[] { "User1" });
+ parameterMap.put("password", new String[] { "Pass1" });
+ parameterMap.put("token", new String[] { "token1" });
+ when(env.access()).thenReturn(access);
+ when(access.getProperties()).thenReturn(props);
+ when(req.getContentType()).thenReturn("application/x-www-form-urlencoded");
+ when(req.getParameterMap()).thenReturn(parameterMap);
+
+ DirectOAuthTAF oAuthTaf = new DirectOAuthTAF(env, null, null);
+
+ TafResp validate = oAuthTaf.validate(null, req, null);
+
+ assertNotNull(validate);
+ assertEquals(validate.getAccess(), access);
+ assertEquals(validate.desc(), "client_id and client_secret required");
+ }
+
+ @Test
+ public void testValidateWithSecret() throws APIException, CadiException {
+ parameterMap.put("client_id", new String[] { "Client1" });
+ parameterMap.put("client_secret", new String[] { "Secret1" });
+ parameterMap.put("username", new String[] { "User1" });
+ parameterMap.put("password", new String[] { "Pass1" });
+ parameterMap.put("token", new String[] { "token1" });
+
+ when(env.access()).thenReturn(access);
+ when(access.getProperties()).thenReturn(props);
+ when(req.getContentType()).thenReturn("application/x-www-form-urlencoded");
+ when(req.getParameterMap()).thenReturn(parameterMap);
+ when(req.getAttribute(TransFilter.TRANS_TAG)).thenReturn(trans);
+ when(facade.mappedIntrospect(trans, "token1")).thenReturn(ri);
+
+ DirectOAuthTAF oAuthTaf = new DirectOAuthTAF(env, null, facade);
+
+ TafResp validate = oAuthTaf.validate(null, req, null);
+
+ assertNotNull(validate);
+ assertEquals(validate.getAccess(), access);
+ assertEquals(validate.desc(), ri.errorString());
+
+ assertNull(oAuthTaf.revalidate(null, null));
+ assertNotNull(oAuthTaf.directUserPass());
+ }
}
diff --git a/auth/auth-oauth/src/test/java/org/onap/aaf/auth/oauth/JU_OACodeTest.java b/auth/auth-oauth/src/test/java/org/onap/aaf/auth/oauth/JU_OACodeTest.java
index 9ae7a012..22958736 100644
--- a/auth/auth-oauth/src/test/java/org/onap/aaf/auth/oauth/JU_OACodeTest.java
+++ b/auth/auth-oauth/src/test/java/org/onap/aaf/auth/oauth/JU_OACodeTest.java
@@ -39,33 +39,33 @@ import aafoauth.v2_0.Introspect;
public class JU_OACodeTest {
- @Mock
- private OAFacade<Introspect> facade;
+ @Mock
+ private OAFacade<Introspect> facade;
- @Mock
- private OAFacade<Introspect> facade1;
+ @Mock
+ private OAFacade<Introspect> facade1;
- @Before
- public void setup() {
- initMocks(this);
- }
+ @Before
+ public void setup() {
+ initMocks(this);
+ }
- @Test
- public void testOACodeDefaultMethod() throws Exception {
- OACode code = new OACode(facade, "Original Description", true, "role1") {
+ @Test
+ public void testOACodeDefaultMethod() throws Exception {
+ OACode code = new OACode(facade, "Original Description", true, "role1") {
- @Override
- public void handle(AuthzTrans trans, HttpServletRequest req, HttpServletResponse resp) throws Exception {
- // Blank implementation to test abstract OACode class.
- }
- };
+ @Override
+ public void handle(AuthzTrans trans, HttpServletRequest req, HttpServletResponse resp) throws Exception {
+ // Blank implementation to test abstract OACode class.
+ }
+ };
- OACode clone = code.clone(facade1, false);
+ OACode clone = code.clone(facade1, false);
- assertNotSame(code, clone);
+ assertNotSame(code, clone);
- assertTrue(code.useJSON);
- assertFalse(clone.useJSON);
+ assertTrue(code.useJSON);
+ assertFalse(clone.useJSON);
- }
+ }
}
diff --git a/auth/auth-oauth/src/test/java/org/onap/aaf/auth/oauth/JU_OAuth2FilterTest.java b/auth/auth-oauth/src/test/java/org/onap/aaf/auth/oauth/JU_OAuth2FilterTest.java
index 56dc669d..56eba95b 100644
--- a/auth/auth-oauth/src/test/java/org/onap/aaf/auth/oauth/JU_OAuth2FilterTest.java
+++ b/auth/auth-oauth/src/test/java/org/onap/aaf/auth/oauth/JU_OAuth2FilterTest.java
@@ -38,51 +38,51 @@ import org.onap.aaf.cadi.principal.BearerPrincipal;
public class JU_OAuth2FilterTest {
- @Mock
- private HttpServletRequest request;
- @Mock
- private FilterChain chain;
- @Mock
- private BearerPrincipal principal;
-
- @Before
- public void setup() {
- initMocks(this);
- }
-
- @Test
- public void testDoFilterWithContentType() throws IOException, ServletException {
- when(request.getContentType()).thenReturn("application/x-www-form-urlencoded");
-
- OAuth2Filter filter = new OAuth2Filter();
- filter.doFilter(request, null, chain);
-
- verify(chain, only()).doFilter(request, null);
- }
-
- @Test
- public void testDoFilter() throws IOException, ServletException {
- when(request.getContentType()).thenReturn("somethingElse");
- when(request.getUserPrincipal()).thenReturn(principal);
- when(request.getHeader("Authorization")).thenReturn("Bearer 1;Bearer2");
-
- OAuth2Filter filter = new OAuth2Filter();
- filter.init(null);
- filter.destroy();
- filter.doFilter(request, null, chain);
-
- verify(chain, only()).doFilter(request, null);
- verify(principal, only()).setBearer("1");
- }
-
- @Test
- public void testDoFilterWithoutBearerPrincipal() throws IOException, ServletException {
- when(request.getContentType()).thenReturn("somethingElse");
- when(request.getHeader("Authorization")).thenReturn("Bearer 1;Bearer2");
-
- OAuth2Filter filter = new OAuth2Filter();
- filter.doFilter(request, null, chain);
-
- verify(chain, only()).doFilter(request, null);
- }
+ @Mock
+ private HttpServletRequest request;
+ @Mock
+ private FilterChain chain;
+ @Mock
+ private BearerPrincipal principal;
+
+ @Before
+ public void setup() {
+ initMocks(this);
+ }
+
+ @Test
+ public void testDoFilterWithContentType() throws IOException, ServletException {
+ when(request.getContentType()).thenReturn("application/x-www-form-urlencoded");
+
+ OAuth2Filter filter = new OAuth2Filter();
+ filter.doFilter(request, null, chain);
+
+ verify(chain, only()).doFilter(request, null);
+ }
+
+ @Test
+ public void testDoFilter() throws IOException, ServletException {
+ when(request.getContentType()).thenReturn("somethingElse");
+ when(request.getUserPrincipal()).thenReturn(principal);
+ when(request.getHeader("Authorization")).thenReturn("Bearer 1;Bearer2");
+
+ OAuth2Filter filter = new OAuth2Filter();
+ filter.init(null);
+ filter.destroy();
+ filter.doFilter(request, null, chain);
+
+ verify(chain, only()).doFilter(request, null);
+ verify(principal, only()).setBearer("1");
+ }
+
+ @Test
+ public void testDoFilterWithoutBearerPrincipal() throws IOException, ServletException {
+ when(request.getContentType()).thenReturn("somethingElse");
+ when(request.getHeader("Authorization")).thenReturn("Bearer 1;Bearer2");
+
+ OAuth2Filter filter = new OAuth2Filter();
+ filter.doFilter(request, null, chain);
+
+ verify(chain, only()).doFilter(request, null);
+ }
}
diff --git a/auth/auth-oauth/src/test/java/org/onap/aaf/auth/oauth/JU_OAuth2FormHttpTafRespTest.java b/auth/auth-oauth/src/test/java/org/onap/aaf/auth/oauth/JU_OAuth2FormHttpTafRespTest.java
index 7a332fa3..8913cceb 100644
--- a/auth/auth-oauth/src/test/java/org/onap/aaf/auth/oauth/JU_OAuth2FormHttpTafRespTest.java
+++ b/auth/auth-oauth/src/test/java/org/onap/aaf/auth/oauth/JU_OAuth2FormHttpTafRespTest.java
@@ -37,28 +37,28 @@ import org.onap.aaf.cadi.taf.TafResp.RESP;
public class JU_OAuth2FormHttpTafRespTest {
- @Mock
- private HttpServletResponse resp;
+ @Mock
+ private HttpServletResponse resp;
- @Before
- public void setup() {
- initMocks(this);
- }
+ @Before
+ public void setup() {
+ initMocks(this);
+ }
- @Test
- public void testAuthenticated() throws IOException {
- OAuth2FormHttpTafResp oAuth2 = new OAuth2FormHttpTafResp(null, null, null, null, resp);
+ @Test
+ public void testAuthenticated() throws IOException {
+ OAuth2FormHttpTafResp oAuth2 = new OAuth2FormHttpTafResp(null, null, null, null, resp);
- assertEquals(oAuth2.authenticate(), RESP.HTTP_REDIRECT_INVOKED);
+ assertEquals(oAuth2.authenticate(), RESP.HTTP_REDIRECT_INVOKED);
- verify(resp, only()).setStatus(401);
- }
+ verify(resp, only()).setStatus(401);
+ }
- @Test
- public void testIsAuthenticated() throws IOException {
- OAuth2FormHttpTafResp oAuth2 = new OAuth2FormHttpTafResp(null, null, null, RESP.HAS_PROCESSED, null, false);
+ @Test
+ public void testIsAuthenticated() throws IOException {
+ OAuth2FormHttpTafResp oAuth2 = new OAuth2FormHttpTafResp(null, null, null, RESP.HAS_PROCESSED, null, false);
- assertEquals(oAuth2.isAuthenticated(), RESP.HAS_PROCESSED);
- assertFalse(oAuth2.isFailedAttempt());
- }
+ assertEquals(oAuth2.isAuthenticated(), RESP.HAS_PROCESSED);
+ assertFalse(oAuth2.isFailedAttempt());
+ }
}
diff --git a/auth/auth-oauth/src/test/java/org/onap/aaf/auth/oauth/facade/JU_DirectOAFacadeImplTest.java b/auth/auth-oauth/src/test/java/org/onap/aaf/auth/oauth/facade/JU_DirectOAFacadeImplTest.java
index 1393f291..6e6722f9 100644
--- a/auth/auth-oauth/src/test/java/org/onap/aaf/auth/oauth/facade/JU_DirectOAFacadeImplTest.java
+++ b/auth/auth-oauth/src/test/java/org/onap/aaf/auth/oauth/facade/JU_DirectOAFacadeImplTest.java
@@ -27,10 +27,10 @@ import org.junit.Test;
public class JU_DirectOAFacadeImplTest {
- @Test
- public void test() {
- DirectOAFacadeImpl oAFacade = new DirectOAFacadeImpl();
- assertNotNull(oAFacade);
- }
+ @Test
+ public void test() {
+ DirectOAFacadeImpl oAFacade = new DirectOAFacadeImpl();
+ assertNotNull(oAFacade);
+ }
}
diff --git a/auth/auth-oauth/src/test/java/org/onap/aaf/auth/oauth/facade/JU_OAFacadeFactory.java b/auth/auth-oauth/src/test/java/org/onap/aaf/auth/oauth/facade/JU_OAFacadeFactory.java
index bf9cbdd6..3c7b2970 100644
--- a/auth/auth-oauth/src/test/java/org/onap/aaf/auth/oauth/facade/JU_OAFacadeFactory.java
+++ b/auth/auth-oauth/src/test/java/org/onap/aaf/auth/oauth/facade/JU_OAFacadeFactory.java
@@ -37,51 +37,51 @@ import aafoauth.v2_0.Introspect;
public class JU_OAFacadeFactory {
- @Mock
- private OAuthService service;
+ @Mock
+ private OAuthService service;
- private String token;
+ private String token;
- private AuthzTrans trans;
- @Mock
- private Result<Data> rs;
+ private AuthzTrans trans;
+ @Mock
+ private Result<Data> rs;
- @Before
- public void setUp() throws Exception {
- initMocks(this);
- }
+ @Before
+ public void setUp() throws Exception {
+ initMocks(this);
+ }
- @Test
- public void testStatusNotOk() throws APIException {
- when(service.introspect(trans, token)).thenReturn(rs);
- when(rs.notOK()).thenReturn(true);
+ @Test
+ public void testStatusNotOk() throws APIException {
+ when(service.introspect(trans, token)).thenReturn(rs);
+ when(rs.notOK()).thenReturn(true);
- DirectIntrospect<Introspect> direct = OAFacadeFactory.directV1_0(service);
- Result<Introspect> rti = direct.mappedIntrospect(trans, token);
+ DirectIntrospect<Introspect> direct = OAFacadeFactory.directV1_0(service);
+ Result<Introspect> rti = direct.mappedIntrospect(trans, token);
- assertEquals(rti.status, 0);
- }
+ assertEquals(rti.status, 0);
+ }
- @Test
- public void testStatusOk() throws APIException {
- when(service.introspect(trans, token)).thenReturn(rs);
- when(rs.notOK()).thenReturn(false);
+ @Test
+ public void testStatusOk() throws APIException {
+ when(service.introspect(trans, token)).thenReturn(rs);
+ when(rs.notOK()).thenReturn(false);
- DirectIntrospect<Introspect> directV1_0 = OAFacadeFactory.directV1_0(service);
- Result<Introspect> rti = directV1_0.mappedIntrospect(trans, token);
+ DirectIntrospect<Introspect> directV1_0 = OAFacadeFactory.directV1_0(service);
+ Result<Introspect> rti = directV1_0.mappedIntrospect(trans, token);
- assertEquals(rti.status, 0);
- }
+ assertEquals(rti.status, 0);
+ }
- @Test
- public void testStatusOkWithResultSetEmpty() throws APIException {
- when(service.introspect(trans, token)).thenReturn(rs);
- when(rs.isEmpty()).thenReturn(true);
- when(rs.notOK()).thenReturn(false);
+ @Test
+ public void testStatusOkWithResultSetEmpty() throws APIException {
+ when(service.introspect(trans, token)).thenReturn(rs);
+ when(rs.isEmpty()).thenReturn(true);
+ when(rs.notOK()).thenReturn(false);
- DirectIntrospect<Introspect> directV1_0 = OAFacadeFactory.directV1_0(service);
- Result<Introspect> rti = directV1_0.mappedIntrospect(trans, token);
+ DirectIntrospect<Introspect> directV1_0 = OAFacadeFactory.directV1_0(service);
+ Result<Introspect> rti = directV1_0.mappedIntrospect(trans, token);
- assertEquals(rti.status, Result.ERR_NotFound);
- }
+ assertEquals(rti.status, Result.ERR_NotFound);
+ }
}
diff --git a/auth/auth-oauth/src/test/java/org/onap/aaf/auth/oauth/mapper/JU_Mapper1_0Test.java b/auth/auth-oauth/src/test/java/org/onap/aaf/auth/oauth/mapper/JU_Mapper1_0Test.java
index c872cb8e..3a0a40d9 100644
--- a/auth/auth-oauth/src/test/java/org/onap/aaf/auth/oauth/mapper/JU_Mapper1_0Test.java
+++ b/auth/auth-oauth/src/test/java/org/onap/aaf/auth/oauth/mapper/JU_Mapper1_0Test.java
@@ -49,178 +49,178 @@ import aafoauth.v2_0.Token;
import aafoauth.v2_0.TokenRequest;
public class JU_Mapper1_0Test {
- @Mock
- private HttpServletRequest req;
-
- @Mock
- private TokenRequest tokenRequest;
-
- @Mock
- private Holder<GRANT_TYPE> hgt;
-
- @Mock(answer = Answers.RETURNS_DEEP_STUBS)
- private OAuth2Principal p;
-
- private Data data;
-
- @Before
- public void setup() {
- initMocks(this);
- data = new Data();
- data.id = "id";
- }
-
- @Test
- public void testMapper() {
- Mapper<TokenRequest, Token, Introspect, Error> mapper = new Mapper1_0();
- assertEquals(TokenRequest.class, mapper.getClass(API.TOKEN_REQ));
- assertEquals(Token.class, mapper.getClass(API.TOKEN));
- assertEquals(Introspect.class, mapper.getClass(API.INTROSPECT));
- assertEquals(Error.class, mapper.getClass(API.ERROR));
- assertEquals(Void.class, mapper.getClass(API.VOID));
-
- assertTrue(mapper.newInstance(API.TOKEN_REQ) instanceof TokenRequest);
- assertTrue(mapper.newInstance(API.TOKEN) instanceof Token);
- assertTrue(mapper.newInstance(API.INTROSPECT) instanceof Introspect);
- assertTrue(mapper.newInstance(API.ERROR) instanceof Error);
- assertEquals(null, mapper.newInstance(API.VOID));
+ @Mock
+ private HttpServletRequest req;
+
+ @Mock
+ private TokenRequest tokenRequest;
+
+ @Mock
+ private Holder<GRANT_TYPE> hgt;
+
+ @Mock(answer = Answers.RETURNS_DEEP_STUBS)
+ private OAuth2Principal p;
+
+ private Data data;
+
+ @Before
+ public void setup() {
+ initMocks(this);
+ data = new Data();
+ data.id = "id";
+ }
+
+ @Test
+ public void testMapper() {
+ Mapper<TokenRequest, Token, Introspect, Error> mapper = new Mapper1_0();
+ assertEquals(TokenRequest.class, mapper.getClass(API.TOKEN_REQ));
+ assertEquals(Token.class, mapper.getClass(API.TOKEN));
+ assertEquals(Introspect.class, mapper.getClass(API.INTROSPECT));
+ assertEquals(Error.class, mapper.getClass(API.ERROR));
+ assertEquals(Void.class, mapper.getClass(API.VOID));
+
+ assertTrue(mapper.newInstance(API.TOKEN_REQ) instanceof TokenRequest);
+ assertTrue(mapper.newInstance(API.TOKEN) instanceof Token);
+ assertTrue(mapper.newInstance(API.INTROSPECT) instanceof Introspect);
+ assertTrue(mapper.newInstance(API.ERROR) instanceof Error);
+ assertEquals(null, mapper.newInstance(API.VOID));
- Error error = mapper.errorFromMessage(null, null, "text", "var1", "var2");
- assertEquals("text", error.getText());
+ Error error = mapper.errorFromMessage(null, null, "text", "var1", "var2");
+ assertEquals("text", error.getText());
- Object tokenReqFromParams = mapper.tokenReqFromParams(req);
- assertNull(tokenReqFromParams);
- }
+ Object tokenReqFromParams = mapper.tokenReqFromParams(req);
+ assertNull(tokenReqFromParams);
+ }
- @Test
- public void testTokeReqFromParams() {
- Map<String, String[]> parameterMap = new TreeMap<String, String[]>();
- parameterMap.put("client_id", new String[] { "ClientId1" });
- parameterMap.put("client_secret", new String[] { "client_secret" });
- parameterMap.put("username", new String[] { "username" });
- parameterMap.put("password", new String[] { "password" });
- parameterMap.put("scope", new String[] { "scope" });
- parameterMap.put("grant_type", new String[] { "grant_type" });
- parameterMap.put("refresh_token", new String[] { "refresh_token" });
- parameterMap.put("etc", new String[] { "etc" });
- when(req.getParameterMap()).thenReturn(parameterMap);
+ @Test
+ public void testTokeReqFromParams() {
+ Map<String, String[]> parameterMap = new TreeMap<String, String[]>();
+ parameterMap.put("client_id", new String[] { "ClientId1" });
+ parameterMap.put("client_secret", new String[] { "client_secret" });
+ parameterMap.put("username", new String[] { "username" });
+ parameterMap.put("password", new String[] { "password" });
+ parameterMap.put("scope", new String[] { "scope" });
+ parameterMap.put("grant_type", new String[] { "grant_type" });
+ parameterMap.put("refresh_token", new String[] { "refresh_token" });
+ parameterMap.put("etc", new String[] { "etc" });
+ when(req.getParameterMap()).thenReturn(parameterMap);
- Mapper<TokenRequest, Token, Introspect, Error> mapper = new Mapper1_0();
+ Mapper<TokenRequest, Token, Introspect, Error> mapper = new Mapper1_0();
- TokenRequest param = mapper.tokenReqFromParams(req);
+ TokenRequest param = mapper.tokenReqFromParams(req);
- assertEquals("ClientId1", param.getClientId());
- assertEquals("client_secret", param.getClientSecret());
- assertEquals("username", param.getUsername());
- assertEquals("password", param.getPassword());
- assertEquals("scope", param.getScope());
- assertEquals("grant_type", param.getGrantType());
- assertEquals("refresh_token", param.getRefreshToken());
+ assertEquals("ClientId1", param.getClientId());
+ assertEquals("client_secret", param.getClientSecret());
+ assertEquals("username", param.getUsername());
+ assertEquals("password", param.getPassword());
+ assertEquals("scope", param.getScope());
+ assertEquals("grant_type", param.getGrantType());
+ assertEquals("refresh_token", param.getRefreshToken());
- OCreds credsFromReq = mapper.credsFromReq(param);
- assertEquals("ClientId1", credsFromReq.client_id);
- assertEquals("username", credsFromReq.username);
+ OCreds credsFromReq = mapper.credsFromReq(param);
+ assertEquals("ClientId1", credsFromReq.client_id);
+ assertEquals("username", credsFromReq.username);
- }
+ }
- @Test
- public void testTokeReqFromParamsWithNoValues() {
- Map<String, String[]> parameterMap = new TreeMap<String, String[]>();
- parameterMap.put("client_id", new String[] {});
- parameterMap.put("client_secret", new String[] {});
- parameterMap.put("username", new String[] {});
- parameterMap.put("password", new String[] {});
- parameterMap.put("scope", new String[] {});
- parameterMap.put("grant_type", new String[] {});
- parameterMap.put("refresh_token", new String[] {});
- parameterMap.put("etc", new String[] {});
- when(req.getParameterMap()).thenReturn(parameterMap);
+ @Test
+ public void testTokeReqFromParamsWithNoValues() {
+ Map<String, String[]> parameterMap = new TreeMap<String, String[]>();
+ parameterMap.put("client_id", new String[] {});
+ parameterMap.put("client_secret", new String[] {});
+ parameterMap.put("username", new String[] {});
+ parameterMap.put("password", new String[] {});
+ parameterMap.put("scope", new String[] {});
+ parameterMap.put("grant_type", new String[] {});
+ parameterMap.put("refresh_token", new String[] {});
+ parameterMap.put("etc", new String[] {});
+ when(req.getParameterMap()).thenReturn(parameterMap);
- Mapper<TokenRequest, Token, Introspect, Error> mapper = new Mapper1_0();
+ Mapper<TokenRequest, Token, Introspect, Error> mapper = new Mapper1_0();
- Object param = mapper.tokenReqFromParams(req);
+ Object param = mapper.tokenReqFromParams(req);
- assertNull(param);
+ assertNull(param);
- }
+ }
- @Test
- public void testClientTokenReqWithClientCred() {
- when(hgt.get()).thenReturn(GRANT_TYPE.client_credentials);
- when(tokenRequest.getState()).thenReturn("State");
- when(tokenRequest.getGrantType()).thenReturn("client_credentials");
- when(tokenRequest.getScope()).thenReturn("Scope");
+ @Test
+ public void testClientTokenReqWithClientCred() {
+ when(hgt.get()).thenReturn(GRANT_TYPE.client_credentials);
+ when(tokenRequest.getState()).thenReturn("State");
+ when(tokenRequest.getGrantType()).thenReturn("client_credentials");
+ when(tokenRequest.getScope()).thenReturn("Scope");
- Mapper<TokenRequest, Token, Introspect, Error> mapper = new Mapper1_0();
+ Mapper<TokenRequest, Token, Introspect, Error> mapper = new Mapper1_0();
- Data clientTokenReq = mapper.clientTokenReq(tokenRequest, hgt);
+ Data clientTokenReq = mapper.clientTokenReq(tokenRequest, hgt);
- assertEquals("State", clientTokenReq.state);
- assertTrue(clientTokenReq.scopes.contains("Scope"));
+ assertEquals("State", clientTokenReq.state);
+ assertTrue(clientTokenReq.scopes.contains("Scope"));
- }
+ }
- @Test
- public void testClientTokenReqWithPassword() {
- when(hgt.get()).thenReturn(GRANT_TYPE.unknown);
- when(tokenRequest.getState()).thenReturn("State");
- when(tokenRequest.getRefreshToken()).thenReturn("UnKnown");
+ @Test
+ public void testClientTokenReqWithPassword() {
+ when(hgt.get()).thenReturn(GRANT_TYPE.unknown);
+ when(tokenRequest.getState()).thenReturn("State");
+ when(tokenRequest.getRefreshToken()).thenReturn("UnKnown");
- Mapper<TokenRequest, Token, Introspect, Error> mapper = new Mapper1_0();
+ Mapper<TokenRequest, Token, Introspect, Error> mapper = new Mapper1_0();
- Data clientTokenReq = mapper.clientTokenReq(tokenRequest, hgt);
+ Data clientTokenReq = mapper.clientTokenReq(tokenRequest, hgt);
- assertEquals("State", clientTokenReq.state);
- assertEquals(clientTokenReq.type, 0);
- }
+ assertEquals("State", clientTokenReq.state);
+ assertEquals(clientTokenReq.type, 0);
+ }
- @Test
- public void testTokenFromDataWithNotOk() {
- Result<Data> dataResult = Result.create(null, 1, "detail", "var");
+ @Test
+ public void testTokenFromDataWithNotOk() {
+ Result<Data> dataResult = Result.create(null, 1, "detail", "var");
- Mapper<TokenRequest, Token, Introspect, Error> mapper = new Mapper1_0();
+ Mapper<TokenRequest, Token, Introspect, Error> mapper = new Mapper1_0();
- Result<Token> clientTokenReq = mapper.tokenFromData(dataResult);
+ Result<Token> clientTokenReq = mapper.tokenFromData(dataResult);
- assertEquals(null, clientTokenReq.value);
- }
+ assertEquals(null, clientTokenReq.value);
+ }
- @Test
- public void testTokenFromData() {
+ @Test
+ public void testTokenFromData() {
- Result<Data> dataResult = Result.create(data, 0, "detail", "var");
+ Result<Data> dataResult = Result.create(data, 0, "detail", "var");
- Mapper<TokenRequest, Token, Introspect, Error> mapper = new Mapper1_0();
+ Mapper<TokenRequest, Token, Introspect, Error> mapper = new Mapper1_0();
- Result<Token> clientTokenReq = mapper.tokenFromData(dataResult);
+ Result<Token> clientTokenReq = mapper.tokenFromData(dataResult);
- assertEquals(clientTokenReq.value.getAccessToken(), data.id);
- }
+ assertEquals(clientTokenReq.value.getAccessToken(), data.id);
+ }
- @Test
- public void testTokenFromDataWithNoTokenType() {
- data.type = 20;
+ @Test
+ public void testTokenFromDataWithNoTokenType() {
+ data.type = 20;
- Result<Data> dataResult = Result.create(data, 0, "detail", "var");
+ Result<Data> dataResult = Result.create(data, 0, "detail", "var");
- Mapper<TokenRequest, Token, Introspect, Error> mapper = new Mapper1_0();
+ Mapper<TokenRequest, Token, Introspect, Error> mapper = new Mapper1_0();
- Result<Token> clientTokenReq = mapper.tokenFromData(dataResult);
+ Result<Token> clientTokenReq = mapper.tokenFromData(dataResult);
- assertEquals(clientTokenReq.value.getAccessToken(), data.id);
- assertEquals(clientTokenReq.value.getTokenType(), "Invalid");
- }
+ assertEquals(clientTokenReq.value.getAccessToken(), data.id);
+ assertEquals(clientTokenReq.value.getTokenType(), "Invalid");
+ }
- @Test
- public void testFromPrincipal() {
+ @Test
+ public void testFromPrincipal() {
- Introspect introspect = new Introspect();
- when(p.tokenPerm().getIntrospect()).thenReturn(introspect);
+ Introspect introspect = new Introspect();
+ when(p.tokenPerm().getIntrospect()).thenReturn(introspect);
- Mapper<TokenRequest, Token, Introspect, Error> mapper = new Mapper1_0();
+ Mapper<TokenRequest, Token, Introspect, Error> mapper = new Mapper1_0();
- Introspect intro = mapper.fromPrincipal(p);
+ Introspect intro = mapper.fromPrincipal(p);
- assertEquals(introspect, intro);
- }
+ assertEquals(introspect, intro);
+ }
}
diff --git a/auth/auth-oauth/src/test/java/org/onap/aaf/auth/oauth/mapper/JU_MapperIntrospect1_0Test.java b/auth/auth-oauth/src/test/java/org/onap/aaf/auth/oauth/mapper/JU_MapperIntrospect1_0Test.java
index d303755f..f5e50d5e 100644
--- a/auth/auth-oauth/src/test/java/org/onap/aaf/auth/oauth/mapper/JU_MapperIntrospect1_0Test.java
+++ b/auth/auth-oauth/src/test/java/org/onap/aaf/auth/oauth/mapper/JU_MapperIntrospect1_0Test.java
@@ -37,58 +37,58 @@ import org.onap.aaf.auth.layer.Result;
import aafoauth.v2_0.Introspect;
public class JU_MapperIntrospect1_0Test {
- @Mock
- private HttpServletRequest req;
+ @Mock
+ private HttpServletRequest req;
- Data data;
+ Data data;
- @Before
- public void setup() {
- initMocks(this);
- data = new Data();
- }
+ @Before
+ public void setup() {
+ initMocks(this);
+ data = new Data();
+ }
- @Test
- public void testIntrospect() {
- data.type = 1;
+ @Test
+ public void testIntrospect() {
+ data.type = 1;
- Result<Data> dataResult = Result.create(data, 0, "detail", "var");
+ Result<Data> dataResult = Result.create(data, 0, "detail", "var");
- MapperIntrospect<Introspect> mapper = new MapperIntrospect1_0();
+ MapperIntrospect<Introspect> mapper = new MapperIntrospect1_0();
- Result<Introspect> intro = mapper.introspect(dataResult);
+ Result<Introspect> intro = mapper.introspect(dataResult);
- assertEquals(intro.value.getClientType(), "confidential");
- }
+ assertEquals(intro.value.getClientType(), "confidential");
+ }
- @Test
- public void testIntrospectWithUnknowType() {
- data.type = 5;
- data.scopes = new HashSet<String>();
+ @Test
+ public void testIntrospectWithUnknowType() {
+ data.type = 5;
+ data.scopes = new HashSet<String>();
- data.scopes.add(Scope.APPLICATION.toString());
- data.scopes.add(Scope.HANDLER.toString());
+ data.scopes.add(Scope.APPLICATION.toString());
+ data.scopes.add(Scope.HANDLER.toString());
- Result<Data> dataResult = Result.create(data, 0, "detail", "var");
+ Result<Data> dataResult = Result.create(data, 0, "detail", "var");
- MapperIntrospect<Introspect> mapper = new MapperIntrospect1_0();
+ MapperIntrospect<Introspect> mapper = new MapperIntrospect1_0();
- Result<Introspect> intro = mapper.introspect(dataResult);
+ Result<Introspect> intro = mapper.introspect(dataResult);
- assertEquals(intro.value.getClientType(), "unknown");
- }
+ assertEquals(intro.value.getClientType(), "unknown");
+ }
- @Test
- public void testIntrospectWithNotOk() {
- data.type = 5;
+ @Test
+ public void testIntrospectWithNotOk() {
+ data.type = 5;
- Result<Data> dataResult = Result.create(data, 1, "detail", "var");
+ Result<Data> dataResult = Result.create(data, 1, "detail", "var");
- MapperIntrospect<Introspect> mapper = new MapperIntrospect1_0();
+ MapperIntrospect<Introspect> mapper = new MapperIntrospect1_0();
- Result<Introspect> intro = mapper.introspect(dataResult);
+ Result<Introspect> intro = mapper.introspect(dataResult);
- assertEquals(intro.value, null);
- }
+ assertEquals(intro.value, null);
+ }
} \ No newline at end of file
diff --git a/auth/auth-oauth/src/test/java/org/onap/aaf/auth/oauth/service/JU_JSONPermLoaderFactoryTest.java b/auth/auth-oauth/src/test/java/org/onap/aaf/auth/oauth/service/JU_JSONPermLoaderFactoryTest.java
index 1a13580f..4a26da7d 100644
--- a/auth/auth-oauth/src/test/java/org/onap/aaf/auth/oauth/service/JU_JSONPermLoaderFactoryTest.java
+++ b/auth/auth-oauth/src/test/java/org/onap/aaf/auth/oauth/service/JU_JSONPermLoaderFactoryTest.java
@@ -54,147 +54,147 @@ import org.onap.aaf.misc.env.Env;
import org.onap.aaf.misc.env.TimeTaken;
public class JU_JSONPermLoaderFactoryTest {
- @Mock
- private AAFCon<?> aafcon;
- @Mock
- private AuthzTrans trans;
- @Mock
- private TimeTaken tt;
- @Mock
- Rcli c;
- @Mock
- private Future fs;
- @Mock
- private Question question;
- @Mock
- private Result<NsSplit> rdns;
- private NsSplit nss;
+ @Mock
+ private AAFCon<?> aafcon;
+ @Mock
+ private AuthzTrans trans;
+ @Mock
+ private TimeTaken tt;
+ @Mock
+ Rcli c;
+ @Mock
+ private Future fs;
+ @Mock
+ private Question question;
+ @Mock
+ private Result<NsSplit> rdns;
+ private NsSplit nss;
- private Access access;
+ private Access access;
- @Before
- public void setup() throws CadiException {
- access = new AuthzEnv();
- Define.set(access);
- initMocks(this);
- nss = new NsSplit("APPLICATION", "APPLICATION");
- }
+ @Before
+ public void setup() throws CadiException {
+ access = new AuthzEnv();
+ Define.set(access);
+ initMocks(this);
+ nss = new NsSplit("APPLICATION", "APPLICATION");
+ }
- @Test
- public void testRemoteWithTimeOut() throws APIException, CadiException {
- when(trans.start("Call AAF Service", Env.REMOTE)).thenReturn(tt);
- when(aafcon.clientAs(Config.AAF_DEFAULT_VERSION, trans.getUserPrincipal())).thenReturn(c);
- when(c.read("/authz/perms/user/null?scopes=APPLICATION:HANDLER",
- "application/Perms+json;charset=utf-8;version=2.0")).thenReturn(fs);
- when(fs.get(0)).thenReturn(true);
+ @Test
+ public void testRemoteWithTimeOut() throws APIException, CadiException {
+ when(trans.start("Call AAF Service", Env.REMOTE)).thenReturn(tt);
+ when(aafcon.clientAs(Config.AAF_DEFAULT_VERSION, trans.getUserPrincipal())).thenReturn(c);
+ when(c.read("/authz/perms/user/null?scopes=APPLICATION:HANDLER",
+ "application/Perms+json;charset=utf-8;version=2.0")).thenReturn(fs);
+ when(fs.get(0)).thenReturn(true);
- Set<String> scopes = new HashSet<String>();
- scopes.add(Scope.APPLICATION.toString());
- scopes.add(Scope.HANDLER.toString());
+ Set<String> scopes = new HashSet<String>();
+ scopes.add(Scope.APPLICATION.toString());
+ scopes.add(Scope.HANDLER.toString());
- JSONPermLoader factory = JSONPermLoaderFactory.remote(aafcon, 0);
+ JSONPermLoader factory = JSONPermLoaderFactory.remote(aafcon, 0);
- Result<String> loadJSONPerms = factory.loadJSONPerms(trans, null, scopes);
+ Result<String> loadJSONPerms = factory.loadJSONPerms(trans, null, scopes);
- assertEquals(0, loadJSONPerms.status);
+ assertEquals(0, loadJSONPerms.status);
- verify(tt, only()).done();
- }
+ verify(tt, only()).done();
+ }
- @Test
- public void testRemoteWith404() throws APIException, CadiException {
- when(trans.start("Call AAF Service", Env.REMOTE)).thenReturn(tt);
- when(aafcon.clientAs(Config.AAF_DEFAULT_VERSION, trans.getUserPrincipal())).thenReturn(c);
- when(c.read("/authz/perms/user/null?scopes=APPLICATION:HANDLER",
- "application/Perms+json;charset=utf-8;version=2.0")).thenReturn(fs);
- when(fs.get(0)).thenReturn(false);
- when(fs.code()).thenReturn(404);
+ @Test
+ public void testRemoteWith404() throws APIException, CadiException {
+ when(trans.start("Call AAF Service", Env.REMOTE)).thenReturn(tt);
+ when(aafcon.clientAs(Config.AAF_DEFAULT_VERSION, trans.getUserPrincipal())).thenReturn(c);
+ when(c.read("/authz/perms/user/null?scopes=APPLICATION:HANDLER",
+ "application/Perms+json;charset=utf-8;version=2.0")).thenReturn(fs);
+ when(fs.get(0)).thenReturn(false);
+ when(fs.code()).thenReturn(404);
- Set<String> scopes = new HashSet<String>();
- scopes.add(Scope.APPLICATION.toString());
- scopes.add(Scope.HANDLER.toString());
+ Set<String> scopes = new HashSet<String>();
+ scopes.add(Scope.APPLICATION.toString());
+ scopes.add(Scope.HANDLER.toString());
- JSONPermLoader factory = JSONPermLoaderFactory.remote(aafcon, 0);
+ JSONPermLoader factory = JSONPermLoaderFactory.remote(aafcon, 0);
- Result<String> loadJSONPerms = factory.loadJSONPerms(trans, null, scopes);
+ Result<String> loadJSONPerms = factory.loadJSONPerms(trans, null, scopes);
- assertEquals(Result.ERR_NotFound, loadJSONPerms.status);
+ assertEquals(Result.ERR_NotFound, loadJSONPerms.status);
- verify(tt, only()).done();
- }
+ verify(tt, only()).done();
+ }
- @Test
- public void testRemote() throws APIException, CadiException {
- when(trans.start("Call AAF Service", Env.REMOTE)).thenReturn(tt);
- when(aafcon.clientAs(Config.AAF_DEFAULT_VERSION, trans.getUserPrincipal())).thenReturn(c);
- when(c.read("/authz/perms/user/null?scopes=APPLICATION:HANDLER",
- "application/Perms+json;charset=utf-8;version=2.0")).thenReturn(fs);
- when(fs.get(0)).thenReturn(false);
+ @Test
+ public void testRemote() throws APIException, CadiException {
+ when(trans.start("Call AAF Service", Env.REMOTE)).thenReturn(tt);
+ when(aafcon.clientAs(Config.AAF_DEFAULT_VERSION, trans.getUserPrincipal())).thenReturn(c);
+ when(c.read("/authz/perms/user/null?scopes=APPLICATION:HANDLER",
+ "application/Perms+json;charset=utf-8;version=2.0")).thenReturn(fs);
+ when(fs.get(0)).thenReturn(false);
- Set<String> scopes = new HashSet<String>();
- scopes.add(Scope.APPLICATION.toString());
- scopes.add(Scope.HANDLER.toString());
+ Set<String> scopes = new HashSet<String>();
+ scopes.add(Scope.APPLICATION.toString());
+ scopes.add(Scope.HANDLER.toString());
- JSONPermLoader factory = JSONPermLoaderFactory.remote(aafcon, 0);
+ JSONPermLoader factory = JSONPermLoaderFactory.remote(aafcon, 0);
- Result<String> loadJSONPerms = factory.loadJSONPerms(trans, null, scopes);
+ Result<String> loadJSONPerms = factory.loadJSONPerms(trans, null, scopes);
- assertEquals(Result.ERR_Backend, loadJSONPerms.status);
+ assertEquals(Result.ERR_Backend, loadJSONPerms.status);
- verify(tt, only()).done();
- }
+ verify(tt, only()).done();
+ }
- @Test
- public void testDirectWhenPdNotOk() throws APIException, CadiException {
+ @Test
+ public void testDirectWhenPdNotOk() throws APIException, CadiException {
- Result<List<PermDAO.Data>> pd = Result.create(null, Result.ERR_Backend, "details", "vars");
+ Result<List<PermDAO.Data>> pd = Result.create(null, Result.ERR_Backend, "details", "vars");
- when(question.getPermsByUser(trans, "user", false)).thenReturn(pd);
- when(trans.start("Cached DB Perm lookup", Env.SUB)).thenReturn(tt);
+ when(question.getPermsByUser(trans, "user", false)).thenReturn(pd);
+ when(trans.start("Cached DB Perm lookup", Env.SUB)).thenReturn(tt);
- Set<String> scopes = new HashSet<String>();
- scopes.add(Scope.APPLICATION.toString());
- scopes.add(Scope.HANDLER.toString());
+ Set<String> scopes = new HashSet<String>();
+ scopes.add(Scope.APPLICATION.toString());
+ scopes.add(Scope.HANDLER.toString());
- JSONPermLoader factory = JSONPermLoaderFactory.direct(question);
+ JSONPermLoader factory = JSONPermLoaderFactory.direct(question);
- Result<String> loadJSONPerms = factory.loadJSONPerms(trans, "user", scopes);
+ Result<String> loadJSONPerms = factory.loadJSONPerms(trans, "user", scopes);
- assertEquals(Result.ERR_Backend, loadJSONPerms.status);
+ assertEquals(Result.ERR_Backend, loadJSONPerms.status);
- verify(tt, only()).done();
- }
+ verify(tt, only()).done();
+ }
- @Test
- public void testDirectWhenPdOk() throws APIException, CadiException {
+ @Test
+ public void testDirectWhenPdOk() throws APIException, CadiException {
- when(trans.start("Cached DB Perm lookup", Env.SUB)).thenReturn(tt);
- when(question.deriveNsSplit(trans, "name")).thenReturn(rdns);
- when(rdns.isOKhasData()).thenReturn(false);
+ when(trans.start("Cached DB Perm lookup", Env.SUB)).thenReturn(tt);
+ when(question.deriveNsSplit(trans, "name")).thenReturn(rdns);
+ when(rdns.isOKhasData()).thenReturn(false);
- List<PermDAO.Data> list = new ArrayList<PermDAO.Data>();
- list.add(new PermDAO.Data(nss, "instance", "action"));
- list.add(new PermDAO.Data(nss, "instance", "action"));
+ List<PermDAO.Data> list = new ArrayList<PermDAO.Data>();
+ list.add(new PermDAO.Data(nss, "instance", "action"));
+ list.add(new PermDAO.Data(nss, "instance", "action"));
- Result<List<PermDAO.Data>> pd = Result.create(list, Result.OK, "details", "vars");
+ Result<List<PermDAO.Data>> pd = Result.create(list, Result.OK, "details", "vars");
- when(question.getPermsByUser(trans, "user", false)).thenReturn(pd);
+ when(question.getPermsByUser(trans, "user", false)).thenReturn(pd);
- Set<String> scopes = new HashSet<String>();
- scopes.add(Scope.APPLICATION.toString());
- scopes.add(Scope.HANDLER.toString());
+ Set<String> scopes = new HashSet<String>();
+ scopes.add(Scope.APPLICATION.toString());
+ scopes.add(Scope.HANDLER.toString());
- JSONPermLoader factory = JSONPermLoaderFactory.direct(question);
+ JSONPermLoader factory = JSONPermLoaderFactory.direct(question);
- Result<String> loadJSONPerms = factory.loadJSONPerms(trans, "user", scopes);
+ Result<String> loadJSONPerms = factory.loadJSONPerms(trans, "user", scopes);
- assertEquals(Result.OK, loadJSONPerms.status);
- assertEquals("Success", loadJSONPerms.details);
- assertEquals(
- "{\"perm\":[{\"ns\":\"APPLICATION\",\"type\":\"APPLICATION\",\"instance\":\"instance\",\"action\":\"action\"},{\"ns\":\"APPLICATION\",\"type\":\"APPLICATION\",\"instance\":\"instance\",\"action\":\"action\"}]}",
- loadJSONPerms.value);
+ assertEquals(Result.OK, loadJSONPerms.status);
+ assertEquals("Success", loadJSONPerms.details);
+ assertEquals(
+ "{\"perm\":[{\"ns\":\"APPLICATION\",\"type\":\"APPLICATION\",\"instance\":\"instance\",\"action\":\"action\"},{\"ns\":\"APPLICATION\",\"type\":\"APPLICATION\",\"instance\":\"instance\",\"action\":\"action\"}]}",
+ loadJSONPerms.value);
- verify(tt, only()).done();
- }
+ verify(tt, only()).done();
+ }
}
diff --git a/auth/auth-oauth/src/test/java/org/onap/aaf/auth/oauth/service/JU_OCredsTest.java b/auth/auth-oauth/src/test/java/org/onap/aaf/auth/oauth/service/JU_OCredsTest.java
index 1c16772b..51ea07a3 100644
--- a/auth/auth-oauth/src/test/java/org/onap/aaf/auth/oauth/service/JU_OCredsTest.java
+++ b/auth/auth-oauth/src/test/java/org/onap/aaf/auth/oauth/service/JU_OCredsTest.java
@@ -26,24 +26,24 @@ import org.junit.Test;
public class JU_OCredsTest {
- @Test
- public void test() {
- OCreds cred = new OCreds("client_id", "client_secret", "username", "password");
-
- assertEquals(cred.client_id, "client_id");
- assertEquals(cred.username, "username");
- assertEquals(new String(cred.client_secret), "client_secret");
- assertEquals(new String(cred.password), "password");
- }
-
- @Test
- public void testWithNullValues() {
- OCreds cred = new OCreds("client_id", null, "username", null);
-
- assertEquals(cred.client_id, "client_id");
- assertEquals(cred.username, "username");
- assertEquals(cred.client_secret, null);
- assertEquals(cred.password, null);
- }
+ @Test
+ public void test() {
+ OCreds cred = new OCreds("client_id", "client_secret", "username", "password");
+
+ assertEquals(cred.client_id, "client_id");
+ assertEquals(cred.username, "username");
+ assertEquals(new String(cred.client_secret), "client_secret");
+ assertEquals(new String(cred.password), "password");
+ }
+
+ @Test
+ public void testWithNullValues() {
+ OCreds cred = new OCreds("client_id", null, "username", null);
+
+ assertEquals(cred.client_id, "client_id");
+ assertEquals(cred.username, "username");
+ assertEquals(cred.client_secret, null);
+ assertEquals(cred.password, null);
+ }
}