Convert from NULL macro to nullptr, remove unused zlib code.
[shibboleth/cpp-opensaml.git] / samltest / ArtifactMapTest.h
1 /*
2  *  Copyright 2001-2010 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 #include <xmltooling/security/SecurityHelper.h>
23
24 using namespace opensaml::saml2p;
25 using namespace opensaml;
26 using namespace std;
27
28 class ArtifactMapTest : public CxxTest::TestSuite
29 {
30 public:
31     string providerIdStr;
32     string handle;
33     void setUp() {
34         if (handle.empty()) {
35             providerIdStr = "https://idp.org/SAML";
36             SAMLConfig::getConfig().generateRandomBytes(handle,SAML2ArtifactType0004::HANDLE_LENGTH);
37         }
38     }
39     void tearDown() {
40     }
41     void testArtifactMap(void) {
42         auto_ptr<Response> response(ResponseBuilder::buildResponse());
43
44         SAML2ArtifactType0004 artifact(
45             SecurityHelper::doHash("SHA1", providerIdStr.data(), providerIdStr.length(), false), 666, handle
46             );
47         
48         ArtifactMap* artifactMap = SAMLConfig::getConfig().getArtifactMap();
49         artifactMap->storeContent(response.get(), &artifact, providerIdStr.c_str());
50         response.release();
51
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);
55     }
56 };