Ejemplo n.º 1
0
  @Test
  public void testIterationCondition() throws Exception {
    final String TEST_NAME = "testIterationCondition";
    TestUtil.displayTestTile(TEST_NAME);

    // GIVEN
    OperationResult result = new OperationResult(TestExpression.class.getName() + "." + TEST_NAME);

    rememberScriptExecutionCount();

    ExpressionType expressionType =
        PrismTestUtil.parseAtomicValue(
            EXPRESSION_ITERATION_CONDITION_FILE, ExpressionType.COMPLEX_TYPE);

    PrismPropertyDefinition<Boolean> outputDefinition =
        new PrismPropertyDefinitionImpl<Boolean>(
            ExpressionConstants.OUTPUT_ELMENT_NAME, DOMUtil.XSD_BOOLEAN, prismContext);
    Expression<PrismPropertyValue<Boolean>, PrismPropertyDefinition<Boolean>> expression =
        expressionFactory.makeExpression(expressionType, outputDefinition, TEST_NAME, null, result);

    ExpressionVariables variables = new ExpressionVariables();
    PrismObject<UserType> user = PrismTestUtil.parseObject(USER_JACK_FILE);
    variables.addVariableDefinition(ExpressionConstants.VAR_FOCUS, user);
    variables.addVariableDefinition(ExpressionConstants.VAR_USER, user);
    PrismObject<ShadowType> account = PrismTestUtil.parseObject(ACCOUNT_JACK_DUMMYFILE);
    variables.addVariableDefinition(ExpressionConstants.VAR_SHADOW, account);
    variables.addVariableDefinition(ExpressionConstants.VAR_ITERATION, 1);
    variables.addVariableDefinition(ExpressionConstants.VAR_ITERATION_TOKEN, "001");

    ExpressionEvaluationContext expressionContext =
        new ExpressionEvaluationContext(null, variables, TEST_NAME, null, result);

    // WHEN
    PrismValueDeltaSetTriple<PrismPropertyValue<Boolean>> outputTriple =
        expression.evaluate(expressionContext);

    // THEN
    assertNotNull(outputTriple);
    outputTriple.checkConsistence();

    // Make sure that the script is executed only once. There is no delta in the variables, no need
    // to do it twice.
    assertScriptExecutionIncrement(1);
  }
Ejemplo n.º 2
0
  @BeforeMethod
  public void initUcf() throws Exception {
    TestUtil.displayTestTile("initUcf");

    File file = new File(FILENAME_RESOURCE_OPENDJ);
    FileInputStream fis = new FileInputStream(file);

    // Resource
    PrismObject<ResourceType> resource =
        PrismTestUtil.parseObject(new File(FILENAME_RESOURCE_OPENDJ));
    resourceType = resource.asObjectable();

    // Resource: Second copy for negative test cases
    PrismObject<ResourceType> badResource =
        PrismTestUtil.parseObject(new File(FILENAME_RESOURCE_OPENDJ_BAD));
    badResourceType = badResource.asObjectable();

    // Connector
    PrismObject<ConnectorType> connector =
        PrismTestUtil.parseObject(new File(FILENAME_CONNECTOR_LDAP));
    connectorType = connector.asObjectable();

    factory = connectorFactoryIcfImpl;

    cc =
        factory.createConnectorInstance(
            connectorType, ResourceTypeUtil.getResourceNamespace(resourceType), "test connector");
    AssertJUnit.assertNotNull("Cannot create connector instance", cc);

    connectorSchema = cc.generateConnectorSchema();
    AssertJUnit.assertNotNull("Cannot generate connector schema", cc);
    display("Connector schema", connectorSchema);

    OperationResult result = new OperationResult("initUcf");
    cc.configure(resourceType.getConnectorConfiguration().asPrismContainerValue(), result);
    cc.initialize(null, null, false, result);
    // TODO: assert something

    resourceSchema = cc.fetchResourceSchema(null, result);
    display("Resource schema", resourceSchema);

    AssertJUnit.assertNotNull(resourceSchema);
  }
