projects
/
gssweb.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Move util_ files into utils directory, move main.cpp into src
[gssweb.git]
/
json_gssapi
/
test
/
GSSCreateSecContextTest.cpp
diff --git
a/json_gssapi/test/GSSCreateSecContextTest.cpp
b/json_gssapi/test/GSSCreateSecContextTest.cpp
index
8669267
..
cf3be56
100644
(file)
--- a/
json_gssapi/test/GSSCreateSecContextTest.cpp
+++ b/
json_gssapi/test/GSSCreateSecContextTest.cpp
@@
-7,20
+7,21
@@
#include "GSSCreateSecContextTest.h"
#include "GSSCreateSecContextTest.h"
-#include "GSS
CreateSecContextCommand
.h"
+#include "GSS
InitSecContext
.h"
#include "command_mocks/InitSecContextMock.h"
#include <iostream>
#include <string.h>
#include <exception>
#include "command_mocks/InitSecContextMock.h"
#include <iostream>
#include <string.h>
#include <exception>
-#include "util_json.h"
+#include "util
s/util
_json.h"
#include <cache/GSSContextCache.h>
#include <cache/GSSNameCache.h>
#include <datamodel/GSSContext.h>
#include <cache/GSSContextCache.h>
#include <cache/GSSNameCache.h>
#include <datamodel/GSSContext.h>
+#include <utils/util_base64.h>
// Registers the fixture into the 'registry'
CPPUNIT_TEST_SUITE_REGISTRATION( GSSCreateSecContextTest );
// Registers the fixture into the 'registry'
CPPUNIT_TEST_SUITE_REGISTRATION( GSSCreateSecContextTest );
-
+using std::cout;
static OM_uint32 KRB5_CALLCONV
mock_init_sec(
static OM_uint32 KRB5_CALLCONV
mock_init_sec(
@@
-84,12
+85,12
@@
GSSCreateSecContextTest::tearDown()
void
GSSCreateSecContextTest::testConstructor()
{
void
GSSCreateSecContextTest::testConstructor()
{
- GSS
CreateSecContextCommand cmd = GSSCreateSecContextCommand
();
-
void *
cmdFn;
-
void *
GSSFn;
+ GSS
InitSecContext cmd = GSSInitSecContext
();
+
init_sec_context_type
cmdFn;
+
init_sec_context_type
GSSFn;
cmdFn = cmd.getGSSFunction();
cmdFn = cmd.getGSSFunction();
- GSSFn =
(void *)
&gss_init_sec_context;
+ GSSFn = &gss_init_sec_context;
CPPUNIT_ASSERT_MESSAGE(
"The default constructor for GSSCreateSecContextCommand should assign the function gss_init_sec_context",
cmdFn == GSSFn);
CPPUNIT_ASSERT_MESSAGE(
"The default constructor for GSSCreateSecContextCommand should assign the function gss_init_sec_context",
cmdFn == GSSFn);
@@
-139,20
+140,19
@@
void GSSCreateSecContextTest::testConstructorWithJSONObject()
source.setValue(src);
std::string key = GSSNameCache::instance()->store(source);
source.setValue(src);
std::string key = GSSNameCache::instance()->store(source);
- std::string input = "{\"method\": \"gss_create_sec_context\", \
- \"arguments\": {\"req_flags\": \"1\", \
+ std::string input = "{\"req_flags\": \"1\", \
\"time_req\": \"2\", \
\"mech_type\": \"{ 1 2 840 113554 1 2 1 4 }\", \
\"target_name\": \"";
\"time_req\": \"2\", \
\"mech_type\": \"{ 1 2 840 113554 1 2 1 4 }\", \
\"target_name\": \"";
- input = input + key + "\"}
}
";
+ input = input + key + "\"}";
json_error_t jsonErr;
const char *in = input.c_str();
JSONObject json = JSONObject::load(in, 0, &jsonErr);
json_error_t jsonErr;
const char *in = input.c_str();
JSONObject json = JSONObject::load(in, 0, &jsonErr);
- GSS
CreateSecContextCommand cmd = GSSCreateSecContextCommand
(
+ GSS
InitSecContext cmd = GSSInitSecContext
(
&json,
&json,
-
(void *)
&mock_init_sec
+ &mock_init_sec
);
const char *from_cmd = cmd.getTargetDisplayName();
);
const char *from_cmd = cmd.getTargetDisplayName();
@@
-164,25
+164,25
@@
void GSSCreateSecContextTest::testConstructorWithJSONObject()
CPPUNIT_ASSERT_EQUAL_MESSAGE(
"The context_handle values differ.",
CPPUNIT_ASSERT_EQUAL_MESSAGE(
"The context_handle values differ.",
- json["
arguments"]["
context_handle"].integer(),
+ json["context_handle"].integer(),
(json_int_t)cmd.getContextHandle()
);
CPPUNIT_ASSERT_EQUAL_MESSAGE(
"The mech_type values differ.",
(json_int_t)cmd.getContextHandle()
);
CPPUNIT_ASSERT_EQUAL_MESSAGE(
"The mech_type values differ.",
- std::string(json["
arguments"]["
mech_type"].string()),
+ std::string(json["mech_type"].string()),
cmd.getMechType().toString()
);
CPPUNIT_ASSERT_EQUAL_MESSAGE(
"The req_flags differ.",
cmd.getMechType().toString()
);
CPPUNIT_ASSERT_EQUAL_MESSAGE(
"The req_flags differ.",
- (int)json["
arguments"]["
req_flags"].integer(),
+ (int)json["req_flags"].integer(),
(int)cmd.getReqFlags()
);
CPPUNIT_ASSERT_EQUAL_MESSAGE(
"The req_flags differ.",
(int)cmd.getReqFlags()
);
CPPUNIT_ASSERT_EQUAL_MESSAGE(
"The req_flags differ.",
- (int)json["
arguments"]["
time_req"].integer(),
+ (int)json["time_req"].integer(),
(int)cmd.getTimeReq()
);
(int)cmd.getTimeReq()
);
@@
-193,7
+193,7
@@
GSSCreateSecContextTest::testEmptyCall()
{
gss_ctx_id_t expectedResult, expectedArgument;
{
gss_ctx_id_t expectedResult, expectedArgument;
- GSS
CreateSecContextCommand cmd ((void *)
&mock_init_sec);
+ GSS
InitSecContext cmd (
&mock_init_sec);
/* Set expectations on what the GSS function will be called with */
cmd.time_req = rand() % 1024;
/* Set expectations on what the GSS function will be called with */
cmd.time_req = rand() % 1024;
@@
-309,7
+309,7
@@
GSSCreateSecContextTest::testEmptyCall()
void GSSCreateSecContextTest::testJSONMarshal()
{
/* Variables */
void GSSCreateSecContextTest::testJSONMarshal()
{
/* Variables */
- GSS
CreateSecContextCommand cmd ((void *)
&mock_init_sec);
+ GSS
InitSecContext cmd (
&mock_init_sec);
JSONObject *result;
GSSContextCache *cache = GSSContextCache::instance();
GSSContext context;
JSONObject *result;
GSSContextCache *cache = GSSContextCache::instance();
GSSContext context;
@@
-340,50
+340,53
@@
void GSSCreateSecContextTest::testJSONMarshal()
/*
std::cout << "create sec context json: " << result->dump() << "\n";*/
/*
std::cout << "create sec context json: " << result->dump() << "\n";*/
- CPPUNIT_ASSERT_MESSAGE(
- "The command name is incorrect",
- ( strcmp("gss_init_sec_context",
- (*result)["command"].string() ) == 0 )
- );
-
-
CPPUNIT_ASSERT_EQUAL_MESSAGE(
"The return value was reported incorrectly",
(int)InitSecContextMock::retVal,
CPPUNIT_ASSERT_EQUAL_MESSAGE(
"The return value was reported incorrectly",
(int)InitSecContextMock::retVal,
- (int)( (*result)["
return_values"]["
major_status"].integer() )
+ (int)( (*result)["major_status"].integer() )
);
CPPUNIT_ASSERT_EQUAL_MESSAGE(
"The minor_status value was reported incorrectly",
(int)InitSecContextMock::minor_status,
);
CPPUNIT_ASSERT_EQUAL_MESSAGE(
"The minor_status value was reported incorrectly",
(int)InitSecContextMock::minor_status,
- (int)( (*result)["
return_values"]["
minor_status"].integer() )
+ (int)( (*result)["minor_status"].integer() )
);
CPPUNIT_ASSERT_MESSAGE(
"The actual_mech_type value was reported incorrectly",
( strcmp("{ 1 3 6 1 5 5 13 4 }",
);
CPPUNIT_ASSERT_MESSAGE(
"The actual_mech_type value was reported incorrectly",
( strcmp("{ 1 3 6 1 5 5 13 4 }",
- (*result)["
return_values"]["
actual_mech_type"].string() ) == 0 )
+ (*result)["actual_mech_type"].string() ) == 0 )
);
);
+
+
+ std::string str = (*result)["output_token"].string();
+ size_t len;
+ void *decoded = base64Decode(str.c_str(), &len);
+ CPPUNIT_ASSERT_MESSAGE(
+ "The decoded token size is incorrect",
+ ( len == InitSecContextMock::output_token.length )
+ );
CPPUNIT_ASSERT_MESSAGE(
"The output_token value was reported incorrectly",
CPPUNIT_ASSERT_MESSAGE(
"The output_token value was reported incorrectly",
- (
strcmp((const char *)(InitSecContextMock::output_token.value),
-
(*result)["return_values"]["output_token"].string()
) == 0 )
+ (
memcmp(InitSecContextMock::output_token.value,
+
decoded, len
) == 0 )
);
);
+ base64Free(decoded);
CPPUNIT_ASSERT_EQUAL_MESSAGE(
"The minor_status value was reported incorrectly",
(int)InitSecContextMock::ret_flags,
CPPUNIT_ASSERT_EQUAL_MESSAGE(
"The minor_status value was reported incorrectly",
(int)InitSecContextMock::ret_flags,
- (int)( (*result)["ret
urn_values"]["ret
_flags"].integer() )
+ (int)( (*result)["ret_flags"].integer() )
);
CPPUNIT_ASSERT_EQUAL_MESSAGE(
"The minor_status value was reported incorrectly",
(int)InitSecContextMock::time_rec,
);
CPPUNIT_ASSERT_EQUAL_MESSAGE(
"The minor_status value was reported incorrectly",
(int)InitSecContextMock::time_rec,
- (int)( (*result)["
return_values"]["
time_rec"].integer() )
+ (int)( (*result)["time_rec"].integer() )
);
);
- context = cache->retrieve( (*result)["
return_values"]["
context_handle"].string() );
+ context = cache->retrieve( (*result)["context_handle"].string() );
CPPUNIT_ASSERT_EQUAL_MESSAGE(
"The returned context was reported incorrectly",
CPPUNIT_ASSERT_EQUAL_MESSAGE(
"The returned context was reported incorrectly",