From c9a5ae83bf2a895d38f4ea43cdcf4a2ff5f97fd0 Mon Sep 17 00:00:00 2001 From: Mark Donnelly Date: Thu, 20 Nov 2014 14:52:38 -0500 Subject: [PATCH] Update tests to deal with GSSCommand objects now taking only the 'argument' part of the input JSON --- json_gssapi/test/GSSCreateSecContextTest.cpp | 16 +++++++++++----- json_gssapi/test/GSSImportNameTest.cpp | 17 +++++------------ 2 files changed, 16 insertions(+), 17 deletions(-) diff --git a/json_gssapi/test/GSSCreateSecContextTest.cpp b/json_gssapi/test/GSSCreateSecContextTest.cpp index 8926e7b..dd006b4 100644 --- a/json_gssapi/test/GSSCreateSecContextTest.cpp +++ b/json_gssapi/test/GSSCreateSecContextTest.cpp @@ -16,6 +16,7 @@ #include #include #include +#include // Registers the fixture into the 'registry' CPPUNIT_TEST_SUITE_REGISTRATION( GSSCreateSecContextTest ); @@ -163,25 +164,25 @@ void GSSCreateSecContextTest::testConstructorWithJSONObject() 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.", - std::string(json["arguments"]["mech_type"].string()), + std::string(json["mech_type"].string()), 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)json["arguments"]["time_req"].integer(), + (int)json["time_req"].integer(), (int)cmd.getTimeReq() ); @@ -356,11 +357,16 @@ void GSSCreateSecContextTest::testJSONMarshal() ( strcmp("{ 1 3 6 1 5 5 13 4 }", (*result)["actual_mech_type"].string() ) == 0 ) ); + + + unsigned long len; + std::string str = (*result)["output_token"].string(); + unsigned char *decoded = base64_decode(str, &len); CPPUNIT_ASSERT_MESSAGE( "The output_token value was reported incorrectly", ( strcmp((const char *)(InitSecContextMock::output_token.value), - (*result)["output_token"].string() ) == 0 ) + (const char *)decoded ) == 0 ) ); CPPUNIT_ASSERT_EQUAL_MESSAGE( diff --git a/json_gssapi/test/GSSImportNameTest.cpp b/json_gssapi/test/GSSImportNameTest.cpp index a890af6..a7c6cad 100644 --- a/json_gssapi/test/GSSImportNameTest.cpp +++ b/json_gssapi/test/GSSImportNameTest.cpp @@ -134,9 +134,8 @@ void GSSImportNameTest::testEmptyCall() void GSSImportNameTest::testConstructorWithJSONObject() { /* Variables */ - const char* input = "{\"method\": \"gss_import_name\", \ - \"arguments\": {\"input_name\": \"http@localhost\", \ - \"input_name_type\": \"{ 1 2 840 113554 1 2 1 4 }\"}}"; + const char* input = "{\"input_name\": \"http@localhost\", \ + \"input_name_type\": \"{ 1 2 840 113554 1 2 1 4 }\"}"; json_error_t jsonErr; JSONObject json = JSONObject::load(input, 0, &jsonErr); @@ -196,26 +195,20 @@ void GSSImportNameTest::testJSONMarshal() // std::cout << "JSON Output:" << std::endl << result->dump(4) << std::endl; - CPPUNIT_ASSERT_EQUAL_MESSAGE( - "The command name is incorrect", - std::string("gss_import_name"), - std::string( (*result)["command"].string() ) - ); - CPPUNIT_ASSERT_EQUAL_MESSAGE( "The return value was reported incorrectly", (int)MockImportName::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)MockImportName::minor_status, - (int)( (*result)["return_values"]["minor_status"].integer() ) + (int)( (*result)["minor_status"].integer() ) ); - key = (*result)["return_values"]["gss_name"].string(); + key = (*result)["gss_name"].string(); gssName = GSSNameCache::instance()->retrieve(key); CPPUNIT_ASSERT_EQUAL_MESSAGE( -- 2.1.4