use of org.forgerock.openam.oauth2.resources.ResourceSetStoreFactory in project OpenAM by OpenRock.
the class ResourceSetServiceTest method setup.
@BeforeMethod
public void setup() throws Exception {
ResourceSetStoreFactory resourceSetStoreFactory = mock(ResourceSetStoreFactory.class);
resourceSetStore = mock(ResourceSetStore.class);
policyService = mock(UmaPolicyService.class);
coreWrapper = mock(CoreWrapper.class);
UmaProviderSettingsFactory umaProviderSettingsFactory = mock(UmaProviderSettingsFactory.class);
umaProviderSettings = mock(UmaProviderSettings.class);
service = new ResourceSetService(resourceSetStoreFactory, policyService, coreWrapper, umaProviderSettingsFactory);
given(resourceSetStoreFactory.create("REALM")).willReturn(resourceSetStore);
given(umaProviderSettingsFactory.get("REALM")).willReturn(umaProviderSettings);
}
use of org.forgerock.openam.oauth2.resources.ResourceSetStoreFactory in project OpenAM by OpenRock.
the class UmaPolicyServiceImplDelegationTest method setup.
@SuppressWarnings("unchecked")
@BeforeMethod
public void setup() throws Exception {
MockitoAnnotations.initMocks(this);
//Stub getting ResourceSetStore
ResourceSetStoreFactory resourceSetStoreFactory = mock(ResourceSetStoreFactory.class);
given(resourceSetStoreFactory.create(anyString())).willReturn(resourceSetStore);
//Stub getting UmaAuditLogger
Config<UmaAuditLogger> lazyAuditLogger = mock(Config.class);
given(lazyAuditLogger.get()).willReturn(auditLogger);
//Stub getting Evaluator
UmaPolicyEvaluatorFactory policyEvaluatorFactory = mock(UmaPolicyEvaluatorFactory.class);
given(policyEvaluatorFactory.getEvaluator(any(Subject.class), anyString())).willReturn(policyEvaluator);
Debug debug = mock(Debug.class);
UmaSettingsFactory umaSettingsFactory = mock(UmaSettingsFactory.class);
given(umaSettingsFactory.create(anyString())).willReturn(umaSettings);
ExtensionFilterManager extensionFilterManager = mock(ExtensionFilterManager.class);
policyService = new UmaPolicyServiceImpl(policyResourceDelegate, resourceSetStoreFactory, lazyAuditLogger, contextHelper, policyEvaluatorFactory, coreServicesWrapper, debug, umaSettingsFactory, extensionFilterManager);
given(contextHelper.getRealm(Matchers.<Context>anyObject())).willReturn("REALM");
}
use of org.forgerock.openam.oauth2.resources.ResourceSetStoreFactory in project OpenAM by OpenRock.
the class UmaPolicyServiceImplTest method setup.
@BeforeMethod
public void setup() throws Exception {
policyResourceDelegate = mock(PolicyResourceDelegate.class);
final ResourceSetStoreFactory resourceSetStoreFactory = mock(ResourceSetStoreFactory.class);
Config<UmaAuditLogger> lazyAuditLogger = mock(Config.class);
auditLogger = mock(UmaAuditLogger.class);
contextHelper = mock(ContextHelper.class);
UmaPolicyEvaluatorFactory policyEvaluatorFactory = mock(UmaPolicyEvaluatorFactory.class);
policyEvaluator = mock(Evaluator.class);
given(policyEvaluatorFactory.getEvaluator(any(Subject.class), anyString())).willReturn(policyEvaluator);
coreServicesWrapper = mock(CoreServicesWrapper.class);
Debug debug = mock(Debug.class);
UmaSettingsFactory umaSettingsFactory = mock(UmaSettingsFactory.class);
UmaSettings umaSettings = mock(UmaSettings.class);
given(umaSettingsFactory.create(anyString())).willReturn(umaSettings);
ExtensionFilterManager extensionFilterManager = mock(ExtensionFilterManager.class);
resourceDelegationFilter = mock(ResourceDelegationFilter.class);
given(extensionFilterManager.getFilters(ResourceDelegationFilter.class)).willReturn(Collections.singleton(resourceDelegationFilter));
policyService = new UmaPolicyServiceImpl(policyResourceDelegate, resourceSetStoreFactory, lazyAuditLogger, contextHelper, policyEvaluatorFactory, coreServicesWrapper, debug, umaSettingsFactory, extensionFilterManager);
given(contextHelper.getRealm(Matchers.<Context>anyObject())).willReturn("REALM");
given(contextHelper.getUserId(Matchers.<Context>anyObject())).willReturn(RESOURCE_OWNER_ID);
given(contextHelper.getUserUid(Matchers.<Context>anyObject())).willReturn("RESOURCE_OWNER_UID");
resourceSetStore = mock(ResourceSetStore.class);
resourceSet = new ResourceSetDescription("RESOURCE_SET_ID", "CLIENT_ID", RESOURCE_OWNER_ID, Collections.<String, Object>emptyMap());
resourceSet.setDescription(json(object(field("name", "NAME"), field("scopes", array("SCOPE_A", "SCOPE_B", "SCOPE_C")))));
given(resourceSetStoreFactory.create(anyString())).willReturn(resourceSetStore);
given(resourceSetStore.read("RESOURCE_SET_ID", RESOURCE_OWNER_ID)).willReturn(resourceSet);
given(resourceSetStore.read(eq("RESOURCE_SET_ID"), any(ResourceSetAcceptAllFilter.class))).willReturn(resourceSet);
given(resourceSetStore.query(QueryFilter.and(QueryFilter.equalTo(ResourceSetTokenField.RESOURCE_SET_ID, "RESOURCE_SET_ID")))).willReturn(Collections.singleton(resourceSet));
doThrow(org.forgerock.oauth2.core.exceptions.NotFoundException.class).when(resourceSetStore).read("OTHER_ID", RESOURCE_OWNER_ID);
doThrow(org.forgerock.oauth2.core.exceptions.ServerException.class).when(resourceSetStore).read("FAILING_ID", RESOURCE_OWNER_ID);
doThrow(org.forgerock.oauth2.core.exceptions.ServerException.class).when(resourceSetStore).query(QueryFilter.and(QueryFilter.equalTo(ResourceSetTokenField.RESOURCE_SET_ID, "FAILING_ID")));
given(lazyAuditLogger.get()).willReturn(auditLogger);
AMIdentity identity = mock(AMIdentity.class);
given(identity.getUniversalId()).willReturn("uid=RESOURCE_OWNER_ID,ou=REALM,dc=forgerock,dc=org");
given(coreServicesWrapper.getIdentity(RESOURCE_OWNER_ID, "REALM")).willReturn(identity);
}
Aggregations