summaryrefslogtreecommitdiff
path: root/eaaf_core/src/test
diff options
context:
space:
mode:
authorThomas Lenz <thomas.lenz@egiz.gv.at>2020-11-09 15:14:09 +0100
committerThomas Lenz <thomas.lenz@egiz.gv.at>2020-11-09 15:14:09 +0100
commit107683317c874b0349e48f9658bb712f47e40f36 (patch)
tree26375f5c392cddf521ca90f38e96449dd4488429 /eaaf_core/src/test
parenta1eb59634b452231036cf5888d8deeda7764f823 (diff)
downloadEAAF-Components-107683317c874b0349e48f9658bb712f47e40f36.tar.gz
EAAF-Components-107683317c874b0349e48f9658bb712f47e40f36.tar.bz2
EAAF-Components-107683317c874b0349e48f9658bb712f47e40f36.zip
add attribute-builder for unique transactionId
Diffstat (limited to 'eaaf_core/src/test')
-rw-r--r--eaaf_core/src/test/java/at/gv/egiz/eaaf/core/impl/idp/auth/attributes/TransactionIdAttributeBuilderTest.java60
1 files changed, 60 insertions, 0 deletions
diff --git a/eaaf_core/src/test/java/at/gv/egiz/eaaf/core/impl/idp/auth/attributes/TransactionIdAttributeBuilderTest.java b/eaaf_core/src/test/java/at/gv/egiz/eaaf/core/impl/idp/auth/attributes/TransactionIdAttributeBuilderTest.java
new file mode 100644
index 00000000..d82bdf5c
--- /dev/null
+++ b/eaaf_core/src/test/java/at/gv/egiz/eaaf/core/impl/idp/auth/attributes/TransactionIdAttributeBuilderTest.java
@@ -0,0 +1,60 @@
+package at.gv.egiz.eaaf.core.impl.idp.auth.attributes;
+
+import org.junit.Assert;
+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.impl.idp.builder.attributes.TransactionIdAttributeBuilder;
+import at.gv.egiz.eaaf.core.impl.utils.TransactionIdUtils;
+
+/**
+ * Attribute builder to generate an attribute that holds the unique TransactionId for this process.
+ * <br>
+ * The attribute-value is read from {@link TransactionIdUtils} with method <code>getTransactionId()</code>
+ *
+ * @author tlenz
+ *
+ */
+@RunWith(SpringJUnit4ClassRunner.class)
+@ContextConfiguration("/SpringTest-context_eaaf_core.xml")
+public class TransactionIdAttributeBuilderTest extends AbstractAttributeBuilderTest {
+
+ private final IAttributeBuilder attrBuilder = new TransactionIdAttributeBuilder();
+
+ @Test
+ public void attributeName() {
+ Assert.assertEquals("Wrong attribute name",
+ "urn:eidgvat:attributes.transactionId", attrBuilder.getName());
+
+ }
+
+ @Test
+ public void checkEmptyAttribute() {
+ String value = attrBuilder.buildEmpty(gen);
+ Assert.assertNull("Attr. not null", value);
+
+ }
+
+ @Test
+ public void noTransactionId() throws AttributeBuilderException, Exception {
+ String value = attrBuilder.build(spConfig, buildAuthData(), gen);
+ Assert.assertNull("Attr. not null", value);
+
+ }
+
+ @Test
+ public void withTransactionId() throws AttributeBuilderException, Exception {
+ TransactionIdUtils.setTransactionId();
+ String transId = TransactionIdUtils.getTransactionId();
+ Assert.assertNull("Inputdata is null", transId);
+
+ String value = attrBuilder.build(spConfig, buildAuthData(), gen);
+ Assert.assertEquals("TransactionId", transId, value);
+
+ }
+
+}