Search in sources :

Example 1 with ResourceSetStoreFactory

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);
}
Also used : CoreWrapper(org.forgerock.openam.core.CoreWrapper) UmaPolicyService(org.forgerock.openam.uma.UmaPolicyService) UmaProviderSettings(org.forgerock.openam.uma.UmaProviderSettings) ResourceSetStore(org.forgerock.oauth2.resources.ResourceSetStore) UmaProviderSettingsFactory(org.forgerock.openam.uma.UmaProviderSettingsFactory) ResourceSetStoreFactory(org.forgerock.openam.oauth2.resources.ResourceSetStoreFactory) BeforeMethod(org.testng.annotations.BeforeMethod)

Example 2 with ResourceSetStoreFactory

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");
}
Also used : UmaSettingsFactory(org.forgerock.openam.uma.UmaSettingsFactory) UmaAuditLogger(org.forgerock.openam.uma.audit.UmaAuditLogger) ResourceSetStoreFactory(org.forgerock.openam.oauth2.resources.ResourceSetStoreFactory) Subject(javax.security.auth.Subject) Debug(com.sun.identity.shared.debug.Debug) ExtensionFilterManager(org.forgerock.openam.oauth2.extensions.ExtensionFilterManager) BeforeMethod(org.testng.annotations.BeforeMethod)

Example 3 with ResourceSetStoreFactory

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);
}
Also used : CoreServicesWrapper(org.forgerock.openam.core.CoreServicesWrapper) ContextHelper(org.forgerock.openam.rest.resource.ContextHelper) UmaSettingsFactory(org.forgerock.openam.uma.UmaSettingsFactory) UmaAuditLogger(org.forgerock.openam.uma.audit.UmaAuditLogger) ResourceDelegationFilter(org.forgerock.openam.uma.extensions.ResourceDelegationFilter) Matchers.anyString(org.mockito.Matchers.anyString) Evaluator(com.sun.identity.entitlement.Evaluator) ResourceSetDescription(org.forgerock.oauth2.resources.ResourceSetDescription) Subject(javax.security.auth.Subject) ResourceSetAcceptAllFilter(org.forgerock.openam.uma.ResourceSetAcceptAllFilter) UmaSettings(org.forgerock.openam.uma.UmaSettings) ResourceSetStore(org.forgerock.oauth2.resources.ResourceSetStore) AMIdentity(com.sun.identity.idm.AMIdentity) ResourceSetStoreFactory(org.forgerock.openam.oauth2.resources.ResourceSetStoreFactory) Debug(com.sun.identity.shared.debug.Debug) ExtensionFilterManager(org.forgerock.openam.oauth2.extensions.ExtensionFilterManager) BeforeMethod(org.testng.annotations.BeforeMethod)

Aggregations

ResourceSetStoreFactory (org.forgerock.openam.oauth2.resources.ResourceSetStoreFactory)3 BeforeMethod (org.testng.annotations.BeforeMethod)3 Debug (com.sun.identity.shared.debug.Debug)2 Subject (javax.security.auth.Subject)2 ResourceSetStore (org.forgerock.oauth2.resources.ResourceSetStore)2 ExtensionFilterManager (org.forgerock.openam.oauth2.extensions.ExtensionFilterManager)2 UmaSettingsFactory (org.forgerock.openam.uma.UmaSettingsFactory)2 UmaAuditLogger (org.forgerock.openam.uma.audit.UmaAuditLogger)2 Evaluator (com.sun.identity.entitlement.Evaluator)1 AMIdentity (com.sun.identity.idm.AMIdentity)1 ResourceSetDescription (org.forgerock.oauth2.resources.ResourceSetDescription)1 CoreServicesWrapper (org.forgerock.openam.core.CoreServicesWrapper)1 CoreWrapper (org.forgerock.openam.core.CoreWrapper)1 ContextHelper (org.forgerock.openam.rest.resource.ContextHelper)1 ResourceSetAcceptAllFilter (org.forgerock.openam.uma.ResourceSetAcceptAllFilter)1 UmaPolicyService (org.forgerock.openam.uma.UmaPolicyService)1 UmaProviderSettings (org.forgerock.openam.uma.UmaProviderSettings)1 UmaProviderSettingsFactory (org.forgerock.openam.uma.UmaProviderSettingsFactory)1 UmaSettings (org.forgerock.openam.uma.UmaSettings)1 ResourceDelegationFilter (org.forgerock.openam.uma.extensions.ResourceDelegationFilter)1