@Test public void testReadAlterAttributes() { final OracleAttributesReader reader = new OracleAttributesReader(TestHelpers.createDummyMessages()); OracleUserAttributes.Builder caAttributes = new OracleUserAttributes.Builder(); caAttributes.setUserName("testUser"); Set<Attribute> attributes = new HashSet<Attribute>(); attributes.add( AttributeBuilder.build( OracleConstants.ORACLE_AUTHENTICATION_ATTR_NAME, OracleConstants.ORACLE_AUTH_LOCAL)); attributes.add(AttributeBuilder.buildPassword("myPassword".toCharArray())); reader.readAlterAttributes(AttributeUtil.toMap(attributes), caAttributes); Assert.assertEquals(OracleAuthentication.LOCAL, caAttributes.getAuth()); Assert.assertNotNull("Password must not be null", caAttributes.getPassword()); // verify that password is not set for alter when not set caAttributes = new OracleUserAttributes.Builder(); caAttributes.setUserName("testUser"); attributes.clear(); attributes.add(AttributeBuilder.buildPasswordExpired(true)); reader.readAlterAttributes(AttributeUtil.toMap(attributes), caAttributes); Assert.assertNull("Password must be null", caAttributes.getPassword()); // try to update authentication to null attributes = new HashSet<Attribute>(); attributes.add(AttributeBuilder.build(OracleConstants.ORACLE_AUTHENTICATION_ATTR_NAME)); attributes.add(AttributeBuilder.buildPassword("myPassword".toCharArray())); try { reader.readAlterAttributes(AttributeUtil.toMap(attributes), caAttributes); fail("Create attributes must fail for null authentication"); } catch (IllegalArgumentException e) { } }
private void generateUsers() { for (int i = 0; i < getCreateUsersNumber(); i++) { Set<Attribute> attrs = new HashSet<Attribute>(); attrs.add(AttributeBuilder.build(Name.NAME, formatName(i))); attrs.add(AttributeBuilder.buildPassword(SAMPLE_PASSWD.toCharArray())); facade.create(ObjectClass.ACCOUNT, attrs, null); } }
/** * Test method for {@link * org.identityconnectors.oracle.OracleAttributesReader#readAuthAttributes(java.util.Set, * org.identityconnectors.oracle.OracleUserAttributes)}. */ @Test public final void testReadCreateAuthAttributes() { final OracleAttributesReader reader = new OracleAttributesReader(TestHelpers.createDummyMessages()); OracleUserAttributes.Builder caAttributes = new OracleUserAttributes.Builder(); caAttributes.setUserName("testUser"); Set<Attribute> attributes = new HashSet<Attribute>(); attributes.add( AttributeBuilder.build( OracleConstants.ORACLE_AUTHENTICATION_ATTR_NAME, OracleConstants.ORACLE_AUTH_LOCAL)); attributes.add(AttributeBuilder.buildPassword("myPassword".toCharArray())); reader.readCreateAttributes(AttributeUtil.toMap(attributes), caAttributes); Assert.assertEquals(OracleAuthentication.LOCAL, caAttributes.getAuth()); Assert.assertNotNull("Password must not be null", caAttributes.getPassword()); attributes.clear(); caAttributes = new OracleUserAttributes.Builder(); caAttributes.setUserName("testUser"); reader.readCreateAttributes(AttributeUtil.toMap(attributes), caAttributes); Assert.assertNull("Should not set authentication to any default value", caAttributes.getAuth()); Assert.assertNull("Password must be null", caAttributes.getPassword()); // Test for failures attributes.clear(); reader.readCreateAttributes(AttributeUtil.toMap(attributes), caAttributes); attributes.add( AttributeBuilder.build( OracleConstants.ORACLE_AUTHENTICATION_ATTR_NAME, "invalid authentication")); try { reader.readCreateAttributes(AttributeUtil.toMap(attributes), caAttributes); fail("Must fail for invalid authentication"); } catch (RuntimeException e) { } attributes.clear(); attributes.add( AttributeBuilder.build( OracleConstants.ORACLE_AUTHENTICATION_ATTR_NAME, OracleConstants.ORACLE_AUTH_GLOBAL)); try { reader.readCreateAttributes(AttributeUtil.toMap(attributes), caAttributes); fail("Must fail for missing global name"); } catch (RuntimeException e) { } attributes.clear(); attributes.add( AttributeBuilder.build( OracleConstants.ORACLE_AUTHENTICATION_ATTR_NAME, OracleConstants.ORACLE_AUTH_GLOBAL)); attributes.add(AttributeBuilder.build(OracleConstants.ORACLE_GLOBAL_ATTR_NAME, "")); try { reader.readCreateAttributes(AttributeUtil.toMap(attributes), caAttributes); fail("Must fail for empty global name"); } catch (RuntimeException e) { } }