Search in sources :

Example 11 with CredentialsCapabilityType

use of com.evolveum.midpoint.xml.ns._public.resource.capabilities_3.CredentialsCapabilityType in project midpoint by Evolveum.

the class TestSanityLegacy method test004Capabilities.

@Test
public void test004Capabilities() throws ObjectNotFoundException, CommunicationException, SchemaException, FaultMessage {
    TestUtil.displayTestTile("test004Capabilities");
    // GIVEN
    checkRepoOpenDjResource();
    assertNoRepoCache();
    Holder<OperationResultType> resultHolder = new Holder<OperationResultType>();
    Holder<ObjectType> objectHolder = new Holder<ObjectType>();
    SelectorQualifiedGetOptionsType options = new SelectorQualifiedGetOptionsType();
    // WHEN
    modelWeb.getObject(ObjectTypes.RESOURCE.getTypeQName(), RESOURCE_OPENDJ_OID, options, objectHolder, resultHolder);
    ResourceType resource = (ResourceType) objectHolder.value;
    // THEN
    display("Resource", resource);
    assertNoRepoCache();
    CapabilityCollectionType nativeCapabilities = resource.getCapabilities().getNative();
    List<Object> capabilities = nativeCapabilities.getAny();
    assertFalse("Empty capabilities returned", capabilities.isEmpty());
    for (Object capability : nativeCapabilities.getAny()) {
        System.out.println("Native Capability: " + CapabilityUtil.getCapabilityDisplayName(capability) + " : " + capability);
    }
    if (resource.getCapabilities() != null) {
        for (Object capability : resource.getCapabilities().getConfigured().getAny()) {
            System.out.println("Configured Capability: " + CapabilityUtil.getCapabilityDisplayName(capability) + " : " + capability);
        }
    }
    List<Object> effectiveCapabilities = ResourceTypeUtil.getEffectiveCapabilities(resource);
    for (Object capability : effectiveCapabilities) {
        System.out.println("Efective Capability: " + CapabilityUtil.getCapabilityDisplayName(capability) + " : " + capability);
    }
    CredentialsCapabilityType capCred = CapabilityUtil.getCapability(capabilities, CredentialsCapabilityType.class);
    assertNotNull("password capability not present", capCred.getPassword());
    // Connector cannot do activation, this should be null
    ActivationCapabilityType capAct = CapabilityUtil.getCapability(capabilities, ActivationCapabilityType.class);
    assertNull("Found activation capability while not expecting it", capAct);
    capCred = ResourceTypeUtil.getEffectiveCapability(resource, CredentialsCapabilityType.class);
    assertNotNull("password capability not found", capCred.getPassword());
    // Although connector does not support activation, the resource specifies a way how to simulate it.
    // Therefore the following should succeed
    capAct = ResourceTypeUtil.getEffectiveCapability(resource, ActivationCapabilityType.class);
    assertNotNull("activation capability not found", capAct);
}
Also used : ObjectType(com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType) GenericObjectType(com.evolveum.midpoint.xml.ns._public.common.common_3.GenericObjectType) CapabilityCollectionType(com.evolveum.midpoint.xml.ns._public.common.common_3.CapabilityCollectionType) OperationResultType(com.evolveum.midpoint.xml.ns._public.common.common_3.OperationResultType) ActivationCapabilityType(com.evolveum.midpoint.xml.ns._public.resource.capabilities_3.ActivationCapabilityType) Holder(javax.xml.ws.Holder) CredentialsCapabilityType(com.evolveum.midpoint.xml.ns._public.resource.capabilities_3.CredentialsCapabilityType) ResourceType(com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceType) SelectorQualifiedGetOptionsType(com.evolveum.midpoint.xml.ns._public.common.common_3.SelectorQualifiedGetOptionsType) Test(org.testng.annotations.Test) AbstractModelIntegrationTest(com.evolveum.midpoint.model.test.AbstractModelIntegrationTest)

Example 12 with CredentialsCapabilityType

use of com.evolveum.midpoint.xml.ns._public.resource.capabilities_3.CredentialsCapabilityType in project midpoint by Evolveum.

the class TestDBTable method test001Connection.

