Commit an overly-large chunk of work.
[gssweb.git] / json_gssapi / test / GSSUnwrapTest.cpp
index d807b52..7b26008 100644 (file)
@@ -5,11 +5,16 @@
  *
  */
 
+#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 );
 
 /* 
@@ -138,15 +143,17 @@ void GSSUnwrapTest::testEmptyCall()
 void GSSUnwrapTest::testConstructorWithJSONObject()
 {
   /* Variables */
-  const char* input = "{\"method\": \"gss_wrap\", \
+  GSSContext context((gss_ctx_id_t)rand(), true);
+  std::string key = GSSContextCache::instance()->store(context);
+  std::string input = "{\"method\": \"gss_wrap\", \
     \"arguments\": \
     { \
-         \"context_handle\": \"#######\", \
+         \"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);
   
@@ -155,6 +162,12 @@ void GSSUnwrapTest::testConstructorWithJSONObject()
   /* 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()