2 * Copyright 2001-2007 Internet2
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
18 #include <saml/SAMLConfig.h>
19 #include "saml/binding/ArtifactMap.h"
20 #include <saml/saml2/binding/SAML2ArtifactType0004.h>
21 #include <saml/saml2/core/Protocols.h>
23 using namespace opensaml::saml2p;
24 using namespace opensaml;
27 class ArtifactMapTest : public CxxTest::TestSuite
34 providerIdStr = "https://idp.org/SAML";
35 SAMLConfig::getConfig().generateRandomBytes(handle,SAML2ArtifactType0004::HANDLE_LENGTH);
40 void testArtifactMap(void) {
41 auto_ptr<Response> response(ResponseBuilder::buildResponse());
43 SAML2ArtifactType0004 artifact(SAMLConfig::getConfig().hashSHA1(providerIdStr.c_str()),666,handle);
45 ArtifactMap* artifactMap = SAMLConfig::getConfig().getArtifactMap();
46 artifactMap->storeContent(response.get(), &artifact, providerIdStr.c_str());
49 auto_ptr<XMLObject> xmlObject(artifactMap->retrieveContent(&artifact, providerIdStr.c_str()));
50 TSM_ASSERT_THROWS("Artifact resolution improperly succeeded.", artifactMap->retrieveContent(&artifact), BindingException);
51 TSM_ASSERT("Mapped content was not a Response.", dynamic_cast<Response*>(xmlObject.get())!=NULL);