SAML 2.0 artifact bits plus tests
[shibboleth/cpp-opensaml.git] / samltest / SAMLArtifactType0001Test.h
diff --git a/samltest/SAMLArtifactType0001Test.h b/samltest/SAMLArtifactType0001Test.h
new file mode 100644 (file)
index 0000000..48c8754
--- /dev/null
@@ -0,0 +1,44 @@
+/*\r
+ *  Copyright 2001-2005 Internet2\r
+ * \r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ *     http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ */\r
+\r
+#include "internal.h"\r
+#include <saml/saml1/core/SAMLArtifactType0001.h>\r
+\r
+using namespace opensaml::saml1p;\r
+using namespace opensaml;\r
+using namespace std;\r
+\r
+class SAMLArtifactType0001Test : public CxxTest::TestSuite\r
+{\r
+public:\r
+    string providerIdStr;\r
+\r
+    void setUp() {\r
+        providerIdStr = "https://idp.org/SAML";\r
+    }\r
+    \r
+    void testSAMLArtifactType0001(void) {\r
+        string sourceId = SAMLConfig::getConfig().hashSHA1(providerIdStr.c_str());\r
+        auto_ptr<SAMLArtifactType0001> artifact(new SAMLArtifactType0001(sourceId));\r
+        auto_ptr<SAMLArtifact> tempArtifact(SAMLArtifact::parse(artifact->encode().c_str()));\r
+        \r
+        TS_ASSERT_EQUALS(artifact->getSource(),tempArtifact->getSource());\r
+        TS_ASSERT_EQUALS(artifact->getMessageHandle(),tempArtifact->getMessageHandle());\r
+        \r
+        TS_ASSERT_THROWS(auto_ptr<SAMLArtifact> bogus1(new SAMLArtifactType0001(sourceId + sourceId)), ArtifactException);\r
+        TS_ASSERT_THROWS(auto_ptr<SAMLArtifact> bogus2(new SAMLArtifactType0001(sourceId, artifact->getMessageHandle() + artifact->getMessageHandle())), ArtifactException);\r
+    }\r
+};\r