Ejemplo n.º 3
0
  @Test(enabled = true)
  public void test010FormatUser() throws Exception {

    // GIVEN

    PrismObject<UserType> jack = PrismTestUtil.parseObject(new File(USER_JACK_FILE));
    System.out.println(jack.debugDump());
    // WHEN

    String jackFormattedHideNone = textFormatter.formatObject(jack, null, true);
    System.out.println("no hidden paths + show operational attributes: " + jackFormattedHideNone);

    String jackFormattedHideOper = textFormatter.formatObject(jack, null, false);
    System.out.println("no hidden paths + hide operational attributes: " + jackFormattedHideOper);

    String jackFormattedHideAux = textFormatter.formatObject(jack, auxiliaryPaths, true);
    System.out.println(
        "hide auxiliary paths + show operational attributes: " + jackFormattedHideAux);

    String jackFormattedHideAuxAndOper = textFormatter.formatObject(jack, auxiliaryPaths, false);
    System.out.println(
        "hide auxiliary paths + hide operational attributes: " + jackFormattedHideAuxAndOper);

    // THEN

    assertTrue(
        "hidden operational attribute when it should be shown ('hide none')",
        jackFormattedHideNone.contains("createTimestamp:"));
    assertTrue(
        "hidden auxiliary attribute (effective status) when it should be shown ('hide none')",
        jackFormattedHideNone.contains("Effective Status: ENABLED"));
    assertTrue(
        "hidden auxiliary attribute (family name) when it should be shown ('hide none')",
        jackFormattedHideNone.contains("Family Name: Sparrow"));
    assertTrue(
        "hidden standard attribute when it should be shown ('hide none')",
        jackFormattedHideNone.contains("ship: Black Pearl"));

    assertTrue(
        "shown operational attribute when it should be hidden ('hide oper')",
        !jackFormattedHideOper.contains("createTimestamp:"));
    assertTrue(
        "hidden auxiliary attribute when it should be shown ('hide oper')",
        jackFormattedHideOper.contains("Effective Status: ENABLED"));
    assertTrue(
        "hidden auxiliary attribute (family name) when it should be shown ('hide oper')",
        jackFormattedHideOper.contains("Family Name: Sparrow"));
    assertTrue(
        "hidden standard attribute when it should be shown ('hide oper')",
        jackFormattedHideOper.contains("ship: Black Pearl"));

    assertTrue(
        "shown auxiliary attribute (metadata) when it should be hidden ('hide aux')",
        !jackFormattedHideAux.contains("createTimestamp:"));
    assertTrue(
        "shown auxiliary attribute (family name) when it should be hidden ('hide aux')",
        !jackFormattedHideAux.contains("Family Name: Sparrow"));
    assertTrue(
        "shown auxiliary attribute (effective status) when it should be hidden ('hide aux')",
        !jackFormattedHideAux.contains("Effective Status: ENABLED"));
    assertTrue(
        "hidden standard attribute when it should be shown ('hide aux')",
        jackFormattedHideAux.contains("ship: Black Pearl"));

    assertTrue(
        "shown operational attribute when it should be hidden ('hide aux and oper')",
        !jackFormattedHideAuxAndOper.contains("createTimestamp:"));
    assertTrue(
        "shown auxiliary attribute (effective status) when it should be hidden ('hide aux and oper')",
        !jackFormattedHideAuxAndOper.contains("Effective Status: ENABLED"));
    assertTrue(
        "shown auxiliary attribute (family name) when it should be hidden ('hide aux and oper')",
        !jackFormattedHideAuxAndOper.contains("Family Name: Sparrow"));
    assertTrue(
        "hidden standard attribute when it should be shown ('hide aux and oper')",
        jackFormattedHideAuxAndOper.contains("ship: Black Pearl"));
  }