@Test
public void test001Connection() throws Exception {
    final String TEST_NAME = "test001Connection";
    TestUtil.displayTestTile(TEST_NAME);
    Task task = createTask(TEST_NAME);
    OperationResult result = task.getResult();
    // WHEN
    OperationResult testResult = provisioningService.testResource(RESOURCE_DERBY_OID, task);
    display("Test result", testResult);
    TestUtil.assertSuccess("Test resource failed (result)", testResult);
    ResourceType resource = repositoryService.getObject(ResourceType.class, RESOURCE_DERBY_OID, null, result).asObjectable();
    display("Resource after test", resource);
    display("Resource after test (XML)", PrismTestUtil.serializeObjectToString(resource.asPrismObject(), PrismContext.LANG_XML));
    List<Object> nativeCapabilities = resource.getCapabilities().getNative().getAny();
    CredentialsCapabilityType credentialsCapabilityType = CapabilityUtil.getCapability(nativeCapabilities, CredentialsCapabilityType.class);
    assertNotNull("No credentials capability", credentialsCapabilityType);
    PasswordCapabilityType passwordCapabilityType = credentialsCapabilityType.getPassword();
    assertNotNull("No password in credentials capability", passwordCapabilityType);
    assertEquals("Wrong password capability ReturnedByDefault", Boolean.FALSE, passwordCapabilityType.isReturnedByDefault());
}
Also used : Task(com.evolveum.midpoint.task.api.Task) PasswordCapabilityType(com.evolveum.midpoint.xml.ns._public.resource.capabilities_3.PasswordCapabilityType) CredentialsCapabilityType(com.evolveum.midpoint.xml.ns._public.resource.capabilities_3.CredentialsCapabilityType) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) ResourceType(com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceType) PrismObject(com.evolveum.midpoint.prism.PrismObject) AbstractIntegrationTest(com.evolveum.midpoint.test.AbstractIntegrationTest) Test(org.testng.annotations.Test)

Example 13 with CredentialsCapabilityType

use of com.evolveum.midpoint.xml.ns._public.resource.capabilities_3.CredentialsCapabilityType in project midpoint by Evolveum.

the class AbstractBasicDummyTest method test025CapabilitiesRepo.

/**
	 * Check if the cached native capabilities were properly stored in the repo 
	 */
@Test
public void test025CapabilitiesRepo() throws Exception {
    final String TEST_NAME = "test025CapabilitiesRepo";
    TestUtil.displayTestTile(TEST_NAME);
    // GIVEN
    OperationResult result = new OperationResult(AbstractBasicDummyTest.class.getName() + "." + TEST_NAME);
    // WHEN
    PrismObject<ResourceType> resource = repositoryService.getObject(ResourceType.class, RESOURCE_DUMMY_OID, null, result);
    ;
    // THEN
    result.computeStatus();
    display("getObject result", result);
    TestUtil.assertSuccess(result);
    // Check native capabilities
    ResourceType resourceType = resource.asObjectable();
    CapabilitiesType capabilitiesType = resourceType.getCapabilities();
    assertNotNull("No capabilities in repo, the capabilities were not cached", capabilitiesType);
    CapabilityCollectionType nativeCapabilities = capabilitiesType.getNative();
    System.out.println("Native capabilities: " + PrismTestUtil.serializeAnyDataWrapped(nativeCapabilities));
    System.out.println("resource: " + resourceType.asPrismObject().debugDump());
    List<Object> nativeCapabilitiesList = nativeCapabilities.getAny();
    assertFalse("Empty capabilities returned", nativeCapabilitiesList.isEmpty());
    CredentialsCapabilityType capCred = CapabilityUtil.getCapability(nativeCapabilitiesList, CredentialsCapabilityType.class);
    assertNotNull("password native capability not present", capCred.getPassword());
    ActivationCapabilityType capAct = CapabilityUtil.getCapability(nativeCapabilitiesList, ActivationCapabilityType.class);
    if (supportsActivation()) {
        assertNotNull("native activation capability not present", capAct);
        assertNotNull("native activation status capability not present", capAct.getStatus());
    } else {
        assertNull("native activation capability sneaked in", capAct);
    }
    TestConnectionCapabilityType capTest = CapabilityUtil.getCapability(nativeCapabilitiesList, TestConnectionCapabilityType.class);
    assertNotNull("native test capability not present", capTest);
    ScriptCapabilityType capScript = CapabilityUtil.getCapability(nativeCapabilitiesList, ScriptCapabilityType.class);
    assertNotNull("native script capability not present", capScript);
    assertNotNull("No host in native script capability", capScript.getHost());
    assertFalse("No host in native script capability", capScript.getHost().isEmpty());
    // TODO: better look inside
    CachingMetadataType repoCapabilitiesCachingMetadataType = capabilitiesType.getCachingMetadata();
    assertNotNull("No repo capabilities caching metadata", repoCapabilitiesCachingMetadataType);
    assertNotNull("No repo capabilities caching metadata timestamp", repoCapabilitiesCachingMetadataType.getRetrievalTimestamp());
    assertNotNull("No repo capabilities caching metadata serial number", repoCapabilitiesCachingMetadataType.getSerialNumber());
    assertEquals("Repo capabilities caching metadata timestamp does not match previously returned value", capabilitiesCachingMetadataType.getRetrievalTimestamp(), repoCapabilitiesCachingMetadataType.getRetrievalTimestamp());
    assertEquals("Repo capabilities caching metadata serial does not match previously returned value", capabilitiesCachingMetadataType.getSerialNumber(), repoCapabilitiesCachingMetadataType.getSerialNumber());
    assertSteadyResource();
}
Also used : CapabilityCollectionType(com.evolveum.midpoint.xml.ns._public.common.common_3.CapabilityCollectionType) ActivationCapabilityType(com.evolveum.midpoint.xml.ns._public.resource.capabilities_3.ActivationCapabilityType) TestConnectionCapabilityType(com.evolveum.midpoint.xml.ns._public.resource.capabilities_3.TestConnectionCapabilityType) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) ResourceType(com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceType) ScriptCapabilityType(com.evolveum.midpoint.xml.ns._public.resource.capabilities_3.ScriptCapabilityType) CapabilitiesType(com.evolveum.midpoint.xml.ns._public.common.common_3.CapabilitiesType) CredentialsCapabilityType(com.evolveum.midpoint.xml.ns._public.resource.capabilities_3.CredentialsCapabilityType) PrismObject(com.evolveum.midpoint.prism.PrismObject) CachingMetadataType(com.evolveum.midpoint.xml.ns._public.common.common_3.CachingMetadataType) Test(org.testng.annotations.Test)

