2 * Copyright (c) 2014, 2015 JANET(UK)
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
16 * 3. Neither the name of JANET(UK) nor the names of its contributors
17 * may be used to endorse or promote products derived from this software
18 * without specific prior written permission.
20 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
23 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
24 * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
25 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
26 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
27 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
29 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
30 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
31 * OF THE POSSIBILITY OF SUCH DAMAGE.
35 #include "GSSExceptionTest.h"
36 #include "GSSException.h"
41 // Registers the fixture into the 'registry'
42 CPPUNIT_TEST_SUITE_REGISTRATION( GSSExceptionTest );
44 void GSSExceptionTest::setUp()
46 CppUnit::TestFixture::setUp();
49 void GSSExceptionTest::tearDown()
51 CppUnit::TestFixture::tearDown();
55 void GSSExceptionTest::testWithMessage()
58 throw GSSException("Test message");
59 } catch (GSSException e)
61 CPPUNIT_ASSERT_EQUAL_MESSAGE(
62 "GSSException message reporting is incorrect.",
63 std::string("Test message\n\
66 The routine completed successfully\n\
68 Minor status details: \n\
75 void GSSExceptionTest::testWithMessageAndMajor()
78 throw GSSException("Test message", 524288);
79 } catch (GSSException e)
81 CPPUNIT_ASSERT_EQUAL_MESSAGE(
82 "GSSException message reporting is incorrect.",
83 std::string("Test message\n\
86 No context has been established\n\
88 Minor status details: \n\
95 void GSSExceptionTest::testWithMessageAndMajorAndMinor()
97 OM_uint32 major, minor, context = 0;
98 gss_buffer_desc_struct buf;
101 major = gss_display_status(&minor, 2109382930, GSS_C_MECH_CODE, GSS_C_NO_OID, &context, &buf);
102 throw GSSException("Test message", major, minor);
103 } catch (GSSException e)
105 CPPUNIT_ASSERT_EQUAL_MESSAGE(
106 "GSSException message reporting is incorrect.",
107 std::string("Test message\n\
108 GSS Error message:\n\
110 An invalid status code was supplied\n\
112 Minor status details: \n\
113 Invalid argument\n"),
114 std::string(e.what())
119 void GSSExceptionTest::testWithMessageAndMajorAndMinorAndMechanism()
122 OM_uint32 major, minor, context = 0;
123 gss_buffer_desc_struct buf;
126 major = gss_display_status(&minor, 2109382930, GSS_C_MECH_CODE, GSS_C_NO_OID, &context, &buf);
127 throw GSSException("Test message", major, minor, GSS_C_NO_OID);
128 } catch (GSSException e)
130 CPPUNIT_ASSERT_EQUAL_MESSAGE(
131 "GSSException message reporting is incorrect.",
132 std::string("Test message\n\
133 GSS Error message:\n\
135 An invalid status code was supplied\n\
137 Minor status details: \n\
138 Invalid argument\n"),
139 std::string(e.what())