Ejemplo n.º 4
0
  @Test(enabled = true)
  public void test030FormatAccount() throws Exception {

    // GIVEN

    PrismObject<ShadowType> jack = PrismTestUtil.parseObject(new File(ACCOUNT_JACK_FILE));
    System.out.println(jack.debugDump());
    // WHEN

    String jackFormattedHideNone =
        textFormatter.formatAccountAttributes(jack.asObjectable(), null, true);
    System.out.println("no hidden paths + show operational attributes: " + jackFormattedHideNone);

    String jackFormattedHideAux =
        textFormatter.formatAccountAttributes(jack.asObjectable(), auxiliaryPaths, true);
    System.out.println(
        "hide auxiliary paths + show operational attributes: " + jackFormattedHideAux);

    // THEN

    assertTrue("account name is not shown", jackFormattedHideNone.contains("Name: jack"));
    assertTrue(
        "account password is not shown", jackFormattedHideNone.contains("(protected string)"));
    assertTrue(
        "administrative status is not shown",
        jackFormattedHideNone.contains("Administrative Status: ENABLED"));
    assertTrue(
        "effective status is not shown",
        jackFormattedHideNone.contains("Effective Status: ENABLED"));

    assertTrue("account name is not shown", jackFormattedHideAux.contains("Name: jack"));
    assertTrue(
        "account password is not shown", jackFormattedHideAux.contains("(protected string)"));
    assertTrue(
        "administrative status is not shown",
        jackFormattedHideAux.contains("Administrative Status: ENABLED"));
    assertTrue(
        "effective status is shown although it should be hidden",
        !jackFormattedHideAux.contains("Effective Status: ENABLED"));

    //        AssertJUnit.assertTrue("hidden operational attribute when it should be shown ('hide
    // none')", jackFormattedHideNone.contains("createTimestamp:"));
    //        AssertJUnit.assertTrue("hidden auxiliary attribute (effective status) when it should
    // be shown ('hide none')", jackFormattedHideNone.contains("Effective Status: ENABLED"));
    //        AssertJUnit.assertTrue("hidden auxiliary attribute (family name) when it should be
    // shown ('hide none')", jackFormattedHideNone.contains("Family Name: Sparrow"));
    //        AssertJUnit.assertTrue("hidden standard attribute when it should be shown ('hide
    // none')", jackFormattedHideNone.contains("ship: Black Pearl"));
    //
    //        AssertJUnit.assertTrue("shown operational attribute when it should be hidden ('hide
    // oper')", !jackFormattedHideOper.contains("createTimestamp:"));
    //        AssertJUnit.assertTrue("hidden auxiliary attribute when it should be shown ('hide
    // oper')", jackFormattedHideOper.contains("Effective Status: ENABLED"));
    //        AssertJUnit.assertTrue("hidden auxiliary attribute (family name) when it should be
    // shown ('hide oper')", jackFormattedHideOper.contains("Family Name: Sparrow"));
    //        AssertJUnit.assertTrue("hidden standard attribute when it should be shown ('hide
    // oper')", jackFormattedHideOper.contains("ship: Black Pearl"));
    //
    //        AssertJUnit.assertTrue("shown auxiliary attribute (metadata) when it should be hidden
    // ('hide aux')", !jackFormattedHideAux.contains("createTimestamp:"));
    //        AssertJUnit.assertTrue("shown auxiliary attribute (family name) when it should be
    // hidden ('hide aux')", !jackFormattedHideAux.contains("Family Name: Sparrow"));
    //        AssertJUnit.assertTrue("shown auxiliary attribute (effective status) when it should be
    // hidden ('hide aux')", !jackFormattedHideAux.contains("Effective Status: ENABLED"));
    //        AssertJUnit.assertTrue("hidden standard attribute when it should be shown ('hide
    // aux')", jackFormattedHideAux.contains("ship: Black Pearl"));
    //
    //        AssertJUnit.assertTrue("shown operational attribute when it should be hidden ('hide
    // aux and oper')", !jackFormattedHideAuxAndOper.contains("createTimestamp:"));
    //        AssertJUnit.assertTrue("shown auxiliary attribute (effective status) when it should be
    // hidden ('hide aux and oper')", !jackFormattedHideAuxAndOper.contains("Effective Status:
    // ENABLED"));
    //        AssertJUnit.assertTrue("shown auxiliary attribute (family name) when it should be
    // hidden ('hide aux and oper')", !jackFormattedHideAuxAndOper.contains("Family Name:
    // Sparrow"));
    //        AssertJUnit.assertTrue("hidden standard attribute when it should be shown ('hide aux
    // and oper')", jackFormattedHideAuxAndOper.contains("ship: Black Pearl"));

  }
