From: Mark Donnelly Date: Wed, 30 Apr 2014 20:40:25 +0000 (-0400) Subject: GSS import name working X-Git-Url: http://www.project-moonshot.org/gitweb/?p=gssweb.git;a=commitdiff_plain;h=b3a9fa38b5efc6a79f54de0d08c48290b30c4fba GSS import name working --- diff --git a/.gitignore b/.gitignore index a0028da..b6c2844 100644 --- a/.gitignore +++ b/.gitignore @@ -81,4 +81,4 @@ Doxyfile json_gssapi/build json_gssapi/debug json_gssapi/manual -test/ \ No newline at end of file +./test/ \ No newline at end of file diff --git a/json_gssapi/src/GSSImportName.cpp b/json_gssapi/src/GSSImportName.cpp index feb9127..2cf6a42 100644 --- a/json_gssapi/src/GSSImportName.cpp +++ b/json_gssapi/src/GSSImportName.cpp @@ -11,11 +11,32 @@ void GSSImportName::execute() { this->outputName = GSSName(inputName, inputNameType, function); + this->retVal = this->outputName.getMajorStatus(); + this->minor_status = this->outputName.getMinorStatus(); + this->outputName.setKey("constant for now"); } JSONObject *GSSImportName::toJSON() { - return new JSONObject(); + /* Variables */ + JSONObject *ret = new JSONObject(); + JSONObject *values = new JSONObject(); + + /* Error checking */ + + /* Setup */ + + /* Main */ + values->set("major_status", this->retVal); + values->set("minor_status", this->minor_status); + values->set("gss_name", this->outputName.getKey().c_str() ); + ret->set("command", "gss_import_name"); + ret->set("return_values", *values); + + /* Cleanup */ + + /* Return */ + return(ret); } GSSImportName::GSSImportName(JSONObject *params, gss_imp_name_type fn) : GSSCommand(params) diff --git a/json_gssapi/src/datamodel/GSSName.cpp b/json_gssapi/src/datamodel/GSSName.cpp index 9260bf4..a009c64 100644 --- a/json_gssapi/src/datamodel/GSSName.cpp +++ b/json_gssapi/src/datamodel/GSSName.cpp @@ -11,17 +11,16 @@ void GSSName::init(const GSSBuffer namestr, GSSOID name_type, gss_imp_name_type fn) { /* Variables */ - OM_uint32 major, minor; /* Error checking */ /* Setup */ /* Main */ - major = fn(&minor, namestr.toGss(), name_type.toGss(), &name); - if ( GSS_ERROR(major) ) + this->major_status = fn(&(this->minor_status), namestr.toGss(), name_type.toGss(), &name); + if ( GSS_ERROR(this->major_status) ) { std::string errMsg; errMsg += "Cannot import name: "; errMsg += namestr.toString(); - throw GSSException(errMsg.c_str(), major, minor, name_type.toGss()); + throw GSSException(errMsg.c_str(), this->major_status, this->minor_status, name_type.toGss()); } /* Cleanup */ diff --git a/json_gssapi/src/datamodel/GSSName.h b/json_gssapi/src/datamodel/GSSName.h index 32f1908..05fe2a1 100644 --- a/json_gssapi/src/datamodel/GSSName.h +++ b/json_gssapi/src/datamodel/GSSName.h @@ -62,10 +62,17 @@ public: std::string toString(); bool setValue(gss_name_t newName); + bool setKey(std::string key) { this->hashKey = key; } + std::string getKey() const { return this->hashKey; } + + OM_uint32 getMajorStatus() const { return this->major_status; } + OM_uint32 getMinorStatus() const { return this->minor_status; } private: + OM_uint32 major_status, minor_status; gss_name_t name; gss_imp_name_type function; + std::string hashKey; void init(const GSSBuffer namestr, GSSOID name_type, gss_imp_name_type fn); void release(); diff --git a/json_gssapi/test/GSSImportNameTest.cpp b/json_gssapi/test/GSSImportNameTest.cpp index 49a3ec0..2a57987 100644 --- a/json_gssapi/test/GSSImportNameTest.cpp +++ b/json_gssapi/test/GSSImportNameTest.cpp @@ -163,11 +163,48 @@ void GSSImportNameTest::testConstructorWithJSONObject() void GSSImportNameTest::testJSONMarshal() { /* Variables */ - GSSImportName cmd = GSSImportName(); + std::string name("dns@google.com"); + std::string type("{ 1 2 840 113554 1 2 1 4 }"); + JSONObject *result; + GSSImportName cmd = GSSImportName(&mock_import_name); /* Error checking */ /* Setup */ + cmd.setInputName(name); + cmd.setInputNameType(type); + MockImportName::minor_status = 0; + MockImportName::retVal = 0; + MockImportName::output_name.setValue(GSS_C_NO_NAME); + /* Main */ + cmd.execute(); + result = cmd.toJSON(); + + 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() ) + ); + + CPPUNIT_ASSERT_EQUAL_MESSAGE( + "The minor_status value was reported incorrectly", + (int)MockImportName::minor_status, + (int)( (*result)["return_values"]["minor_status"].integer() ) + ); + + CPPUNIT_ASSERT_EQUAL_MESSAGE( + "The gss_name was reported incorrectly", + std::string("constant for now"), + std::string( (*result)["return_values"]["gss_name"].string() ) + ); + /* Cleanup */ /* Return */