Bump lib version.
[shibboleth/cpp-opensaml.git] / samltest / ArtifactMapTest.h
1 /*
2  *  Copyright 2001-2007 Internet2
3  * 
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
7  *
8  *     http://www.apache.org/licenses/LICENSE-2.0
9  *
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.
15  */
16
17 #include "internal.h"
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
23 using namespace opensaml::saml2p;
24 using namespace opensaml;
25 using namespace std;
26
27 class ArtifactMapTest : public CxxTest::TestSuite
28 {
29 public:
30     string providerIdStr;
31     string handle;
32     void setUp() {
33         if (handle.empty()) {
34             providerIdStr = "https://idp.org/SAML";
35             SAMLConfig::getConfig().generateRandomBytes(handle,SAML2ArtifactType0004::HANDLE_LENGTH);
36         }
37     }
38     void tearDown() {
39     }
40     void testArtifactMap(void) {
41         auto_ptr<Response> response(ResponseBuilder::buildResponse());
42
43         SAML2ArtifactType0004 artifact(SAMLConfig::getConfig().hashSHA1(providerIdStr.c_str()),666,handle);
44         
45         ArtifactMap* artifactMap = SAMLConfig::getConfig().getArtifactMap();
46         artifactMap->storeContent(response.get(), &artifact, providerIdStr.c_str());
47         response.release();
48
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);
52     }
53 };