#include "GSSGetMicTest.h"
#include "command_mocks/MockGetMic.h"
#include "GSSGetMic.h"
+#include <datamodel/GSSContext.h>
+#include <cache/GSSContextCache.h>
#include <gssapi/gssapi.h>
CPPUNIT_TEST_SUITE_REGISTRATION( GSSGetMicTest );
{
/* Error checking */
/* Variables */
- std::string buffer;
/* Setup */
- buffer = MockGetMic::outputToken.toString();
/* Main */
// Copy our input from the appropriate parameters to MockGetMic
// copy our output to the appropriate parameters
*minor_status = MockGetMic::minor_status;
- message_token->length = buffer.length();
- message_token->value = (void *)buffer.c_str();
+ *message_token = *MockGetMic::outputToken.toGss();
/* Cleanup */
/* return */
GSSBuffer input((char *)"Input message");
std::string out("Output Message");
gss_qop_t desiredQop = rand();
- gss_ctx_id_t desiredContext = (gss_ctx_id_t)rand();
+ gss_ctx_id_t desiredContext = (gss_ctx_id_t)( (long)0 | rand() );
/* Error checking */
/* Setup */
void GSSGetMicTest::testConstructorWithJSONObject()
{
/* Variables */
- const char* input = "{\"method\": \"gss_get_mic\", \
- \"arguments\": \
- { \
- \"context_handle\": \"#######\", \
+ GSSContext context((gss_ctx_id_t)( (long)0 | rand() ),
+ true);
+ std::string key = GSSContextCache::instance()->store(context);
+
+ std::string input = "{ \
+ \"context_handle\": \"" + key + "\", \
\"qop_req\": \"GSS_C_QOP_DEFAULT\", \
\"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);
GSSGetMic cmd = GSSGetMic(&json, &mock_get_mic);
cmd.getInputMessage().toString()
);
+ CPPUNIT_ASSERT_EQUAL_MESSAGE(
+ "GSSGetMic did not retrieve the context handle correctly",
+ context.getContext(),
+ cmd.getContextHandle()
+ );
+
/* Cleanup */
/* Return */
}
// std::cout << "\nGSSGetMic JSON: \n" << result->dump() << "\n";
CPPUNIT_ASSERT_EQUAL_MESSAGE(
- "The command name is incorrect",
- std::string("gss_get_mic"),
- std::string( (*result)["command"].string() )
- );
-
-
- CPPUNIT_ASSERT_EQUAL_MESSAGE(
"The return value was reported incorrectly",
(int)MockGetMic::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)MockGetMic::minor_status,
- (int)( (*result)["return_values"]["minor_status"].integer() )
+ (int)( (*result)["minor_status"].integer() )
);
CPPUNIT_ASSERT_EQUAL_MESSAGE(
"The output message was reported incorrectly",
output,
- std::string( (*result)["return_values"]["output_token"].string() )
+ std::string( (*result)["output_token"].string() )
);