X-Git-Url: http://www.project-moonshot.org/gitweb/?a=blobdiff_plain;f=samltest%2FArtifactMapTest.h;fp=samltest%2FArtifactMapTest.h;h=72a8b2df684fd7d408750536664054c8151d61ca;hb=54bc3fd9396935d92c53bbb69d003e8d121720c2;hp=0000000000000000000000000000000000000000;hpb=e7d56a2d45c08ee71853ff8f19d04a4ef83448e6;p=shibboleth%2Fcpp-opensaml.git diff --git a/samltest/ArtifactMapTest.h b/samltest/ArtifactMapTest.h new file mode 100644 index 0000000..72a8b2d --- /dev/null +++ b/samltest/ArtifactMapTest.h @@ -0,0 +1,55 @@ +/* + * Copyright 2001-2005 Internet2 + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "internal.h" +#include +#include +#include + +using namespace opensaml::saml2p; +using namespace opensaml; +using namespace std; + +class ArtifactMapTest : public CxxTest::TestSuite +{ +public: + string providerIdStr; + string handle; + ArtifactMap* artifactMap; + void setUp() { + if (handle.empty()) { + providerIdStr = "https://idp.org/SAML"; + SAMLConfig::getConfig().generateRandomBytes(handle,SAML2ArtifactType0004::HANDLE_LENGTH); + } + artifactMap = new ArtifactMap(); + } + void tearDown() { + delete artifactMap; + artifactMap=NULL; + } + void testArtifactMap(void) { + auto_ptr response(ResponseBuilder::buildResponse()); + + SAML2ArtifactType0004 artifact(SAMLConfig::getConfig().hashSHA1(providerIdStr.c_str()),666,handle); + + artifactMap->storeContent(response.get(), &artifact, providerIdStr.c_str()); + response.release(); + + auto_ptr xmlObject(artifactMap->retrieveContent(&artifact, providerIdStr.c_str())); + TSM_ASSERT_THROWS("Artifact resolution improperly succeeded.", artifactMap->retrieveContent(&artifact), BindingException); + TSM_ASSERT("Mapped content was not a Response.", dynamic_cast(xmlObject.get())!=NULL); + } +};