mockDataManager.setApi(api);
// no auth found
assertNull(dataAccess.checkAllowed(api, "authKey").getAuthIdentity());
assertNull(dataAccess.checkAllowed(api, "username", "password").getAuthIdentity());
assertNull(dataAccess.checkAllowed(api, new CanonicalizedIpAddress("127.0.0.1")).getAuthIdentity());
Auth auth = new Auth();
auth.setStatus(StatusType.ACTIVE);
mockDataManager.setAuth(auth);
// No policy found
assertNull(dataAccess.checkAllowed(api, "authKey").getAuthIdentity());
assertNull(dataAccess.checkAllowed(api, "username", "password").getAuthIdentity());
assertNull(dataAccess.checkAllowed(api, new CanonicalizedIpAddress("127.0.0.1")).getAuthIdentity());
Policy policy = new Policy();
mockDataManager.getCallDescriptors().add(new CallDescriptor(policy, 1, 2));
AuthIdentity authIdentity = dataAccess.checkAllowed(api, "authKey").getAuthIdentity();
assertNotNull(authIdentity);
assertNotNull(authIdentity.getApi() == api); // compare memory reference
assertNotNull(authIdentity.getAuth() == auth); // compare memory reference
assertNotNull(authIdentity.getCallDescriptors().get(0).getPolicy() == policy); // compare memory reference
authIdentity = dataAccess.checkAllowed(api, "username", "password").getAuthIdentity();
assertNotNull(authIdentity);
assertNotNull(authIdentity.getApi() == api); // compare memory reference
assertNotNull(authIdentity.getAuth() == auth); // compare memory reference
assertNotNull(authIdentity.getCallDescriptors().get(0).getPolicy() == policy); // compare memory reference
authIdentity = dataAccess.checkAllowed(api, new CanonicalizedIpAddress("127.0.0.1")).getAuthIdentity();
assertNotNull(authIdentity);
assertNotNull(authIdentity.getApi() == api); // compare memory reference
assertNotNull(authIdentity.getAuth() == auth); // compare memory reference
assertNotNull(authIdentity.getCallDescriptors().get(0).getPolicy() == policy); // compare memory reference