Example 14 with CredentialsCapabilityType

use of com.evolveum.midpoint.xml.ns._public.resource.capabilities_3.CredentialsCapabilityType in project midpoint by Evolveum.

the class AbstractBasicDummyTest method assertNativeCredentialsCapability.

protected void assertNativeCredentialsCapability(CredentialsCapabilityType capCred) {
    PasswordCapabilityType passwordCapabilityType = capCred.getPassword();
    assertNotNull("password native capability not present", passwordCapabilityType);
    Boolean readable = passwordCapabilityType.isReadable();
    if (readable != null) {
        assertFalse("Unexpected 'readable' in password capability", readable);
    }
}
Also used : PasswordCapabilityType(com.evolveum.midpoint.xml.ns._public.resource.capabilities_3.PasswordCapabilityType)

Example 15 with CredentialsCapabilityType

use of com.evolveum.midpoint.xml.ns._public.resource.capabilities_3.CredentialsCapabilityType in project midpoint by Evolveum.

the class TestDummyIncomplete method assertNativeCredentialsCapability.

@Override
protected void assertNativeCredentialsCapability(CredentialsCapabilityType capCred) {
    PasswordCapabilityType passwordCapabilityType = capCred.getPassword();
    assertNotNull("password native capability not present", passwordCapabilityType);
    Boolean readable = passwordCapabilityType.isReadable();
    assertNotNull("No 'readable' inducation in password capability", readable);
    assertTrue("Password not 'readable' in password capability", readable);
}
Also used : PasswordCapabilityType(com.evolveum.midpoint.xml.ns._public.resource.capabilities_3.PasswordCapabilityType)

Aggregations

CredentialsCapabilityType (com.evolveum.midpoint.xml.ns._public.resource.capabilities_3.CredentialsCapabilityType)12 ActivationCapabilityType (com.evolveum.midpoint.xml.ns._public.resource.capabilities_3.ActivationCapabilityType)9 ResourceType (com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceType)8 PasswordCapabilityType (com.evolveum.midpoint.xml.ns._public.resource.capabilities_3.PasswordCapabilityType)8 Test (org.testng.annotations.Test)7 PrismObject (com.evolveum.midpoint.prism.PrismObject)6 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)6 CapabilityCollectionType (com.evolveum.midpoint.xml.ns._public.common.common_3.CapabilityCollectionType)6 ScriptCapabilityType (com.evolveum.midpoint.xml.ns._public.resource.capabilities_3.ScriptCapabilityType)4 PagedSearchCapabilityType (com.evolveum.midpoint.xml.ns._public.resource.capabilities_3.PagedSearchCapabilityType)3 TestConnectionCapabilityType (com.evolveum.midpoint.xml.ns._public.resource.capabilities_3.TestConnectionCapabilityType)3 AbstractModelIntegrationTest (com.evolveum.midpoint.model.test.AbstractModelIntegrationTest)2 Task (com.evolveum.midpoint.task.api.Task)2 AbstractIntegrationTest (com.evolveum.midpoint.test.AbstractIntegrationTest)2 GenericObjectType (com.evolveum.midpoint.xml.ns._public.common.common_3.GenericObjectType)2 ObjectType (com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType)2 OperationResultType (com.evolveum.midpoint.xml.ns._public.common.common_3.OperationResultType)2 SelectorQualifiedGetOptionsType (com.evolveum.midpoint.xml.ns._public.common.common_3.SelectorQualifiedGetOptionsType)2 ActivationStatusCapabilityType (com.evolveum.midpoint.xml.ns._public.resource.capabilities_3.ActivationStatusCapabilityType)2 CreateCapabilityType (com.evolveum.midpoint.xml.ns._public.resource.capabilities_3.CreateCapabilityType)2