2 * Copyright 2001-2010 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>
22 #include <xmltooling/security/SecurityHelper.h>
24 using namespace opensaml::saml2p;
25 using namespace opensaml;
28 class ArtifactMapTest : public CxxTest::TestSuite
35 providerIdStr = "https://idp.org/SAML";
36 SAMLConfig::getConfig().generateRandomBytes(handle,SAML2ArtifactType0004::HANDLE_LENGTH);
41 void testArtifactMap(void) {
42 auto_ptr<Response> response(ResponseBuilder::buildResponse());
44 SAML2ArtifactType0004 artifact(
45 SecurityHelper::doHash("SHA1", providerIdStr.data(), providerIdStr.length(), false), 666, handle
48 ArtifactMap* artifactMap = SAMLConfig::getConfig().getArtifactMap();
49 artifactMap->storeContent(response.get(), &artifact, providerIdStr.c_str());
52 auto_ptr<XMLObject> xmlObject(artifactMap->retrieveContent(&artifact, providerIdStr.c_str()));
53 TSM_ASSERT_THROWS("Artifact resolution improperly succeeded.", artifactMap->retrieveContent(&artifact), BindingException);
54 TSM_ASSERT("Mapped content was not a Response.", dynamic_cast<Response*>(xmlObject.get())!=nullptr);