Ejemplo n.º 5
0
  @Test(enabled = true)
  public void test020FormatUserModification() throws Exception {

    // GIVEN

    ObjectDelta<UserType> delta = parseDelta(USER_JACK_MODIFICATION_FILE);
    PrismObject<UserType> jack = PrismTestUtil.parseObject(new File(USER_JACK_FILE));

    System.out.println(delta.debugDump());
    // WHEN

    String deltaFormattedHideNone =
        textFormatter.formatObjectModificationDelta(delta, null, true, jack, null);
    System.out.println("no hidden paths + show operational attributes: " + deltaFormattedHideNone);

    String deltaFormattedHideOper =
        textFormatter.formatObjectModificationDelta(delta, null, false, jack, null);
    System.out.println("no hidden paths + hide operational attributes: " + deltaFormattedHideOper);

    String deltaFormattedHideAux =
        textFormatter.formatObjectModificationDelta(delta, auxiliaryPaths, true, jack, null);
    System.out.println(
        "hide auxiliary paths + show operational attributes: " + deltaFormattedHideAux);

    String deltaFormattedHideAuxAndOper =
        textFormatter.formatObjectModificationDelta(delta, auxiliaryPaths, false, jack, null);
    System.out.println(
        "hide auxiliary paths + hide operational attributes: " + deltaFormattedHideAuxAndOper);

    // THEN

    checkNotes(deltaFormattedHideAux);
    checkNotes(deltaFormattedHideAuxAndOper);
    checkNotes(deltaFormattedHideNone);
    checkNotes(deltaFormattedHideOper);

    assertTrue(
        "hidden operational attribute when it should be shown ('hide none')",
        deltaFormattedHideNone.contains("createTimestamp:"));
    assertTrue(
        "hidden auxiliary attribute (family name) when it should be shown ('hide none')",
        deltaFormattedHideNone.contains("SPARROW"));
    assertTrue(
        "hidden password change when it should be shown ('hide none')",
        deltaFormattedHideNone.contains("(protected string)"));
    assertTrue(
        "hidden standard attribute when it should be shown ('hide none')",
        deltaFormattedHideNone.contains("BLACK PEARL"));

    assertTrue(
        "shown operational attribute when it should be hidden ('hide oper')",
        !deltaFormattedHideOper.contains("createTimestamp:"));
    assertTrue(
        "hidden auxiliary attribute (family name) when it should be shown ('hide oper')",
        deltaFormattedHideOper.contains("SPARROW"));
    assertTrue(
        "hidden password change when it should be shown ('hide oper')",
        deltaFormattedHideOper.contains("(protected string)"));
    assertTrue(
        "hidden standard attribute when it should be shown ('hide oper')",
        deltaFormattedHideOper.contains("BLACK PEARL"));

    assertTrue(
        "shown auxiliary attribute (metadata) when it should be hidden ('hide aux')",
        !deltaFormattedHideAux.contains("createTimestamp:"));
    assertTrue(
        "shown auxiliary attribute (family name) when it should be hidden ('hide aux')",
        !deltaFormattedHideAux.contains("SPARROW"));
    assertTrue(
        "hidden standard attribute when it should be shown ('hide aux')",
        deltaFormattedHideAux.contains("BLACK PEARL"));

    assertTrue(
        "shown operational attribute when it should be hidden ('hide aux and oper')",
        !deltaFormattedHideAuxAndOper.contains("createTimestamp:"));
    assertTrue(
        "shown auxiliary attribute (family name) when it should be hidden ('hide aux and oper')",
        !deltaFormattedHideAuxAndOper.contains("SPARROW"));
    assertTrue(
        "hidden standard attribute when it should be shown ('hide aux and oper')",
        deltaFormattedHideAuxAndOper.contains("BLACK PEARL"));
  }