Skip to content

Commit

Permalink
Fixing <const>
Browse files Browse the repository at this point in the history
  • Loading branch information
semancik committed Sep 13, 2017
1 parent a8fe7d4 commit e7a3345
Show file tree
Hide file tree
Showing 12 changed files with 45 additions and 466 deletions.
Expand Up @@ -1218,6 +1218,10 @@ private <T> T unmarshalEnumFromPrimitive(PrimitiveXNode prim, Class<T> beanClass
private ProtectedStringType unmarshalProtectedString(MapXNode map, Class beanClass, ParsingContext pc) throws SchemaException {
ProtectedStringType protectedType = new ProtectedStringType();
XNodeProcessorUtil.parseProtectedType(protectedType, map, prismContext, pc);
if (protectedType.isEmpty()) {
// E.g. in case when the xmap is empty or if there are is just an expression
return null;
}
return protectedType;
}

Expand Down
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2010-2013 Evolveum
* Copyright (c) 2010-2017 Evolveum
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down
Expand Up @@ -276,6 +276,12 @@ private void assertResourceExpression(PrismObject<ResourceType> resource, PrismC
baseContextsProp.applyDefinition(new PrismPropertyDefinitionImpl<>(new QName("whatever","baseContexts"), DOMUtil.XSD_STRING, prismContext));
assertNotRaw(baseContextsProp);
assertExpression(baseContextsProp, "script");

PrismProperty<ProtectedStringType> credentialsProp = findProp(ldapConfigPropItems, "credentials");
assertRaw(credentialsProp);
credentialsProp.applyDefinition(new PrismPropertyDefinitionImpl<>(new QName("whatever","credentials"), ProtectedStringType.COMPLEX_TYPE, prismContext));
assertNotRaw(credentialsProp);
assertExpression(credentialsProp, "const");
}

PrismContainer<Containerable> schemaContainer = resource.findContainer(ResourceType.F_SCHEMA);
Expand Down Expand Up @@ -370,28 +376,28 @@ private void doTestParseResourceExpressionRoundtrip(String serializeInto) throws

}

private void assertRaw(PrismProperty<String> prop) {
private <T> void assertRaw(PrismProperty<T> prop) {
assertTrue("Prop "+prop+" no raw", prop.isRaw());
}

private void assertNotRaw(PrismProperty<String> prop) {
private <T> void assertNotRaw(PrismProperty<T> prop) {
assertFalse("Prop "+prop+" raw (unexpected)", prop.isRaw());
}

private PrismProperty<String> findProp(List<Item<?, ?>> items, String local) {
private <T> PrismProperty<T> findProp(List<Item<?, ?>> items, String local) {
for (Item<?, ?> item: items) {
if (local.equals(item.getElementName().getLocalPart())) {
return (PrismProperty<String>) item;
return (PrismProperty<T>) item;
}
}
fail("No item "+local);
return null; // not reached
}

private void assertExpression(PrismProperty<String> prop, String evaluatorName) {
private <T> void assertExpression(PrismProperty<T> prop, String evaluatorName) {
System.out.println("Prop:");
System.out.println(prop.debugDump(1));
PrismPropertyValue<String> pval = prop.getValue();
PrismPropertyValue<T> pval = prop.getValue();
ExpressionWrapper expressionWrapper = pval.getExpression();
assertNotNull("No expression wrapper in "+prop, expressionWrapper);
Object expressionObj = expressionWrapper.getExpression();
Expand Down
Expand Up @@ -49,7 +49,9 @@
</baseContexts>
<principal>cn=directory manager</principal>
<credentials>
<clearValue>secret</clearValue>
<expression>
<const>password</const>
</expression>
</credentials>
<vlvSortAttribute>uid</vlvSortAttribute>
<accountOperationalAttributes>ds-pwp-account-disabled</accountOperationalAttributes>
Expand Down
Expand Up @@ -68,7 +68,9 @@
</icfcldap:baseContexts>
<icfcldap:principal>cn=directory manager</icfcldap:principal>
<icfcldap:credentials>
<t:clearValue>secret</t:clearValue>
<expression>
<const>password</const>
</expression>
</icfcldap:credentials>
<icfcldap:vlvSortAttribute>uid</icfcldap:vlvSortAttribute>
<icfcldap:accountOperationalAttributes>ds-pwp-account-disabled</icfcldap:accountOperationalAttributes>
Expand Down
Expand Up @@ -352,9 +352,6 @@ public class AbstractConfiguredModelIntegrationTest extends AbstractModelIntegra
public static final String ACCOUNT_HERMAN_DUMMY_OID = "22220000-2200-0000-0000-444400004444";
public static final String ACCOUNT_HERMAN_DUMMY_USERNAME = "ht";

public static final String ACCOUNT_HERMAN_OPENDJ_FILENAME = COMMON_DIR + "/account-herman-opendj.xml";
public static final String ACCOUNT_HERMAN_OPENDJ_OID = "22220000-2200-0000-0000-333300003333";

public static final File ACCOUNT_SHADOW_GUYBRUSH_DUMMY_FILE = new File(COMMON_DIR, "account-shadow-guybrush-dummy.xml");
public static final String ACCOUNT_SHADOW_GUYBRUSH_OID = "22226666-2200-6666-6666-444400004444";
public static final String ACCOUNT_GUYBRUSH_DUMMY_USERNAME = "guybrush";
Expand Down

This file was deleted.

0 comments on commit e7a3345

Please sign in to comment.