*
*/
+#include <string>
+
#include "GSSUnwrapTest.h"
#include "command_mocks/MockUnwrap.h"
#include "GSSUnwrap.h"
+#include <datamodel/GSSContext.h>
+#include <cache/GSSContextCache.h>
#include <gssapi/gssapi.h>
+
CPPUNIT_TEST_SUITE_REGISTRATION( GSSUnwrapTest );
/*
void GSSUnwrapTest::testConstructorWithJSONObject()
{
/* Variables */
- const char* input = "{\"method\": \"gss_wrap\", \
- \"arguments\": \
- { \
- \"context_handle\": \"#######\", \
+ GSSContext context((gss_ctx_id_t)rand(), true);
+ std::string key = GSSContextCache::instance()->store(context);
+ std::string input = "{ \
+ \"context_handle\": \"" + key + "\", \
\"input_message\": \"mary had a little lamb\" \
- }\
- }";
+ }";
json_error_t jsonErr;
- JSONObject json = JSONObject::load(input, 0, &jsonErr);
+ JSONObject json = JSONObject::load(input.c_str(), 0, &jsonErr);
GSSUnwrap cmd = GSSUnwrap(&json, &mock_unwrap);
/* Main */
CPPUNIT_ASSERT_EQUAL_MESSAGE(
+ "GSSUnwrap did not retrieve the GSS context correctly",
+ context.getContext(),
+ cmd.getContextHandle()
+ );
+
+ CPPUNIT_ASSERT_EQUAL_MESSAGE(
"GSSUnwrap did not parse the input message argument correctly",
std::string("mary had a little lamb"),
cmd.getInputMessage().toString()
result = cmd.toJSON();
// std::cout << "\nGSSUnwrap JSON: \n" << result->dump() << "\n";
- CPPUNIT_ASSERT_EQUAL_MESSAGE(
- "The command name is incorrect",
- std::string("gss_wrap"),
- std::string( (*result)["command"].string() )
- );
-
CPPUNIT_ASSERT_EQUAL_MESSAGE(
"The return value was reported incorrectly",
(int)MockUnwrap::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)MockUnwrap::minor_status,
- (int)( (*result)["return_values"]["minor_status"].integer() )
+ (int)( (*result)["minor_status"].integer() )
);
CPPUNIT_ASSERT_EQUAL_MESSAGE(
"The output message was reported incorrectly",
MockUnwrap::outputMessageBuffer.toString(),
- std::string( (*result)["return_values"]["output_message"].string() )
+ std::string( (*result)["output_message"].string() )
);
CPPUNIT_ASSERT_EQUAL_MESSAGE(
"The minor_status value was reported incorrectly",
(int)qopState,
- (int)( (*result)["return_values"]["qop_state"].integer() )
+ (int)( (*result)["qop_state"].integer() )
);