Add copyright comment headers to appropriate files
[gssweb.git] / json_gssapi / test / GSSPseudoRandomTest.cpp
index e38ab49..65cd5c2 100644 (file)
@@ -1,7 +1,34 @@
 /*
- * Copyright (c) 2014 <copyright holder> <email>
+ * Copyright (c) 2014, 2015 JANET(UK)
+ * All rights reserved.
  *
- * For license details, see the LICENSE file in the root of this project.
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * 3. Neither the name of JANET(UK) nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
+ * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
+ * OF THE POSSIBILITY OF SUCH DAMAGE.
  *
  */
 
@@ -38,7 +65,6 @@ OM_uint32 mock_gss_pseudo_random(
     gss_buffer_t prf_out)
 {
   /* Variables */
-  std::string buffer;
   /* Error checking */
   /* Setup */
   /* Main */
@@ -47,9 +73,7 @@ OM_uint32 mock_gss_pseudo_random(
   MockPseudoRandom::inputMessageBuffer.setValue(prf_in);
   MockPseudoRandom::desiredOutputLength = desired_output_len;
   
-  buffer = MockPseudoRandom::outputMessageBuffer.toString();
-  prf_out->length = buffer.length();
-  prf_out->value = (void *)buffer.c_str();
+  *prf_out = *MockPseudoRandom::outputMessageBuffer.toGss();
   
   /* Cleanup */
   /* Return */
@@ -186,18 +210,16 @@ void GSSPseudoRandomTest::testEmptyCall()
 void GSSPseudoRandomTest::testConstructorWithJSONObject()
 {
   /* Variables */
-  GSSContext context( (gss_ctx_id_t)rand(), true );
+  GSSContext context( (gss_ctx_id_t)( (long)0 | rand() ),
+                     true );
   std::string key = GSSContextCache::instance()->store(context);
   
-  std::string input = "{\"method\": \"gss_pseudo_random\", \
-    \"arguments\": \
-    { \
+  std::string input = "{ \
          \"context_handle\": \"" + key + "\", \
          \"prf_key\": 1234567890, \
          \"prf_in\": \"mary had a little lamb\", \
          \"desired_output_len\": 256 \
-    }\
-  }";
+    }";
   json_error_t jsonErr;
   JSONObject json = JSONObject::load(input.c_str(), 0, &jsonErr);
   
@@ -267,27 +289,21 @@ void GSSPseudoRandomTest::testJSONMarshal()
 //   std::cout << "\nGSSWrap JSON: \n" << result->dump() << "\n";
   
   CPPUNIT_ASSERT_EQUAL_MESSAGE(
-    "The command name is incorrect",
-    std::string("gss_pseudo_random"),
-    std::string( (*result)["command"].string() )
-  );
-  
-  CPPUNIT_ASSERT_EQUAL_MESSAGE(
     "The return value was reported incorrectly",
     (int)MockPseudoRandom::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)MockPseudoRandom::minor_status,
-    (int)( (*result)["return_values"]["minor_status"].integer() )
+    (int)( (*result)["minor_status"].integer() )
   );
   
   CPPUNIT_ASSERT_EQUAL_MESSAGE(
     "The random bytes were reported incorrectly",
     MockPseudoRandom::outputMessageBuffer.toString(),
-    std::string( (*result)["return_values"]["random_bytes"].string() )
+    std::string( (*result)["random_bytes"].string() )
   );