package at.gv.egovernment.moa.id.auth.modules.ehvd.test.attributes; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNull; import org.apache.commons.lang3.RandomStringUtils; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import at.gv.egiz.eaaf.core.api.idp.IAttributeBuilder; import at.gv.egiz.eaaf.core.exceptions.AttributeBuilderException; import at.gv.egiz.eaaf.core.exceptions.EAAFStorageException; import at.gv.egovernment.moa.id.auth.modules.ehvd.ConfigurationProperties; import at.gv.egovernment.moa.id.auth.modules.ehvd.attributes.EhvdFirstnameAttributeBuilder; import at.gv.egovernment.moa.id.auth.modules.ehvd.attributes.EhvdIdAttributeBuilder; import at.gv.egovernment.moa.id.auth.modules.ehvd.attributes.EhvdSurnameAttributeBuilder; import at.gv.egovernment.moa.id.auth.modules.ehvd.attributes.EhvdTitelAttributeBuilder; import at.gv.egovernment.moa.id.auth.modules.ehvd.client.wsdl.GdaDescriptor; import at.gv.egovernment.moa.id.auth.modules.ehvd.client.wsdl.InstanceIdentifier; @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration({ "/test_ehvd_service_auth.beans.xml" }) public class EhvdIdAttributeBuilderTest extends AbstractEhvdAttributeBuilderTest { @Override protected String expectedAttrName() { return "urn:brzgvat:attributes.ehvd.id"; } @Override protected IAttributeBuilder getAttributeBuilderUnderTest() { return new EhvdIdAttributeBuilder(); } @Test public void checkMissingId() throws EAAFStorageException, AttributeBuilderException { final GdaDescriptor gdaInfo = new GdaDescriptor(); InstanceIdentifier id = new InstanceIdentifier(); gdaInfo.setId(id ); authData.setGenericData(ConfigurationProperties.ATTRIBUTE_URN_EHVD_PREFIX, gdaInfo); assertNull("wrong empty attr.", getAttributeBuilderUnderTest().build(oaParam, authData, g)); } @Test public void checkValid() throws EAAFStorageException, AttributeBuilderException { final GdaDescriptor gdaInfo = new GdaDescriptor(); InstanceIdentifier id = new InstanceIdentifier(); id.setId(RandomStringUtils.randomAlphabetic(5)); gdaInfo.setId(id ); authData.setGenericData(ConfigurationProperties.ATTRIBUTE_URN_EHVD_PREFIX, gdaInfo); assertEquals("wrong empty attr.", id.getId(), getAttributeBuilderUnderTest().build(oaParam, authData, g)); } }