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);
}
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());
}
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();
}
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);
}
}
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);
}
Aggregations