diff --git a/kuksa-val-server/include/AccessChecker.hpp b/kuksa-val-server/include/AccessChecker.hpp index 6adcb1025..cf6a45733 100644 --- a/kuksa-val-server/include/AccessChecker.hpp +++ b/kuksa-val-server/include/AccessChecker.hpp @@ -15,7 +15,7 @@ #define __ACCESSCHECKER_H__ #include "IAccessChecker.hpp" -#include "kuksa.pb.h" +#include "KuksaChannel.hpp" class IAuthenticator; @@ -23,16 +23,16 @@ class IAuthenticator; class AccessChecker : public IAccessChecker { private: std::shared_ptr tokenValidator; - bool checkSignalAccess(const kuksa::kuksaChannel& channel, const std::string& path, const std::string& requiredPermission); + bool checkSignalAccess(const KuksaChannel& channel, const std::string& path, const std::string& requiredPermission); public: AccessChecker(std::shared_ptr vdator); - bool checkReadAccess(kuksa::kuksaChannel &channel, const VSSPath &path) override; + bool checkReadAccess(KuksaChannel &channel, const VSSPath &path) override; - bool checkWriteAccess(kuksa::kuksaChannel &channel, const VSSPath &path) override; + bool checkWriteAccess(KuksaChannel &channel, const VSSPath &path) override; - bool checkPathWriteAccess(kuksa::kuksaChannel &channel, const jsoncons::json &paths) override; + bool checkPathWriteAccess(KuksaChannel &channel, const jsoncons::json &paths) override; }; #endif diff --git a/kuksa-val-server/include/Authenticator.hpp b/kuksa-val-server/include/Authenticator.hpp index 9e6335ebb..d5f096d63 100644 --- a/kuksa-val-server/include/Authenticator.hpp +++ b/kuksa-val-server/include/Authenticator.hpp @@ -29,17 +29,17 @@ class Authenticator : public IAuthenticator { string algorithm = "RS256"; std::shared_ptr logger; - int validateToken(kuksa::kuksaChannel& channel, string authToken); + int validateToken(KuksaChannel& channel, string authToken); public: Authenticator(std::shared_ptr loggerUtil, string secretkey, string algorithm); - int validate(kuksa::kuksaChannel &channel, + int validate(KuksaChannel &channel, string authToken); void updatePubKey(string key); - bool isStillValid(kuksa::kuksaChannel &channel); - void resolvePermissions(kuksa::kuksaChannel &channel); + bool isStillValid(KuksaChannel &channel); + void resolvePermissions(KuksaChannel &channel); static string getPublicKeyFromFile(string fileName, std::shared_ptr logger); }; diff --git a/kuksa-val-server/include/GrpcConnection.hpp b/kuksa-val-server/include/GrpcConnection.hpp deleted file mode 100644 index 0d8848cc4..000000000 --- a/kuksa-val-server/include/GrpcConnection.hpp +++ /dev/null @@ -1,41 +0,0 @@ -#include "kuksa.grpc.pb.h" -#include -#include -#include - -#ifndef gRPCConnection_ -#define gRPCConnection_ - -class GrpcConnection { - public: - GrpcConnection(std::shared_ptr channel); - ~GrpcConnection(); - - - std::string GetMetaData(std::string vssPath); - - std::string AuthorizeChannel(std::string file); - - std::string getValue(std::string vssPath); - - std::string setValue(std::string vssPath, std::string value); - - std::string getReqID() { - return this->reqID_; - } - - void setStubtest_(kuksa::viss_client::StubInterface* stub) { this->stubtest_ = stub;} - void setCMAKE_TESTING_ENABLED(bool CMAKE_TESTING_ENABLED) { - this->CMAKE_TESTING_ENABLED_ = CMAKE_TESTING_ENABLED; - } - void setReqID(std::string reqID){ this->reqID_ = reqID;} - private: - boost::uuids::uuid uuid; - std::unique_ptr stub_; - kuksa::viss_client::StubInterface* stubtest_; - kuksa::kuksaChannel kuksa_channel; - std::string reqID_; - bool CMAKE_TESTING_ENABLED_ = false; -}; - -#endif \ No newline at end of file diff --git a/kuksa-val-server/include/WsChannel.hpp b/kuksa-val-server/include/KuksaChannel.hpp similarity index 95% rename from kuksa-val-server/include/WsChannel.hpp rename to kuksa-val-server/include/KuksaChannel.hpp index e703647bc..b3caadd00 100644 --- a/kuksa-val-server/include/WsChannel.hpp +++ b/kuksa-val-server/include/KuksaChannel.hpp @@ -11,8 +11,8 @@ * Robert Bosch GmbH - initial API and functionality * ***************************************************************************** */ -#ifndef __WSCHANNEL_H__ -#define __WSCHANNEL_H__ +#ifndef __KUKSA_CHANNEL_H__ +#define __KUKSA_CHANNEL_H__ #include #include @@ -22,7 +22,7 @@ using namespace std; using namespace jsoncons; using jsoncons::json; -class WsChannel { +class KuksaChannel { public: enum class Type { WEBSOCKET_PLAIN, diff --git a/kuksa-val-server/include/SubscriptionHandler.hpp b/kuksa-val-server/include/SubscriptionHandler.hpp index e56ecc6b8..f3eadc084 100644 --- a/kuksa-val-server/include/SubscriptionHandler.hpp +++ b/kuksa-val-server/include/SubscriptionHandler.hpp @@ -41,10 +41,6 @@ class VssDatabase; class WsServer; class ILogger; - -using SubConnId = uint64_t; -using SubscriptionId = boost::uuids::uuid; - // Subscription ID: Client ID struct UUIDHasher { @@ -57,7 +53,7 @@ struct UUIDHasher return (uuid_hasher(k)); } }; -using subscriptions_t = std::unordered_map; +using subscriptions_t = std::unordered_map; using subscription_keys_t = struct subscription_keys { std::string path; std::string attribute; @@ -84,6 +80,7 @@ struct SubscriptionKeyHasher { class SubscriptionHandler : public ISubscriptionHandler { private: std::unordered_map subscriptions; + std::unordered_map grpcSubscriptions; std::shared_ptr logger; std::shared_ptr server; @@ -107,7 +104,7 @@ class SubscriptionHandler : public ISubscriptionHandler { void addPublisher(std::shared_ptr publisher){ publishers_.push_back(publisher); } - SubscriptionId subscribe(kuksa::kuksaChannel& channel, + SubscriptionId subscribe(KuksaChannel& channel, std::shared_ptr db, const std::string &path, const std::string& attr); int unsubscribe(SubscriptionId subscribeID); diff --git a/kuksa-val-server/include/VssCommandProcessor.hpp b/kuksa-val-server/include/VssCommandProcessor.hpp index a99e7ea54..658f814d8 100644 --- a/kuksa-val-server/include/VssCommandProcessor.hpp +++ b/kuksa-val-server/include/VssCommandProcessor.hpp @@ -21,7 +21,7 @@ #include "IVssCommandProcessor.hpp" #include "VSSRequestValidator.hpp" -#include "WsChannel.hpp" +#include "KuksaChannel.hpp" #include "IAccessChecker.hpp" class IVssDatabase; @@ -39,23 +39,21 @@ class VssCommandProcessor : public IVssCommandProcessor { std::shared_ptr accessValidator_; VSSRequestValidator *requestValidator; - std::string processUpdateMetaData(kuksa::kuksaChannel& channel, jsoncons::json& request); - std::string processAuthorizeWithPermManager(kuksa::kuksaChannel &channel, const std::string & request_id, + std::string processUpdateMetaData(KuksaChannel& channel, jsoncons::json& request); + std::string processAuthorizeWithPermManager(KuksaChannel &channel, const std::string & request_id, const std::string & client, const std::string& clientSecret); std::string getPathFromRequest(const jsoncons::json &req, bool *gen1_compat); - std::string processUpdateVSSTree(kuksa::kuksaChannel& channel, jsoncons::json &request); + std::string processUpdateVSSTree(KuksaChannel& channel, jsoncons::json &request); public: std::string processGetMetaData(jsoncons::json &request); - std::string processAuthorize(kuksa::kuksaChannel& channel, const std::string & request_id, + std::string processAuthorize(KuksaChannel& channel, const std::string & request_id, const std::string & token); - std::string processGet2(kuksa::kuksaChannel &channel, jsoncons::json &request); - std::string processSet2(kuksa::kuksaChannel &channel, jsoncons::json &request); - std::string processGetTarget(kuksa::kuksaChannel &channel, jsoncons::json &request); - std::string processSetTarget(kuksa::kuksaChannel &channel, jsoncons::json &request); - std::string processSubscribe(kuksa::kuksaChannel& channel, jsoncons::json &request); - std::string processUnsubscribe(kuksa::kuksaChannel &channel, jsoncons::json &request); + std::string processGet2(KuksaChannel &channel, jsoncons::json &request); + std::string processSet2(KuksaChannel &channel, jsoncons::json &request); + std::string processSubscribe(KuksaChannel& channel, jsoncons::json &request); + std::string processUnsubscribe(KuksaChannel &channel, jsoncons::json &request); VssCommandProcessor(std::shared_ptr loggerUtil, std::shared_ptr database, @@ -64,7 +62,7 @@ class VssCommandProcessor : public IVssCommandProcessor { std::shared_ptr subhandler); ~VssCommandProcessor(); - std::string processQuery(const std::string &req_json, kuksa::kuksaChannel& channel); + std::string processQuery(const std::string &req_json, KuksaChannel& channel); }; #endif diff --git a/kuksa-val-server/include/VssDatabase.hpp b/kuksa-val-server/include/VssDatabase.hpp index 5c92856c3..6189d91a8 100644 --- a/kuksa-val-server/include/VssDatabase.hpp +++ b/kuksa-val-server/include/VssDatabase.hpp @@ -63,8 +63,8 @@ class VssDatabase : public IVssDatabase { void updateJsonTree(jsoncons::json& sourceTree, const jsoncons::json& jsonTree); - void updateJsonTree(kuksa::kuksaChannel& channel, jsoncons::json& value) override; - void updateMetaData(kuksa::kuksaChannel& channel, const VSSPath& path, const jsoncons::json& newTree) override; + void updateJsonTree(KuksaChannel& channel, jsoncons::json& value) override; + void updateMetaData(KuksaChannel& channel, const VSSPath& path, const jsoncons::json& newTree) override; jsoncons::json getMetaData(const VSSPath& path) override; jsoncons::json setSignal(const VSSPath &path, const std::string& attr, jsoncons::json &value) override; //gen2 version diff --git a/kuksa-val-server/include/WebSockHttpFlexServer.hpp b/kuksa-val-server/include/WebSockHttpFlexServer.hpp index 7c3b40098..3d6c9a97e 100644 --- a/kuksa-val-server/include/WebSockHttpFlexServer.hpp +++ b/kuksa-val-server/include/WebSockHttpFlexServer.hpp @@ -15,7 +15,7 @@ #define __WEBSOCKHTTPFLEXSERVER_H__ #include "IServer.hpp" -#include "kuksa.pb.h" +#include "KuksaChannel.hpp" #include #include @@ -63,7 +63,7 @@ class WebSockHttpFlexServer : public IServer { * @param channel Connection identifier * @return Response JSON message for client */ - std::string HandleRequest(const std::string &req_json, kuksa::kuksaChannel &channel); + std::string HandleRequest(const std::string &req_json, KuksaChannel &channel); public: WebSockHttpFlexServer(std::shared_ptr loggerUtil, std::shared_ptr rest2jsonUtil); diff --git a/kuksa-val-server/include/interface/IAccessChecker.hpp b/kuksa-val-server/include/interface/IAccessChecker.hpp index cc008d83f..c626b11e8 100644 --- a/kuksa-val-server/include/interface/IAccessChecker.hpp +++ b/kuksa-val-server/include/interface/IAccessChecker.hpp @@ -18,15 +18,15 @@ #include #include "VSSPath.hpp" -#include "kuksa.pb.h" +#include "KuksaChannel.hpp" class IAccessChecker { public: virtual ~IAccessChecker() {} - virtual bool checkPathWriteAccess(kuksa::kuksaChannel &channel, const jsoncons::json &paths) = 0; - virtual bool checkReadAccess(kuksa::kuksaChannel &channel, const VSSPath &path) = 0; - virtual bool checkWriteAccess(kuksa::kuksaChannel &channel, const VSSPath &path) = 0; + virtual bool checkPathWriteAccess(KuksaChannel &channel, const jsoncons::json &paths) = 0; + virtual bool checkReadAccess(KuksaChannel &channel, const VSSPath &path) = 0; + virtual bool checkWriteAccess(KuksaChannel &channel, const VSSPath &path) = 0; }; diff --git a/kuksa-val-server/include/interface/IAuthenticator.hpp b/kuksa-val-server/include/interface/IAuthenticator.hpp index da1795f55..39242c190 100644 --- a/kuksa-val-server/include/interface/IAuthenticator.hpp +++ b/kuksa-val-server/include/interface/IAuthenticator.hpp @@ -17,7 +17,7 @@ #include #include -#include "kuksa.pb.h" +#include "KuksaChannel.hpp" using namespace std; @@ -27,11 +27,11 @@ class IAuthenticator { public: virtual ~IAuthenticator() {} - virtual int validate(kuksa::kuksaChannel &channel, + virtual int validate(KuksaChannel &channel, string authToken) = 0; virtual void updatePubKey(string key) = 0; - virtual bool isStillValid(kuksa::kuksaChannel &channel) = 0; - virtual void resolvePermissions(kuksa::kuksaChannel &channel) = 0; + virtual bool isStillValid(KuksaChannel &channel) = 0; + virtual void resolvePermissions(KuksaChannel &channel) = 0; }; #endif diff --git a/kuksa-val-server/include/interface/ISubscriptionHandler.hpp b/kuksa-val-server/include/interface/ISubscriptionHandler.hpp index b6af3ca10..5eb575210 100644 --- a/kuksa-val-server/include/interface/ISubscriptionHandler.hpp +++ b/kuksa-val-server/include/interface/ISubscriptionHandler.hpp @@ -22,7 +22,7 @@ #include "IServer.hpp" #include "VSSPath.hpp" -#include "kuksa.pb.h" +#include "KuksaChannel.hpp" class VssDatabase; class WsServer; @@ -35,7 +35,7 @@ class ISubscriptionHandler { public: virtual ~ISubscriptionHandler() {} - virtual SubscriptionId subscribe(kuksa::kuksaChannel& channel, + virtual SubscriptionId subscribe(KuksaChannel& channel, std::shared_ptr db, const std::string &path, const std::string& attr) = 0; virtual int unsubscribe(SubscriptionId subscribeID) = 0; diff --git a/kuksa-val-server/include/interface/IVssCommandProcessor.hpp b/kuksa-val-server/include/interface/IVssCommandProcessor.hpp index 16fe4dfdd..71b33ad03 100644 --- a/kuksa-val-server/include/interface/IVssCommandProcessor.hpp +++ b/kuksa-val-server/include/interface/IVssCommandProcessor.hpp @@ -17,7 +17,7 @@ #include #include -#include "kuksa.pb.h" +#include "KuksaChannel.hpp" /** * @class IVssCommandProcessor @@ -37,7 +37,7 @@ class IVssCommandProcessor { * @return JSON formated response string */ virtual std::string processQuery(const std::string &req_json, - kuksa::kuksaChannel& channel) = 0; + KuksaChannel& channel) = 0; }; #endif diff --git a/kuksa-val-server/include/interface/IVssDatabase.hpp b/kuksa-val-server/include/interface/IVssDatabase.hpp index bd15a5a79..87cce7d06 100644 --- a/kuksa-val-server/include/interface/IVssDatabase.hpp +++ b/kuksa-val-server/include/interface/IVssDatabase.hpp @@ -19,7 +19,7 @@ #include #include -#include "kuksa.pb.h" +#include "KuksaChannel.hpp" #include "VSSPath.hpp" class IVssDatabase { @@ -27,8 +27,8 @@ class IVssDatabase { virtual ~IVssDatabase() {} virtual void initJsonTree(const boost::filesystem::path &fileName) = 0; - virtual void updateJsonTree(kuksa::kuksaChannel& channel, jsoncons::json& value) = 0; - virtual void updateMetaData(kuksa::kuksaChannel& channel, const VSSPath& path, const jsoncons::json& value) = 0; + virtual void updateJsonTree(KuksaChannel& channel, jsoncons::json& value) = 0; + virtual void updateMetaData(KuksaChannel& channel, const VSSPath& path, const jsoncons::json& value) = 0; virtual jsoncons::json getMetaData(const VSSPath &path) = 0; virtual jsoncons::json setSignal(const VSSPath &path, const std::string& attr, jsoncons::json &value) = 0; //gen2 version diff --git a/kuksa-val-server/protos/kuksa.proto b/kuksa-val-server/protos/kuksa.proto index b223358c6..52aff61c2 100644 --- a/kuksa-val-server/protos/kuksa.proto +++ b/kuksa-val-server/protos/kuksa.proto @@ -10,70 +10,78 @@ syntax = "proto3"; package kuksa; +option go_package = "/kuksa_grpc_proto"; + + // The connecting service definition. -service viss_client { - rpc GetMetaData (getMetaDataRequest) returns (metaData) {} - rpc AuthorizeChannel (authorizeRequest) returns (authStatus) {} - rpc GetValue (getRequest) returns (value) {} - rpc SetValue (setRequest) returns (setStatus) {} +service kuksa_grpc_if { + rpc get (GetRequest) returns (GetResponse) {} + rpc set (SetRequest) returns (SetResponse) {} + rpc subscribe (stream SubscribeRequest) returns (stream SubscribeResponse) {} + rpc authorize (AuthRequest) returns (AuthResponse) {} } -message metaData { - string value_ = 1; +message AuthRequest { + string token = 1; } -message authStatus { - string status_ = 1; - kuksaChannel channel_ = 2; +message GetRequest { + RequestType type = 1; + repeated string path = 2; } -message value { - string value_ = 1; +message GetResponse { + repeated Value values = 1; + Status status = 2; } -message setStatus { - string status_ = 1; +message SetRequest { + RequestType type = 1; + repeated Value values = 2; } +message SetResponse { + Status status = 1; +} -message getMetaDataRequest { - string path_ = 1; - string reqID_ = 2; +message AuthResponse { + string connectionId = 1; + Status status = 2; } -message authorizeRequest { - string token_ = 1; - string reqID_ = 2; - kuksaChannel channel_=3; +message SubscribeRequest { + RequestType type = 1; + string path = 2; + bool start = 3; } -message getRequest { - string path_ = 1; - string reqID_ = 2; - kuksaChannel channel_=3; +message SubscribeResponse { + Value values = 1; } -message setRequest { - string path_ = 1; - string reqID_ = 2; - kuksaChannel channel_=3; - string value_ = 4; +message Value { + string path = 1; + oneof val { + uint32 valueUint32 = 2; + int32 valueInt32 = 3; + uint64 valueUint64 = 4; + int64 valueInt64 = 5; + bool valueBool = 6; + float valueFloat = 7; + double valueDouble = 8; + string valueString = 9; + } + string timestamp=10; // TODO: Change to uint64 } -message kuksaChannel{ - enum Type { - UNKNOWN_TYPE = 0; - WEBSOCKET_PLAIN = 1; - WEBSOCKET_SSL = 2; - HTTP_PLAIN = 3; - HTTP_SSL = 4; - GRPC = 5; - }; - uint64 connectionID = 1; - bool authorized = 2; - bool modifyTree = 3; - bytes authToken = 4; - string permissions = 5; - Type typeOfConnection = 6; +message Status { + uint32 statusCode = 1; + string statusDescription = 2; } +enum RequestType { + UNKNOWN_TYPE = 0; + CURRENT_VALUE = 1; + TARGET_VALUE = 2; + METADATA = 3; +}; diff --git a/kuksa-val-server/src/AccessChecker.cpp b/kuksa-val-server/src/AccessChecker.cpp index 2e39192ce..42a20c50d 100644 --- a/kuksa-val-server/src/AccessChecker.cpp +++ b/kuksa-val-server/src/AccessChecker.cpp @@ -19,20 +19,19 @@ #include #include "IAuthenticator.hpp" -#include "WsChannel.hpp" +#include "KuksaChannel.hpp" using namespace std; using namespace jsoncons; -//using jsoncons::json; AccessChecker::AccessChecker(std::shared_ptr vdator) { tokenValidator = vdator; } -bool AccessChecker::checkSignalAccess(const kuksa::kuksaChannel& channel, const string& path, const string& requiredPermission){ +bool AccessChecker::checkSignalAccess(const KuksaChannel& channel, const string& path, const string& requiredPermission){ json permissions; - if(!channel.permissions().empty()){ - permissions = json::parse(channel.permissions()); + if(!channel.getPermissions().empty()){ + permissions = json::parse(channel.getPermissions().as_string()); } else{ permissions = json::parse("{}"); @@ -54,20 +53,20 @@ bool AccessChecker::checkSignalAccess(const kuksa::kuksaChannel& channel, const } -// check the permissions json in WsChannel if path has read access -bool AccessChecker::checkReadAccess(kuksa::kuksaChannel &channel, const VSSPath &path) { +// check the permissions json in KuksaChannel if path has read access +bool AccessChecker::checkReadAccess(KuksaChannel &channel, const VSSPath &path) { return checkSignalAccess(channel, path.getVSSGen1Path(), "r"); } -// check the permissions json in WsChannel if path has read access -bool AccessChecker::checkWriteAccess(kuksa::kuksaChannel &channel, const VSSPath &path) { +// check the permissions json in KuksaChannel if path has read access +bool AccessChecker::checkWriteAccess(KuksaChannel &channel, const VSSPath &path) { return checkSignalAccess(channel, path.getVSSGen1Path(), "w"); } // Checks if all the paths have write access.If even 1 path in the list does not // have write access, this method returns false. -bool AccessChecker::checkPathWriteAccess(kuksa::kuksaChannel &channel, const json &paths) { +bool AccessChecker::checkPathWriteAccess(KuksaChannel &channel, const json &paths) { for (size_t i = 0; i < paths.size(); i++) { json item = paths[i]; string jPath = item["path"].as(); diff --git a/kuksa-val-server/src/Authenticator.cpp b/kuksa-val-server/src/Authenticator.cpp index 9bd6c02be..c8261a774 100644 --- a/kuksa-val-server/src/Authenticator.cpp +++ b/kuksa-val-server/src/Authenticator.cpp @@ -22,7 +22,7 @@ #include #include #include "VssDatabase.hpp" -#include "WsChannel.hpp" +#include "KuksaChannel.hpp" using namespace std; @@ -57,7 +57,7 @@ void Authenticator::updatePubKey(string key) { } // utility method to validate token. -int Authenticator::validateToken(kuksa::kuksaChannel& channel, string authToken) { +int Authenticator::validateToken(KuksaChannel& channel, string authToken) { json claims; int ttl = -1; @@ -80,8 +80,8 @@ int Authenticator::validateToken(kuksa::kuksaChannel& channel, string authToken) return -1; } - channel.set_authorized(true); - channel.set_authtoken(authToken); + channel.setAuthorized(true); + channel.setAuthToken(authToken); ttl = claims["exp"].as(); } catch (std::exception &e) { @@ -99,7 +99,7 @@ Authenticator::Authenticator(std::shared_ptr loggerUtil, string secretk // validates the token against expiry date/time. should be extended to check // some other claims. -int Authenticator::validate(kuksa::kuksaChannel& channel, +int Authenticator::validate(KuksaChannel& channel, string authToken) { int ttl = validateToken(channel, authToken); if (ttl > 0) { @@ -112,12 +112,12 @@ int Authenticator::validate(kuksa::kuksaChannel& channel, // Checks if the token is still valid for the requests from the channel(client). // Internally check this before publishing messages for previously subscribed // signals. -bool Authenticator::isStillValid(kuksa::kuksaChannel& channel) { - string token = channel.authtoken(); +bool Authenticator::isStillValid(KuksaChannel& channel) { + string token = channel.getAuthToken(); int ret = validateToken(channel, token); if (ret == -1) { - channel.set_authorized(false); + channel.setAuthorized(false); return false; } else { return true; @@ -127,8 +127,8 @@ bool Authenticator::isStillValid(kuksa::kuksaChannel& channel) { // **Do this only once for authenticate request** // resolves the permission in the JWT token and store the absolute path to the // signals in permissions JSON in WsChannel. -void Authenticator::resolvePermissions(kuksa::kuksaChannel& channel) { - string authToken = channel.authtoken(); +void Authenticator::resolvePermissions(KuksaChannel& channel) { + string authToken = channel.getAuthToken(); auto decoded = jwt::decode(authToken); json claims; for (auto& e : decoded.get_payload_claims()) { @@ -140,7 +140,7 @@ void Authenticator::resolvePermissions(kuksa::kuksaChannel& channel) { json permissions; if (claims.contains("modifyTree") && claims["modifyTree"].as()) { - channel.set_modifytree(true); + channel.enableModifyTree(); } if (claims.contains("kuksa-vss")) { @@ -159,5 +159,5 @@ void Authenticator::resolvePermissions(kuksa::kuksaChannel& channel) { } std::string channelPermissions; permissions.dump_pretty(channelPermissions); - channel.set_permissions(channelPermissions); + channel.setPermissions(channelPermissions); } diff --git a/kuksa-val-server/src/CMakeLists.txt b/kuksa-val-server/src/CMakeLists.txt index c78655f33..9d0130c0a 100644 --- a/kuksa-val-server/src/CMakeLists.txt +++ b/kuksa-val-server/src/CMakeLists.txt @@ -186,26 +186,6 @@ if(BUILD_EXE) install( FILES ${CMAKE_CURRENT_SOURCE_DIR}/../../data/vss-core/vss_release_2.2.json DESTINATION bin/${SERVER_EXE_NAME}) - #GRPC client - - add_executable(${GRPC_CLIENT_EXE_NAME} "${GRPC_CLIENT_EXE_NAME}.cpp") - - if (ENABLE_COVERAGE) - add_coverage(${GRPC_CLIENT_EXE_NAME}) - endif() - - # using static library to simplify existing packaging and maintainance - target_link_libraries(${GRPC_CLIENT_EXE_NAME} PRIVATE ${SERVER_LIB_STATIC_NAME}) - - # link executable dependencies - target_link_libraries(${GRPC_CLIENT_EXE_NAME} PRIVATE Threads::Threads) - target_link_libraries(${GRPC_CLIENT_EXE_NAME} PRIVATE ${Boost_LIBRARIES}) - target_link_libraries(${GRPC_CLIENT_EXE_NAME} PRIVATE ${OPENSSL_LIBRARIES}) - target_include_directories(${GRPC_CLIENT_EXE_NAME} PRIVATE ${MOSQUITTO_INCLUDE_DIR}) - target_link_libraries(${GRPC_CLIENT_EXE_NAME} PRIVATE ${MOSQUITTO_LIBRARY}) - target_link_options(${GRPC_CLIENT_EXE_NAME} PRIVATE "-ldl") - message(STATUS "Build target files for grpc client") - # CPack INCLUDE(InstallRequiredSystemLibraries) diff --git a/kuksa-val-server/src/GrpcConnection.cpp b/kuksa-val-server/src/GrpcConnection.cpp deleted file mode 100644 index 8d44d6a4f..000000000 --- a/kuksa-val-server/src/GrpcConnection.cpp +++ /dev/null @@ -1,155 +0,0 @@ -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include - -#include "grpcHandler.hpp" -#include "GrpcConnection.hpp" - -class grpcConnectionHandler { - private: - std::mutex mconnGrpc; - std::unordered_map> connGrpc; - public: - kuksa::kuksaChannel& addClient(boost::uuids::uuid uuid){ - auto newChannel = std::make_shared(); - std::lock_guard lock(mconnGrpc); - uint64_t value = reinterpret_cast(uuid.data); - newChannel->set_connectionid(value); - newChannel->set_typeofconnection(kuksa::kuksaChannel_Type_GRPC); - connGrpc[reinterpret_cast(uuid.data)] = newChannel; - return *newChannel; - } - void RemoveClient(const boost::uuids::uuid uuid){ - std::lock_guard lock(mconnGrpc); - connGrpc.erase(reinterpret_cast(uuid.data)); - } - std::unordered_map> getConnGrpc() { - return this->connGrpc; - } - grpcConnectionHandler() = default; - ~grpcConnectionHandler() = default; -}; - -grpcConnectionHandler connGrpcHandler; - -// handles gRPC Connections -// provides setValue, getValue, getMetaData, authorizeChannel as services -// kuksa_channel is for authorizing against the db -GrpcConnection::GrpcConnection(std::shared_ptr channel){ - stub_ = kuksa::viss_client::NewStub(channel); - uuid = boost::uuids::random_generator()(); - std::stringstream ss; - ss << uuid; - reqID_ = ss.str(); - kuksa_channel = connGrpcHandler.addClient(uuid); -} - -GrpcConnection::~GrpcConnection(){ - kuksa_channel.~kuksaChannel(); - connGrpcHandler.RemoveClient(uuid); -} - -std::string GrpcConnection::GetMetaData(std::string vssPath){ - kuksa::getMetaDataRequest request; - kuksa::metaData reply; - grpc::ClientContext context; - request.set_path_(vssPath); - request.set_reqid_(reqID_); - // for checking if a Unit Test calls this function. Then the server gets mocked by gmock - // for detailed documentation see https://grpc.github.io/grpc/cpp/md_doc_unit_testing.html - grpc::Status status; - if(CMAKE_TESTING_ENABLED_){ - status = stubtest_->GetMetaData(&context, request, &reply); - } - else{ - status = stub_->GetMetaData(&context, request, &reply); - } - if (status.ok()) { - return reply.value_(); - } else { - std::cout << status.error_code() << ": " << status.error_message() - << std::endl; - return "RPC failed"; - } -} - -std::string GrpcConnection::AuthorizeChannel(std::string file){ - kuksa::authorizeRequest request; - kuksa::authStatus reply; - grpc::ClientContext context; - std::string token; - grpcHandler::read(file,token); - request.set_token_(token); - request.set_reqid_(reqID_); - request.mutable_channel_()->MergeFrom(kuksa_channel); - grpc::Status status; - if(CMAKE_TESTING_ENABLED_){ - status = stubtest_->AuthorizeChannel(&context, request, &reply); - } - else{ - status = stub_->AuthorizeChannel(&context, request, &reply); - } - if (status.ok()) { - kuksa_channel = reply.channel_(); - return reply.status_(); - } else { - std::cout << status.error_code() << ": " << status.error_message() - << std::endl; - return "RPC failed"; - } -} - -std::string GrpcConnection::getValue(std::string vssPath){ - kuksa::getRequest request; - kuksa::value reply; - grpc::ClientContext context; - request.set_path_(vssPath); - request.set_reqid_(reqID_); - request.mutable_channel_()->MergeFrom(kuksa_channel); - grpc::Status status; - if(CMAKE_TESTING_ENABLED_){ - status = stubtest_->GetValue(&context, request, &reply); - } - else{ - status = stub_->GetValue(&context, request, &reply); - } - if (status.ok()) { - return reply.value_(); - } else { - std::cout << status.error_code() << ": " << status.error_message() - << std::endl; - return "RPC failed"; - } -} - -std::string GrpcConnection::setValue(std::string vssPath, std::string value){ - kuksa::setRequest request; - kuksa::setStatus reply; - grpc::ClientContext context; - request.set_path_(vssPath); - request.set_value_(value); - request.set_reqid_(reqID_); - request.mutable_channel_()->MergeFrom(kuksa_channel); - grpc::Status status; - if(CMAKE_TESTING_ENABLED_){ - status = stubtest_->SetValue(&context, request, &reply); - } - else{ - status = stub_->SetValue(&context, request, &reply); - } - if (status.ok()) { - return reply.status_(); - } else { - std::cout << status.error_code() << ": " << status.error_message() - << std::endl; - return "RPC failed"; - } -} \ No newline at end of file diff --git a/kuksa-val-server/src/OverlayLoader.cpp b/kuksa-val-server/src/OverlayLoader.cpp index 8e4ef8b2e..950d419a6 100644 --- a/kuksa-val-server/src/OverlayLoader.cpp +++ b/kuksa-val-server/src/OverlayLoader.cpp @@ -50,8 +50,8 @@ void applyOverlays(std::shared_ptr log, const std::vector overlayfiles, std::shared_ptr db) { // Mock a channel with permissions to change VSS tree - auto mockChannel = std::make_shared(); - mockChannel->set_modifytree(true); + auto mockChannel = std::make_shared(); + mockChannel->enableModifyTree(); for (auto const &p : overlayfiles) { log->Log(LogLevel::INFO, "Loading overlay \"" + p.generic_string() + "\""); diff --git a/kuksa-val-server/src/SubscriptionHandler.cpp b/kuksa-val-server/src/SubscriptionHandler.cpp index f5512f706..8982178df 100644 --- a/kuksa-val-server/src/SubscriptionHandler.cpp +++ b/kuksa-val-server/src/SubscriptionHandler.cpp @@ -26,7 +26,7 @@ #include "ILogger.hpp" #include "JsonResponses.hpp" #include "VssDatabase.hpp" -#include "WsChannel.hpp" +#include "KuksaChannel.hpp" #include "exception.hpp" #include "visconf.hpp" @@ -48,7 +48,7 @@ SubscriptionHandler::SubscriptionHandler( SubscriptionHandler::~SubscriptionHandler() { stopThread(); } -SubscriptionId SubscriptionHandler::subscribe(kuksa::kuksaChannel& channel, +SubscriptionId SubscriptionHandler::subscribe(KuksaChannel& channel, std::shared_ptr db, const string& path, const std::string& attr) { // generate subscribe ID "randomly". @@ -77,7 +77,7 @@ SubscriptionId SubscriptionHandler::subscribe(kuksa::kuksaChannel& channel, vssPath.getVSSPath()); std::unique_lock lock(accessMutex); - subscriptions[subsKey][subId] = channel.connectionid(); + subscriptions[subsKey][subId] = channel.getConnID(); return subId; } diff --git a/kuksa-val-server/src/VssCommandGet.cpp b/kuksa-val-server/src/VssCommandGet.cpp index bfb6fc33c..a89313ff8 100644 --- a/kuksa-val-server/src/VssCommandGet.cpp +++ b/kuksa-val-server/src/VssCommandGet.cpp @@ -26,7 +26,7 @@ /** Implements the Websocket get request accroding to GEN2, with GEN1 backwards * compatibility **/ -std::string VssCommandProcessor::processGet2(kuksa::kuksaChannel &channel, +std::string VssCommandProcessor::processGet2(KuksaChannel &channel, jsoncons::json &request) { std::string pathStr= request["path"].as_string(); VSSPath path = VSSPath::fromVSS(pathStr); @@ -59,7 +59,7 @@ std::string VssCommandProcessor::processGet2(kuksa::kuksaChannel &channel, } logger->Log(LogLevel::VERBOSE, "Get request with id " + requestId + - " for path: " + path.to_string() + ", attribute: " + attribute); + " for path: " + path.to_string() + " with attribute: " + attribute); jsoncons::json answer; jsoncons::json datapoints = jsoncons::json::array(); diff --git a/kuksa-val-server/src/VssCommandProcessor.cpp b/kuksa-val-server/src/VssCommandProcessor.cpp index ac1049c2e..bcdb7706c 100644 --- a/kuksa-val-server/src/VssCommandProcessor.cpp +++ b/kuksa-val-server/src/VssCommandProcessor.cpp @@ -20,7 +20,7 @@ #include #include "exception.hpp" -#include "WsChannel.hpp" +#include "KuksaChannel.hpp" #include "JsonResponses.hpp" #include "visconf.hpp" @@ -56,7 +56,7 @@ VssCommandProcessor::~VssCommandProcessor() { } -string VssCommandProcessor::processUpdateVSSTree(kuksa::kuksaChannel& channel, jsoncons::json &request){ +string VssCommandProcessor::processUpdateVSSTree(KuksaChannel& channel, jsoncons::json &request){ logger->Log(LogLevel::VERBOSE, "VssCommandProcessor::processUpdateVSSTree"); try { @@ -144,7 +144,7 @@ string VssCommandProcessor::processGetMetaData(jsoncons::json &request) { return ss.str(); } -string VssCommandProcessor::processUpdateMetaData(kuksa::kuksaChannel& channel, jsoncons::json& request){ +string VssCommandProcessor::processUpdateMetaData(KuksaChannel& channel, jsoncons::json& request){ logger->Log(LogLevel::VERBOSE, "VssCommandProcessor::processUpdateMetaData"); VSSPath path=VSSPath::fromVSS(request["path"].as_string()); @@ -196,7 +196,7 @@ string VssCommandProcessor::processUpdateMetaData(kuksa::kuksaChannel& channel, } -string VssCommandProcessor::processAuthorize(kuksa::kuksaChannel &channel, +string VssCommandProcessor::processAuthorize(KuksaChannel &channel, const string & request_id, const string & token) { int ttl = tokenValidator->validate(channel, token); @@ -231,7 +231,7 @@ string VssCommandProcessor::processAuthorize(kuksa::kuksaChannel &channel, } string VssCommandProcessor::processQuery(const string &req_json, - kuksa::kuksaChannel &channel) { + KuksaChannel &channel) { jsoncons::json root; string response; try { diff --git a/kuksa-val-server/src/VssCommandSet.cpp b/kuksa-val-server/src/VssCommandSet.cpp index 114298da5..3168c6c8e 100644 --- a/kuksa-val-server/src/VssCommandSet.cpp +++ b/kuksa-val-server/src/VssCommandSet.cpp @@ -29,7 +29,7 @@ /** Implements the Websocket set request according to GEN2, with GEN1 backwards * compatibility **/ -std::string VssCommandProcessor::processSet2(kuksa::kuksaChannel &channel, +std::string VssCommandProcessor::processSet2(KuksaChannel &channel, jsoncons::json &request) { try { requestValidator->validateSet(request); diff --git a/kuksa-val-server/src/VssCommandSubscribe.cpp b/kuksa-val-server/src/VssCommandSubscribe.cpp index 7d71d3e2a..73f30ea57 100644 --- a/kuksa-val-server/src/VssCommandSubscribe.cpp +++ b/kuksa-val-server/src/VssCommandSubscribe.cpp @@ -21,7 +21,7 @@ #include "VssCommandProcessor.hpp" #include "exception.hpp" -string VssCommandProcessor::processSubscribe(kuksa::kuksaChannel &channel, +string VssCommandProcessor::processSubscribe(KuksaChannel &channel, jsoncons::json &request) { try { requestValidator->validateSubscribe(request); diff --git a/kuksa-val-server/src/VssCommandUnsubscribe.cpp b/kuksa-val-server/src/VssCommandUnsubscribe.cpp index a638a6868..c4815c8ff 100644 --- a/kuksa-val-server/src/VssCommandUnsubscribe.cpp +++ b/kuksa-val-server/src/VssCommandUnsubscribe.cpp @@ -23,7 +23,7 @@ #include "VssCommandProcessor.hpp" #include "exception.hpp" -string VssCommandProcessor::processUnsubscribe(kuksa::kuksaChannel &channel, +string VssCommandProcessor::processUnsubscribe(KuksaChannel &channel, jsoncons::json &request) { try { requestValidator->validateUnsubscribe(request); diff --git a/kuksa-val-server/src/VssDatabase.cpp b/kuksa-val-server/src/VssDatabase.cpp index 063656e08..b438e3f14 100644 --- a/kuksa-val-server/src/VssDatabase.cpp +++ b/kuksa-val-server/src/VssDatabase.cpp @@ -26,7 +26,7 @@ #include "IAccessChecker.hpp" #include "ISubscriptionHandler.hpp" #include "VssDatabase.hpp" -#include "WsChannel.hpp" +#include "KuksaChannel.hpp" #include "JsonResponses.hpp" using namespace std; @@ -284,8 +284,8 @@ void VssDatabase::updateJsonTree(jsoncons::json& sourceTree, const jsoncons::jso } -void VssDatabase::updateJsonTree(kuksa::kuksaChannel& channel, jsoncons::json& jsonTree){ - if (! channel.modifytree()) { +void VssDatabase::updateJsonTree(KuksaChannel& channel, jsoncons::json& jsonTree){ + if (! channel.authorizedToModifyTree()) { stringstream msg; msg << "do not have write access for updating json tree or is invalid"; throw noPermissionException(msg.str()); @@ -299,8 +299,8 @@ void VssDatabase::updateJsonTree(kuksa::kuksaChannel& channel, jsoncons::json& // update a metadata in tree, which will only do one-level-deep shallow merge/update. // If deep merge/update are expected, use `updateJsonTree` instead. -void VssDatabase::updateMetaData(kuksa::kuksaChannel& channel, const VSSPath& path, const jsoncons::json& metadata){ - if (! channel.modifytree()) { +void VssDatabase::updateMetaData(KuksaChannel& channel, const VSSPath& path, const jsoncons::json& metadata){ + if (! channel.authorizedToModifyTree()) { stringstream msg; msg << "do not have write access for updating MetaData or is invalid"; throw noPermissionException(msg.str()); diff --git a/kuksa-val-server/src/WebSockHttpFlexServer.cpp b/kuksa-val-server/src/WebSockHttpFlexServer.cpp index ae8269f80..8974ebc49 100644 --- a/kuksa-val-server/src/WebSockHttpFlexServer.cpp +++ b/kuksa-val-server/src/WebSockHttpFlexServer.cpp @@ -44,10 +44,10 @@ #include "IRestHandler.hpp" #include "IVssCommandProcessor.hpp" -#include "WsChannel.hpp" +#include "KuksaChannel.hpp" #include "ILogger.hpp" -using RequestHandler = std::function; +using RequestHandler = std::function; using Listeners = std::vector>>; using tcp = boost::asio::ip::tcp; // from namespace ssl = boost::asio::ssl; // from @@ -63,7 +63,7 @@ namespace websocket = boost::beast::websocket; // from > connPlainWebSock_; + std::shared_ptr> connPlainWebSock_; std::unordered_map> connSslWebSock_; + std::shared_ptr> connSslWebSock_; std::unordered_map> connPlainHttp_; + std::shared_ptr> connPlainHttp_; std::unordered_map> connSslHttp_; + std::shared_ptr> connSslHttp_; public: ConnectionHandler() = default; @@ -91,14 +91,14 @@ namespace websocket = boost::beast::websocket; // from (); + KuksaChannel& AddClient(const PlainWebsocketSession * session) { + auto newChannel = std::make_shared(); std::lock_guard lock(mPlainWebSock_); - newChannel->set_connectionid(reinterpret_cast(session)); - newChannel->set_typeofconnection(kuksa::kuksaChannel_Type_WEBSOCKET_PLAIN); + newChannel->setConnID(reinterpret_cast(session)); + newChannel->setType(KuksaChannel::Type::WEBSOCKET_PLAIN); connPlainWebSock_[session] = newChannel; return *newChannel; } @@ -106,14 +106,14 @@ namespace websocket = boost::beast::websocket; // from (); + KuksaChannel& AddClient(const SslWebsocketSession * session) { + auto newChannel = std::make_shared(); std::lock_guard lock(mSslWebSock_); - newChannel->set_connectionid(reinterpret_cast(session)); - newChannel->set_typeofconnection(kuksa::kuksaChannel_Type_WEBSOCKET_SSL); + newChannel->setConnID(reinterpret_cast(session)); + newChannel->setType(KuksaChannel::Type::WEBSOCKET_SSL); connSslWebSock_[session] = newChannel; return *newChannel; @@ -122,14 +122,14 @@ namespace websocket = boost::beast::websocket; // from (); + KuksaChannel& AddClient(const PlainHttpSession * session) { + auto newChannel = std::make_shared(); std::lock_guard lock(mPlainHttp_); - newChannel->set_connectionid(reinterpret_cast(session)); - newChannel->set_typeofconnection(kuksa::kuksaChannel_Type_HTTP_PLAIN); + newChannel->setConnID(reinterpret_cast(session)); + newChannel->setType(KuksaChannel::Type::HTTP_PLAIN); connPlainHttp_[session] = newChannel; return *newChannel; @@ -138,14 +138,14 @@ namespace websocket = boost::beast::websocket; // from (); + KuksaChannel& AddClient(const SslHttpSession * session) { + auto newChannel = std::make_shared(); std::lock_guard lock(mSslHttp_); - newChannel->set_connectionid(reinterpret_cast(session)); - newChannel->set_typeofconnection(kuksa::kuksaChannel_Type_HTTP_SSL); + newChannel->setConnID(reinterpret_cast(session)); + newChannel->setType(KuksaChannel::Type::HTTP_SSL); connSslHttp_[session] = newChannel; return *newChannel; @@ -253,7 +253,7 @@ namespace websocket = boost::beast::websocket; // from strand_; boost::asio::steady_timer timer_; RequestHandler requestHandler_; - kuksa::kuksaChannel channel; + KuksaChannel channel; std::list writeQueue_; public: // Construct the session @@ -762,7 +762,7 @@ namespace websocket = boost::beast::websocket; // from strand_; boost::beast::flat_buffer bufferRead_; RequestHandler requestHandler_; - kuksa::kuksaChannel channel; + KuksaChannel channel; public: // Construct the session @@ -1350,13 +1350,13 @@ void WebSockHttpFlexServer::Initialize(std::string host, std::placeholders::_2)); } -std::string WebSockHttpFlexServer::HandleRequest(const std::string &req_json, kuksa::kuksaChannel &channel) { +std::string WebSockHttpFlexServer::HandleRequest(const std::string &req_json, KuksaChannel &channel) { std::string response; - auto const type = channel.typeofconnection(); + auto const type = channel.getType(); ObserverType handlerType; - if ((type == kuksa::kuksaChannel_Type_WEBSOCKET_PLAIN) || - (type == kuksa::kuksaChannel_Type_WEBSOCKET_SSL )) + if ((type == KuksaChannel::Type::WEBSOCKET_PLAIN) || + (type == KuksaChannel::Type::WEBSOCKET_SSL)) { handlerType = ObserverType::WEBSOCKET; } diff --git a/kuksa-val-server/src/grpcHandler.cpp b/kuksa-val-server/src/grpcHandler.cpp index aaa62abb3..73db84c6f 100644 --- a/kuksa-val-server/src/grpcHandler.cpp +++ b/kuksa-val-server/src/grpcHandler.cpp @@ -14,11 +14,14 @@ #include #include #include +#include +#include #include "grpcHandler.hpp" -#include "WsChannel.hpp" +#include "KuksaChannel.hpp" #include "kuksa.grpc.pb.h" +#include "ILogger.hpp" using namespace std; using grpc::Channel; @@ -27,7 +30,7 @@ using grpc::Server; using grpc::ServerBuilder; using grpc::ServerContext; using grpc::Status; -using kuksa::viss_client; +using kuksa::kuksa_grpc_if; grpcHandler handler; @@ -41,7 +44,7 @@ void grpcHandler::read (const std::string& filename, std::string& data) std::stringstream ss; ss << file.rdbuf(); - file.close(); + file.close(); data = ss.str(); } @@ -51,58 +54,289 @@ void grpcHandler::read (const std::string& filename, std::string& data) return; } +// Map RequestType -> std::string +const static std::map AttributeStringMap = +{ + {kuksa::RequestType::CURRENT_VALUE, "value"}, + {kuksa::RequestType::TARGET_VALUE, "targetValue"}, +}; + +using grpcSession_t = struct grpcSession{ + std::string peer; + boost::uuids::uuid sessionId; + + // constructor + grpcSession(std::string p, boost::uuids::uuid id) { + this->peer = p; + this->sessionId = id; + } + + // Equal operator + bool operator==(const grpcSession &p) const { + return this->peer == p.peer && this->sessionId == p.sessionId; + } +}; + +struct GrpcSessionHasher +{ + std::size_t operator()(const grpcSession_t& k) const + { + boost::hash uuid_hasher; + return (uuid_hasher(k.sessionId) ^ std::hash()(k.peer)); + } +}; + // Logic and data behind the servers behaviour // implementation of the rpc interfaces server side -class RequestServiceImpl final : public viss_client::Service { - Status GetMetaData(ServerContext* context, const kuksa::getMetaDataRequest* request, - kuksa::metaData* reply) override { - jsoncons::json req_json; - req_json["action"] = "getMetaData"; - req_json["path"] = request->path_(); - req_json["requestId"] = request->reqid_(); - auto Processor = handler.getGrpcProcessor(); - auto result = Processor->processGetMetaData(req_json); - reply->set_value_(result); - return Status::OK;} - - Status AuthorizeChannel(ServerContext* context, const kuksa::authorizeRequest* request, - kuksa::authStatus* reply) override { - auto Processor = handler.getGrpcProcessor(); - auto channel = request->channel_(); - auto result = Processor->processAuthorize(channel,request->reqid_(),request->token_()); - reply->mutable_channel_()->MergeFrom(channel); - reply->set_status_(result); - return Status::OK;} - - Status SetValue(ServerContext* context, const kuksa::setRequest* request, - kuksa::setStatus* reply) override { - auto Processor = handler.getGrpcProcessor(); - jsoncons::json req_json; - req_json["action"] = "set"; - req_json["path"] = request->path_(); - req_json["value"] = request->value_(); - req_json["requestId"] = request->reqid_(); - auto channel = request->channel_(); - auto result = Processor->processSet2(channel,req_json); - reply->set_status_(result); - return Status::OK;} - - Status GetValue(ServerContext* context, const kuksa::getRequest* request, - kuksa::value* reply) override { - auto Processor = handler.getGrpcProcessor(); - jsoncons::json req_json; - req_json["action"] = "get"; - req_json["path"] = request->path_(); - req_json["requestId"] = request->reqid_(); - auto channel = request->channel_(); - auto result = Processor->processGet2(channel,req_json); - reply->set_value_(result); - return Status::OK;} +class RequestServiceImpl final : public kuksa_grpc_if::Service { + + private: + std::shared_ptr logger; + std::unordered_map grpcSessionMap; + + /* Internal helper function to authorize the session + * Will create and assign a KuksaChannel object to the session. + * Subsequent calls must retrieve this object to execute a RPC. + */ + jsoncons::json authorizeHelper (const std::string peer, const std::string token) { + // Create an auth request + jsoncons::json req_json; + auto uuid = boost::uuids::random_generator()(); + + req_json["action"] = "authorize"; + req_json["requestId"] = boost::uuids::to_string(uuid); + req_json["token"] = token; + + auto newChannel = std::make_shared(); + newChannel->setConnID(0); // Connection ID is used only for websocket connections. + newChannel->setType(KuksaChannel::Type::GRPC); + + auto Processor = handler.getGrpcProcessor(); + auto response = Processor->processAuthorize(*newChannel, boost::uuids::to_string(uuid), token); + logger->Log(LogLevel::INFO, response); + auto resJson = json::parse(response); + + if (!resJson.contains("error")) { // Success case + grpcSession_t session = grpcSession(peer, uuid); + grpcSessionMap[session] = *newChannel; + } + return resJson; + } + + /* Internal helper function to retrieve KuksaChannel object to the session. + * Needs the UUID assigned to the session in the context metadata. + */ + KuksaChannel* authChecker (ServerContext* context) { + KuksaChannel* kc = NULL; + try { + auto metadata = context->client_metadata(); + + boost::uuids::string_generator gen; + auto iter = metadata.find("connectionid"); + if (iter != metadata.end()) { + auto connId = gen(std::string(iter->second.data())); + logger->Log(LogLevel::ERROR, std::string(iter->second.data())); + grpcSession session = grpcSession(context->peer(), connId); + kc = &grpcSessionMap[session]; + } + } catch (std::exception &e) { + // Do Nothing + // Most probably KuksaChannel does not exist for this session. + // This will result in authorization error later. + } + return kc; + } + + /* Internal function to handle subscribe read streams + * + */ + static void subscribeReadStreamHandling(::grpc::ServerReaderWriter<::kuksa::SubscribeResponse, ::kuksa::SubscribeRequest>* stream) { + + } + + /* Internal function to handle subscribe write streams + * + */ + static void subscribeWriteStreamHandling(::grpc::ServerReaderWriter<::kuksa::SubscribeResponse, ::kuksa::SubscribeRequest>* stream) { + + } + public: + + RequestServiceImpl(std::shared_ptr _logger) { + logger = _logger; + } + + Status get(ServerContext* context, const kuksa::GetRequest* request, kuksa::GetResponse* reply) override { + jsoncons::json req_json; + stringstream msg; + msg << "gRPC get invoked with type " << kuksa::RequestType_Name(request->type()) << " by " << context->peer() << std::endl; + logger->Log(LogLevel::INFO,msg.str()); + + // Check if authorized and get the corresponding KuksaChannel + KuksaChannel* kc = authChecker(context); + if (kc == NULL) { + reply->mutable_status()->set_statuscode(404); + reply->mutable_status()->set_statusdescription("No Authorization!!"); + return Status::OK; + } + + // Return if no paths are given + if (request->path().size() == 0) { + reply->mutable_status()->set_statuscode(400); + reply->mutable_status()->set_statusdescription("No valid path found!!"); + return Status::OK; + } + + if (request->type() == kuksa::RequestType::METADATA) { + // TODO + } else { + req_json["action"] = "get"; + req_json["attribute"] = AttributeStringMap.find(request->type())->second; + bool singleFailure = false; + + for (int i=0; i < request->path().size(); i++) { + req_json["requestId"] = boost::uuids::to_string(boost::uuids::random_generator()()); + req_json["path"] = request->path()[i]; + logger->Log(LogLevel::INFO,req_json.to_string()); + + try { + auto Processor = handler.getGrpcProcessor(); + auto result = Processor->processGet2(*kc, req_json); + logger->Log(LogLevel::INFO,result); + auto resJson = json::parse(result); + if (resJson.contains("error")) { // Failure Case + uint32_t code = resJson["error"]["number"].as_uint(); + std::string reason = resJson["error"]["reason"].as_string() + " " + resJson["error"]["message"].as_string(); + reply->mutable_status()->set_statuscode(code); + reply->mutable_status()->set_statusdescription(reason); + singleFailure = true; + } else { // Success Case + auto val = reply->add_values(); + val->set_valuestring(resJson["data"]["dp"]["value"].as_string()); + val->set_path(resJson["data"]["path"].as_string()); + val->set_timestamp(resJson["data"]["dp"]["ts"].as_string()); + } + } catch (std::exception &e) { + singleFailure = true; + } + } + + if (singleFailure && request->path().size() > 1) { + reply->mutable_status()->set_statuscode(400); + reply->mutable_status()->set_statusdescription("One or more paths could not be resolved. Try individual requests."); + } else if (!singleFailure) { + reply->mutable_status()->set_statuscode(200); + reply->mutable_status()->set_statusdescription("Get request successfully processed"); + } + } + return Status::OK; + } + + Status set(ServerContext* context, const kuksa::SetRequest* request, kuksa::SetResponse* reply) override { + jsoncons::json req_json; + stringstream msg; + msg << "gRPC set invoked with type " << kuksa::RequestType_Name(request->type()) << " by " << context->peer() << std::endl; + logger->Log(LogLevel::INFO,msg.str()); + + // Check if authorized and get the corresponding KuksaChannel + KuksaChannel* kc = authChecker(context); + if (kc == NULL) { + reply->mutable_status()->set_statuscode(404); + reply->mutable_status()->set_statusdescription("No Authorization!!"); + return Status::OK; + } + + if (request->type() == kuksa::RequestType::METADATA) { + // Do Nothing!! + // Setting Metadata is not supported + } else { + req_json["action"] = "set"; + req_json["attribute"] = AttributeStringMap.find(request->type())->second; + bool singleFailure = false; + + for (int i=0; i < request->values().size(); i++) { + auto val = request->values()[i]; + req_json["requestId"] = boost::uuids::to_string(boost::uuids::random_generator()()); + req_json["path"] = val.path(); + req_json["value"] = val.valuestring(); + + logger->Log(LogLevel::INFO,req_json.to_string()); + + try { + auto Processor = handler.getGrpcProcessor(); + auto result = Processor->processSet2(*kc, req_json); + logger->Log(LogLevel::INFO,result); + auto resJson = json::parse(result); + if (resJson.contains("error")) { // Failure Case + uint32_t code = resJson["error"]["number"].as_uint(); + std::string reason = resJson["error"]["reason"].as_string() + " " + resJson["error"]["message"].as_string(); + reply->mutable_status()->set_statuscode(code); + reply->mutable_status()->set_statusdescription(reason); + singleFailure = true; + } else { // Success Case + reply->mutable_status()->set_statuscode(200); + reply->mutable_status()->set_statusdescription("Set request successfully processed"); + } + } catch (std::exception &e) { + singleFailure = true; + } + } + + if (singleFailure && request->values().size() > 1) { + reply->mutable_status()->set_statuscode(400); + reply->mutable_status()->set_statusdescription("One or more paths could not be resolved. Try individual requests."); + } else if (!singleFailure) { + reply->mutable_status()->set_statuscode(200); + reply->mutable_status()->set_statusdescription("Set request successfully processed"); + } + } + return Status::OK; + } + + Status subscribe(ServerContext* context, ::grpc::ServerReaderWriter<::kuksa::SubscribeResponse, ::kuksa::SubscribeRequest>* stream) { + stringstream msg; + msg << "gRPC subscribe invoked" << " by " << context->peer() << std::endl; + logger->Log(LogLevel::INFO,msg.str()); + + // Check if authorized and get the corresponding KuksaChannel + KuksaChannel* kc = authChecker(context); + if (kc == NULL) { + return Status::OK; + } + + thread readStreamThread (subscribeReadStreamHandling, stream); + thread writeStreamThread (subscribeWriteStreamHandling, stream); + writeStreamThread.join(); + readStreamThread.join(); + return Status::OK; + } + + Status authorize(ServerContext* context, const kuksa::AuthRequest* request, kuksa::AuthResponse* reply) override { + stringstream msg; + msg << "gRPC authorize invoked with token " << request->token() << std::endl; + logger->Log(LogLevel::INFO,msg.str()); + logger->Log(LogLevel::INFO,context->peer()); + + auto resJson = authorizeHelper(context->peer(), request->token()); + + // Populate the response + if (!resJson.contains("error")) { // Success case + reply->mutable_status()->set_statuscode(200); + reply->mutable_status()->set_statusdescription("Authorization Successful!!"); + reply->set_connectionid(resJson["requestId"].as_string()); + } else { // Failure case + uint32_t code = resJson["error"]["number"].as_uint(); + std::string reason = resJson["error"]["reason"].as_string() + " " + resJson["error"]["message"].as_string(); + reply->mutable_status()->set_statuscode(code); + reply->mutable_status()->set_statusdescription(reason); + } + return Status::OK; + } }; void grpcHandler::RunServer(std::shared_ptr Processor, std::shared_ptr logger_, std::string certPath, bool allowInsecureConn) { - string server_address("127.0.0.1:50051"); - RequestServiceImpl service; + string server_address("0.0.0.0:50051"); + RequestServiceImpl service(logger_); grpc::EnableDefaultHealthCheckService(true); grpc::reflection::InitProtoReflectionServerBuilderPlugin(); @@ -151,4 +385,4 @@ void grpcHandler::RunServer(std::shared_ptr Processor, std: grpcHandler::grpcHandler() = default; -grpcHandler::~grpcHandler() = default; +grpcHandler::~grpcHandler() = default; \ No newline at end of file diff --git a/kuksa-val-server/src/kuksa_viss_grpc_client.cpp b/kuksa-val-server/src/kuksa_viss_grpc_client.cpp deleted file mode 100644 index 29bd2910d..000000000 --- a/kuksa-val-server/src/kuksa_viss_grpc_client.cpp +++ /dev/null @@ -1,263 +0,0 @@ -/* - * ****************************************************************************** - * Copyright (c) 2021 Robert Bosch GmbH. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v2.0 - * which accompanies this distribution, and is available at - * https://www.eclipse.org/org/documents/epl-2.0/index.php - * - * Contributors: - * Robert Bosch GmbH - * ***************************************************************************** - */ - - -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include - -#include "grpcHandler.hpp" -#include "kuksa.grpc.pb.h" -#include "GrpcConnection.hpp" - -using grpc::Channel; -using grpc::ClientContext; -using grpc::Server; -using grpc::ServerBuilder; -using grpc::ServerContext; -using grpc::Status; -using kuksa::viss_client; - - -// splits the input by a delimiter if no delimiter is provided uses " " as delimiter -std::vector split(std::string const& input, std::string const& separator = " ") -{ - std::vector result; - std::string::size_type position, start = 0; - - while (std::string::npos != (position = input.find(separator, start))) - { - result.push_back(input.substr(start, position-start)); - start = position + separator.size(); - } - - result.push_back(input.substr(start)); - return result; -} - -// starts a new client and handles input from command line -void startClient(std::string port, std::string certPath, bool allowInsecureConn = false){ - // insecure client - if(allowInsecureConn){ - GrpcConnection connGrpcSes( - grpc::CreateChannel(port, grpc::InsecureChannelCredentials())); - std::string command; - std::string reply; - // prepare for getting a command while command is not quit - while(reply != "quit"){ - std::cout << "Test-Client>"; - // Get command input from inputfield names - std::getline(std::cin,command); - std::vector temp = split(command,"\""); - std::vector msg = split(temp[0]); - // handles which rpc call is made - if(msg[0] == "getMetaData"){ - if(msg.size() < 2){ - std::cout << "You have to specify a path" << std::endl; - } - else{ - reply = connGrpcSes.GetMetaData(msg[1]); - std::cout << reply << std::endl; - } - } - else if(msg[0] == "authorize"){ - if(msg.size() < 2){ - std::cout << "You have to specify a token" << std::endl; - } - else{ - reply = connGrpcSes.AuthorizeChannel(msg[1]); - std::cout << reply << std::endl; - } - } - else if(msg[0] == "getValue"){ - if(msg.size() < 2){ - std::cout << "You have to specify a path" << std::endl; - } - else{ - reply = connGrpcSes.getValue(msg[1]); - std::cout << reply << std::endl; - } - } - else if(msg[0] == "setValue"){ - if(msg.size() < 2){ - std::cout << "You have to specify a path" << std::endl; - } - if(temp.size() < 2 && msg.size() < 3){ - std::cout << "You have to specify a value" << std::endl; - } - else{ - std::string value; - if(temp.size() < 2){ - value = msg[2]; - } - else{ - value = temp[1]; - } - reply = connGrpcSes.setValue(msg[1],value); - std::cout << reply << std::endl; - } - } - else if(msg[0] == "quit"){ - reply = temp[0]; - } - else{ - std::cout << "Invalid command!" << std::endl; - } - } - } - // SSL client - else{ - std::string cert; - std::string key; - std::string root; - std::string clientpemfile_ = certPath + "/Client.pem"; - std::string clientkeyfile_ = certPath + "/Client.key"; - std::string clientrootfile_ = certPath + "/CA.pem"; - grpcHandler::read (clientpemfile_, cert); - grpcHandler::read (clientkeyfile_, key); - grpcHandler::read (clientrootfile_, root); - grpc::SslCredentialsOptions opts; - opts.pem_cert_chain = cert; - opts.pem_private_key = key; - opts.pem_root_certs = root; - GrpcConnection connGrpcSes( - grpc::CreateChannel(port, grpc::SslCredentials(opts))); - std::string command; - std::string reply; - // prepare for getting a command while command is not quit - while(reply != "quit"){ - std::cout << "Test-Client>"; - // Get command input from inputfield names - std::getline(std::cin,command); - std::vector temp = split(command,"\""); - std::vector msg = split(temp[0]); - // handles which rpc call is made - if(msg[0] == "getMetaData"){ - if(msg.size() < 2){ - std::cout << "You have to specify a path" << std::endl; - } - else{ - reply = connGrpcSes.GetMetaData(msg[1]); - std::cout << reply << std::endl; - } - } - else if(msg[0] == "authorize"){ - if(msg.size() < 2){ - std::cout << "You have to specify a token" << std::endl; - } - else{ - reply = connGrpcSes.AuthorizeChannel(msg[1]); - std::cout << reply << std::endl; - } - } - else if(msg[0] == "getValue"){ - if(msg.size() < 2){ - std::cout << "You have to specify a path" << std::endl; - } - else{ - reply = connGrpcSes.getValue(msg[1]); - std::cout << reply << std::endl; - } - } - else if(msg[0] == "setValue"){ - if(msg.size() < 2){ - std::cout << "You have to specify a path" << std::endl; - } - if(temp.size() < 2 && msg.size() < 3){ - std::cout << "You have to specify a value" << std::endl; - } - else{ - std::string value; - if(temp.size() < 2){ - value = msg[2]; - } - else{ - value = temp[1]; - } - reply = connGrpcSes.setValue(msg[1],value); - std::cout << reply << std::endl; - } - } - else if(msg[0] == "quit"){ - reply = temp[0]; - } - else{ - std::cout << "Invalid command!" << std::endl; - } - } - } -} - -int main(int argc, char** argv) { - // Instantiate the client. It requires a channel, out of which the actual RPCs - // are created. This channel models a connection to an endpoint specified by - // the argument "--target=" which is the only expected argument. - boost::program_options::options_description desc{"OPTIONS"}; - desc.add_options() - ("help,h", "Help screen") - ("config-file,c", boost::program_options::value()->default_value(boost::filesystem::path{"config_grpc_client.ini"}), - "Configuration file for SSL certificates" - "Sample of configuration file parameters looks like:\n" - "cert-path = . \n") - ("cert-path", boost::program_options::value()->required()->default_value(boost::filesystem::path(".")), - "[mandatory] Directory path where 'Client.pem', 'Client.key', and 'CA.pem' are located. ") - ("log-level","Log Level") - ("insecure", boost::program_options::bool_switch()->default_value(false), "By default, `kuksa_viss_grpc_client` establishes only SSL (TLS) secured connections. If provided, `kuksa_viss_grpc_client` shall establish un-secured connections") - ("target",boost::program_options::value()->default_value("127.0.0.1:50051"),"Value for a server connection"); - boost::program_options::variables_map var; - boost::program_options::store(parse_command_line(argc, argv, desc), var); - if (var.count("help")) { - std::cout << "\tCommands available: authorize , getMetaData , getValue , setValue " << std::endl; - std::cout << "\t--config-file default: config_grpc_client.ini | specifies where to search for SSL certificates" << std::endl; - std::cout << "\t--target default: 127.0.0.1:50051 | specifies where to look for a connection to the gRPC server" << std::endl; - std::cout << "\t--insecure default: false | if you call the client with --insecure it establishes a insecure connection" << std::endl; - } - else{ - bool insecure = false; - if (var.count("config-file")) { - auto configFile = var["config-file"].as(); - auto configFilePath = boost::filesystem::path(configFile); - std::cout << "Read configs from " << configFile.string() << std::endl; - std::ifstream ifs(configFile.string()); - if (ifs) { - // update path only, if these options is not defined via command line, but - // via config file - boost::program_options::store(parse_config_file(ifs, desc), var); - auto cert_path = var["cert-path"].as(); - var.at("cert-path").value() = - boost::filesystem::absolute(cert_path, configFilePath.parent_path()); - std::cout << "Update cert-path to " - << var["cert-path"].as().string() - << std::endl; - } else{ - std::cerr << "Could not open config file: " << configFile << std::endl; - } - // store again, because command line argument prefered - boost::program_options::store(parse_command_line(argc, argv, desc), var); - } - if(var.count("insecure")){ - insecure = var["insecure"].as(); - } - startClient(var["target"].as(),var["cert-path"].as().string(),insecure); - } - return 0; -} diff --git a/kuksa-val-server/test/unit-test/AccessCheckerTests.cpp b/kuksa-val-server/test/unit-test/AccessCheckerTests.cpp index ab943e000..f12b7de99 100644 --- a/kuksa-val-server/test/unit-test/AccessCheckerTests.cpp +++ b/kuksa-val-server/test/unit-test/AccessCheckerTests.cpp @@ -20,7 +20,7 @@ #include #include -#include "WsChannel.hpp" +#include "KuksaChannel.hpp" #include "IAuthenticatorMock.hpp" #include "exception.hpp" #include "kuksa.pb.h" @@ -50,7 +50,7 @@ namespace { BOOST_FIXTURE_TEST_SUITE(AccessCheckerTests, TestSuiteFixture) BOOST_AUTO_TEST_CASE(Given_AuthorizedChannel_When_ReadPathAuthorized_Shall_ReturnTrue) { - kuksa::kuksaChannel channel; + KuksaChannel channel; jsoncons::json permissions; // setup @@ -63,16 +63,16 @@ BOOST_AUTO_TEST_CASE(Given_AuthorizedChannel_When_ReadPathAuthorized_Shall_Retur std::string channelPermissions; permissions.dump_pretty(channelPermissions); - channel.set_connectionid(11); - channel.set_authorized(true); - channel.set_permissions(channelPermissions); + channel.setConnID(11); + channel.setAuthorized(true); + channel.setPermissions(channelPermissions); // verify BOOST_TEST(accChecker->checkReadAccess(channel, path) == true); } BOOST_AUTO_TEST_CASE(Given_AuthorizedChannel_When_ReadPathNotAuthorized_Shall_ReturnFalse) { - kuksa::kuksaChannel channel; + KuksaChannel channel; jsoncons::json permissions; // setup @@ -85,16 +85,16 @@ BOOST_AUTO_TEST_CASE(Given_AuthorizedChannel_When_ReadPathNotAuthorized_Shall_Re std::string channelPermissions; permissions.dump_pretty(channelPermissions); - channel.set_connectionid(11); - channel.set_authorized(true); - channel.set_permissions(channelPermissions); + channel.setConnID(11); + channel.setAuthorized(true); + channel.setPermissions(channelPermissions); // verify BOOST_TEST(accChecker->checkReadAccess(channel, path) == false); } BOOST_AUTO_TEST_CASE(Given_AuthorizedChannel_When_ReadPathNotExistent_Shall_ReturnFalse) { - kuksa::kuksaChannel channel; + KuksaChannel channel; jsoncons::json permissions; // setup @@ -107,16 +107,16 @@ BOOST_AUTO_TEST_CASE(Given_AuthorizedChannel_When_ReadPathNotExistent_Shall_Retu std::string channelPermissions; permissions.dump_pretty(channelPermissions); - channel.set_connectionid(11); - channel.set_authorized(true); - channel.set_permissions(channelPermissions); + channel.setConnID(11); + channel.setAuthorized(true); + channel.setPermissions(channelPermissions); // verify BOOST_TEST(accChecker->checkReadAccess(channel, path) == false); } BOOST_AUTO_TEST_CASE(Given_AuthorizedChannel_When_WritePathAuthorized_Shall_ReturnTrue) { - kuksa::kuksaChannel channel; + KuksaChannel channel; jsoncons::json permissions; // setup @@ -129,16 +129,16 @@ BOOST_AUTO_TEST_CASE(Given_AuthorizedChannel_When_WritePathAuthorized_Shall_Retu std::string channelPermissions; permissions.dump_pretty(channelPermissions); - channel.set_connectionid(11); - channel.set_authorized(true); - channel.set_permissions(channelPermissions); + channel.setConnID(11); + channel.setAuthorized(true); + channel.setPermissions(channelPermissions); // verify BOOST_TEST(accChecker->checkWriteAccess(channel, path) == true); } BOOST_AUTO_TEST_CASE(Given_AuthorizedChannel_When_WritePathNotAuthorized_Shall_ReturnFalse) { - kuksa::kuksaChannel channel; + KuksaChannel channel; jsoncons::json permissions; // setup @@ -151,16 +151,16 @@ BOOST_AUTO_TEST_CASE(Given_AuthorizedChannel_When_WritePathNotAuthorized_Shall_R std::string channelPermissions; permissions.dump_pretty(channelPermissions); - channel.set_connectionid(11); - channel.set_authorized(true); - channel.set_permissions(channelPermissions); + channel.setConnID(11); + channel.setAuthorized(true); + channel.setPermissions(channelPermissions); // verify BOOST_TEST(accChecker->checkWriteAccess(channel, path) == false); } BOOST_AUTO_TEST_CASE(Given_AuthorizedChannel_When_WritePathNotExistent_Shall_ReturnFalse) { - kuksa::kuksaChannel channel; + KuksaChannel channel; jsoncons::json permissions; // setup @@ -173,9 +173,9 @@ BOOST_AUTO_TEST_CASE(Given_AuthorizedChannel_When_WritePathNotExistent_Shall_Ret std::string channelPermissions; permissions.dump_pretty(channelPermissions); - channel.set_connectionid(11); - channel.set_authorized(true); - channel.set_permissions(channelPermissions); + channel.setConnID(11); + channel.setAuthorized(true); + channel.setPermissions(channelPermissions); // verify @@ -183,7 +183,7 @@ BOOST_AUTO_TEST_CASE(Given_AuthorizedChannel_When_WritePathNotExistent_Shall_Ret } BOOST_AUTO_TEST_CASE(Given_AuthorizedChannel_When_PathWriteForAllPathsValid_Shall_ReturnTrue) { - kuksa::kuksaChannel channel; + KuksaChannel channel; jsoncons::json jsonPaths, permissions; std::string paths; @@ -197,9 +197,9 @@ BOOST_AUTO_TEST_CASE(Given_AuthorizedChannel_When_PathWriteForAllPathsValid_Shal std::string channelPermissions; permissions.dump_pretty(channelPermissions); - channel.set_connectionid(11); - channel.set_authorized(true); - channel.set_permissions(channelPermissions); + channel.setConnID(11); + channel.setAuthorized(true); + channel.setPermissions(channelPermissions); paths = "[{\"path\":\"$['Vehicle']['children']['Acceleration']['children']['Vertical']\",\"value\":1}," "{\"path\":\"$['Vehicle']['children']['Acceleration']['children']['Longitudinal']\",\"value\":2}" @@ -213,7 +213,7 @@ BOOST_AUTO_TEST_CASE(Given_AuthorizedChannel_When_PathWriteForAllPathsValid_Shal } BOOST_AUTO_TEST_CASE(Given_AuthorizedChannel_When_PathWriteForAllPathsNotValid_Shall_ReturnFalse) { - kuksa::kuksaChannel channel; + KuksaChannel channel; jsoncons::json jsonPaths, permissions; std::string paths; @@ -225,9 +225,9 @@ BOOST_AUTO_TEST_CASE(Given_AuthorizedChannel_When_PathWriteForAllPathsNotValid_S std::string channelPermissions; permissions.dump_pretty(channelPermissions); - channel.set_connectionid(11); - channel.set_authorized(true); - channel.set_permissions(channelPermissions); + channel.setConnID(11); + channel.setAuthorized(true); + channel.setPermissions(channelPermissions); paths = "[{\"path\":\"$['Vehicle']['children']['Acceleration']['children']['Vertical']\",\"value\":1}," "{\"path\":\"$['Vehicle']['children']['Acceleration']['children']['Longitudinal']\",\"value\":2}" @@ -242,7 +242,7 @@ BOOST_AUTO_TEST_CASE(Given_AuthorizedChannel_When_PathWriteForAllPathsNotValid_S BOOST_AUTO_TEST_CASE(Given_AuthorizedChannel_When_PathWriteForAllPathsNotHaveWritePerm_Shall_ReturnFalse) { - kuksa::kuksaChannel channel; + KuksaChannel channel; jsoncons::json jsonPaths, permissions; std::string paths; @@ -254,9 +254,9 @@ BOOST_AUTO_TEST_CASE(Given_AuthorizedChannel_When_PathWriteForAllPathsNotHaveWri std::string channelPermissions; permissions.dump_pretty(channelPermissions); - channel.set_connectionid(11); - channel.set_authorized(true); - channel.set_permissions(channelPermissions); + channel.setConnID(11); + channel.setAuthorized(true); + channel.setPermissions(channelPermissions); paths = "[{\"path\":\"$['Vehicle']['children']['Acceleration']['children']['Vertical']\",\"value\":1}," "{\"path\":\"$['Vehicle']['children']['Acceleration']['children']['Longitudinal']\",\"value\":2}" diff --git a/kuksa-val-server/test/unit-test/AuthenticatorTests.cpp b/kuksa-val-server/test/unit-test/AuthenticatorTests.cpp index a3bf3c41a..afc255746 100644 --- a/kuksa-val-server/test/unit-test/AuthenticatorTests.cpp +++ b/kuksa-val-server/test/unit-test/AuthenticatorTests.cpp @@ -26,7 +26,7 @@ #include #include -#include "WsChannel.hpp" +#include "KuksaChannel.hpp" #include "ILoggerMock.hpp" #include "JsonResponses.hpp" #include "exception.hpp" @@ -104,7 +104,7 @@ BOOST_FIXTURE_TEST_SUITE(AuthenticatorTests, TestSuiteFixture) BOOST_AUTO_TEST_CASE(Given_GoodToken_When_Validate_Shall_ValidateTokenSuccessfully) { - kuksa::kuksaChannel channel; + KuksaChannel channel; // expectations @@ -150,7 +150,7 @@ BOOST_AUTO_TEST_CASE(Given_GoodToken_When_Validate_Shall_ValidateTokenSuccessful BOOST_AUTO_TEST_CASE(Given_BadToken_When_Validate_Shall_ReturnError) { - kuksa::kuksaChannel channel; + KuksaChannel channel; // expectations diff --git a/kuksa-val-server/test/unit-test/CMakeLists.txt b/kuksa-val-server/test/unit-test/CMakeLists.txt index bde1fa8dd..85281231f 100644 --- a/kuksa-val-server/test/unit-test/CMakeLists.txt +++ b/kuksa-val-server/test/unit-test/CMakeLists.txt @@ -63,7 +63,6 @@ if(BUILD_UNIT_TEST) KuksavalUnitTest.cpp UpdateVSSTreeTest.cpp UpdateMetadataTest.cpp - kuksa_grpc_client_mock.cpp ) # declares a test with our executable diff --git a/kuksa-val-server/test/unit-test/Gen2GetTests.cpp b/kuksa-val-server/test/unit-test/Gen2GetTests.cpp index 2ecac557d..f7e28b771 100644 --- a/kuksa-val-server/test/unit-test/Gen2GetTests.cpp +++ b/kuksa-val-server/test/unit-test/Gen2GetTests.cpp @@ -30,7 +30,7 @@ #include "IAuthenticatorMock.hpp" #include "ILoggerMock.hpp" #include "ISubscriptionHandlerMock.hpp" -#include "WsChannel.hpp" +#include "KuksaChannel.hpp" #include "kuksa.pb.h" #include "exception.hpp" @@ -92,7 +92,7 @@ struct TestSuiteFixture { BOOST_FIXTURE_TEST_SUITE(Gen2GetTests, TestSuiteFixture); BOOST_AUTO_TEST_CASE(Gen2_Get_Sensor) { - kuksa::kuksaChannel channel; + KuksaChannel channel; jsoncons::json jsonGetRequestForSignal; jsoncons::json jsonPathNotFound; @@ -102,8 +102,8 @@ BOOST_AUTO_TEST_CASE(Gen2_Get_Sensor) { const VSSPath vss_path = VSSPath::fromVSSGen2(path); // setup - channel.set_authorized(false); - channel.set_connectionid(1); + channel.setAuthorized(false); + channel.setConnID(1); jsonGetRequestForSignal["action"] = "get"; jsonGetRequestForSignal["path"] = path; @@ -142,9 +142,9 @@ BOOST_AUTO_TEST_CASE(Gen2_Get_Sensor) { } BOOST_AUTO_TEST_CASE(Gen2_Get_Invalid_JSON) { - kuksa::kuksaChannel channel; - channel.set_authorized(false); - channel.set_connectionid(1); + KuksaChannel channel; + channel.setAuthorized(false); + channel.setConnID(1); jsoncons::json jsonSetRequestForSignal; @@ -181,9 +181,9 @@ BOOST_AUTO_TEST_CASE(Gen2_Get_Invalid_JSON) { /** Send an invalid JSON, without any determinable Request Id */ BOOST_AUTO_TEST_CASE(Gen2_Get_Invalid_JSON_NoRequestID) { - kuksa::kuksaChannel channel; - channel.set_authorized(false); - channel.set_connectionid(1); + KuksaChannel channel; + channel.setAuthorized(false); + channel.setConnID(1); jsoncons::json jsonSetRequestForSignal; @@ -214,7 +214,7 @@ BOOST_AUTO_TEST_CASE(Gen2_Get_Invalid_JSON_NoRequestID) { } BOOST_AUTO_TEST_CASE(Gen2_Get_NonExistingPath) { - kuksa::kuksaChannel channel; + KuksaChannel channel; jsoncons::json jsonGetRequestForSignal; jsoncons::json jsonPathNotFound; @@ -224,8 +224,8 @@ BOOST_AUTO_TEST_CASE(Gen2_Get_NonExistingPath) { const VSSPath vss_path = VSSPath::fromVSSGen2(path); // setup - channel.set_authorized(false); - channel.set_connectionid(1); + channel.setAuthorized(false); + channel.setConnID(1); jsonGetRequestForSignal["action"] = "get"; jsonGetRequestForSignal["path"] = path; @@ -242,7 +242,7 @@ BOOST_AUTO_TEST_CASE(Gen2_Get_NonExistingPath) { } BOOST_AUTO_TEST_CASE(Gen2_Get_Branch) { - kuksa::kuksaChannel channel; + KuksaChannel channel; jsoncons::json jsonGetRequestForSignal; jsoncons::json jsonPathNotFound; @@ -252,8 +252,8 @@ BOOST_AUTO_TEST_CASE(Gen2_Get_Branch) { const VSSPath vss_path = VSSPath::fromVSSGen2(path); // setup - channel.set_authorized(false); - channel.set_connectionid(1); + channel.setAuthorized(false); + channel.setConnID(1); jsonGetRequestForSignal["action"] = "get"; jsonGetRequestForSignal["path"] = path; @@ -309,7 +309,7 @@ BOOST_AUTO_TEST_CASE(Gen2_Get_Branch) { } BOOST_AUTO_TEST_CASE(Gen2_Get_Wildcard_End) { - kuksa::kuksaChannel channel; + KuksaChannel channel; jsoncons::json jsonGetRequestForSignal; jsoncons::json jsonPathNotFound; @@ -319,8 +319,8 @@ BOOST_AUTO_TEST_CASE(Gen2_Get_Wildcard_End) { const VSSPath vss_path = VSSPath::fromVSSGen2(path); // setup - channel.set_authorized(true); - channel.set_connectionid(1); + channel.setAuthorized(true); + channel.setConnID(1); jsonGetRequestForSignal["action"] = "get"; jsonGetRequestForSignal["attribute"] = "value"; @@ -377,7 +377,7 @@ BOOST_AUTO_TEST_CASE(Gen2_Get_Wildcard_End) { } BOOST_AUTO_TEST_CASE(Gen2_Get_Wildcard_NonExisting) { - kuksa::kuksaChannel channel; + KuksaChannel channel; jsoncons::json jsonGetRequestForSignal; jsoncons::json jsonPathNotFound; @@ -387,8 +387,8 @@ BOOST_AUTO_TEST_CASE(Gen2_Get_Wildcard_NonExisting) { const VSSPath vss_path = VSSPath::fromVSSGen2("Vehicle/VehicleIdentification/Brand"); // setup - channel.set_authorized(false); - channel.set_connectionid(1); + channel.setAuthorized(false); + channel.setConnID(1); jsonGetRequestForSignal["action"] = "get"; jsonGetRequestForSignal["path"] = path; @@ -405,7 +405,7 @@ BOOST_AUTO_TEST_CASE(Gen2_Get_Wildcard_NonExisting) { } BOOST_AUTO_TEST_CASE(Gen2_Get_noPermissionException) { - kuksa::kuksaChannel channel; + KuksaChannel channel; jsoncons::json jsonGetRequestForSignal; jsoncons::json jsonNoAccess; @@ -414,8 +414,8 @@ BOOST_AUTO_TEST_CASE(Gen2_Get_noPermissionException) { const VSSPath vss_path = VSSPath::fromVSSGen2("Vehicle/VehicleIdentification/Brand"); // setup - channel.set_authorized(false); - channel.set_connectionid(1); + channel.setAuthorized(false); + channel.setConnID(1); jsonGetRequestForSignal["action"] = "get"; jsonGetRequestForSignal["path"] = vss_path.to_string(); @@ -443,7 +443,7 @@ BOOST_AUTO_TEST_CASE(Gen2_Get_noPermissionException) { * the meantime */ BOOST_AUTO_TEST_CASE(Gen2_Get_StableTimestamp) { - kuksa::kuksaChannel channel; + KuksaChannel channel; jsoncons::json jsonGetRequestForSignal; jsoncons::json jsonPathNotFound; @@ -453,8 +453,8 @@ BOOST_AUTO_TEST_CASE(Gen2_Get_StableTimestamp) { const VSSPath vss_path = VSSPath::fromVSSGen2(path); // setup - channel.set_authorized(false); - channel.set_connectionid(1); + channel.setAuthorized(false); + channel.setConnID(1); //Setting data (to put a valid timestamp into tree) jsoncons::json value="100"; diff --git a/kuksa-val-server/test/unit-test/Gen2SetTests.cpp b/kuksa-val-server/test/unit-test/Gen2SetTests.cpp index d72347225..62ef0ef6c 100644 --- a/kuksa-val-server/test/unit-test/Gen2SetTests.cpp +++ b/kuksa-val-server/test/unit-test/Gen2SetTests.cpp @@ -28,7 +28,7 @@ #include "IAuthenticatorMock.hpp" #include "ILoggerMock.hpp" #include "ISubscriptionHandlerMock.hpp" -#include "WsChannel.hpp" +#include "KuksaChannel.hpp" #include "exception.hpp" @@ -88,9 +88,9 @@ BOOST_FIXTURE_TEST_SUITE(Gen2SetTests, TestSuiteFixture); /** Set an existing sensor */ BOOST_AUTO_TEST_CASE(Gen2_Set_Sensor_Simple) { - kuksa::kuksaChannel channel; - channel.set_authorized(false); - channel.set_connectionid(1); + KuksaChannel channel; + channel.setAuthorized(false); + channel.setConnID(1); jsoncons::json jsonSetRequestForSignal; @@ -134,9 +134,9 @@ BOOST_AUTO_TEST_CASE(Gen2_Set_Sensor_Simple) { /** Set an array */ BOOST_AUTO_TEST_CASE(Gen2_Set_Array) { - kuksa::kuksaChannel channel; - channel.set_authorized(false); - channel.set_connectionid(1); + KuksaChannel channel; + channel.setAuthorized(false); + channel.setConnID(1); jsoncons::json jsonSetRequestForSignal; @@ -182,9 +182,9 @@ BOOST_AUTO_TEST_CASE(Gen2_Set_Array) { } /** Send an invalid JSON */ BOOST_AUTO_TEST_CASE(Gen2_Set_Invalid_JSON) { - kuksa::kuksaChannel channel; - channel.set_authorized(false); - channel.set_connectionid(1); + KuksaChannel channel; + channel.setAuthorized(false); + channel.setConnID(1); jsoncons::json jsonSetRequestForSignal; @@ -221,9 +221,9 @@ BOOST_AUTO_TEST_CASE(Gen2_Set_Invalid_JSON) { /** Send an invalid JSON, without any determinable Request Id */ BOOST_AUTO_TEST_CASE(Gen2_Set_Invalid_JSON_NoRequestID) { - kuksa::kuksaChannel channel; - channel.set_authorized(false); - channel.set_connectionid(1); + KuksaChannel channel; + channel.setAuthorized(false); + channel.setConnID(1); jsoncons::json jsonSetRequestForSignal; @@ -256,9 +256,9 @@ BOOST_AUTO_TEST_CASE(Gen2_Set_Invalid_JSON_NoRequestID) { /** Set an non-existing path */ BOOST_AUTO_TEST_CASE(Gen2_Set_Non_Existing_Path) { - kuksa::kuksaChannel channel; - channel.set_authorized(false); - channel.set_connectionid(1); + KuksaChannel channel; + channel.setAuthorized(false); + channel.setConnID(1); jsoncons::json jsonSetRequestForSignal; @@ -305,9 +305,9 @@ BOOST_AUTO_TEST_CASE(Gen2_Set_Non_Existing_Path) { /** Set branch */ BOOST_AUTO_TEST_CASE(Gen2_Set_Branch) { - kuksa::kuksaChannel channel; - channel.set_authorized(false); - channel.set_connectionid(1); + KuksaChannel channel; + channel.setAuthorized(false); + channel.setConnID(1); jsoncons::json jsonSetRequestForSignal; @@ -354,9 +354,9 @@ BOOST_AUTO_TEST_CASE(Gen2_Set_Branch) { /** Set attribute */ BOOST_AUTO_TEST_CASE(Gen2_Set_Attribute) { - kuksa::kuksaChannel channel; - channel.set_authorized(false); - channel.set_connectionid(1); + KuksaChannel channel; + channel.setAuthorized(false); + channel.setConnID(1); jsoncons::json jsonSetRequestForSignal; @@ -401,7 +401,7 @@ BOOST_AUTO_TEST_CASE(Gen2_Set_Attribute) { } BOOST_AUTO_TEST_CASE(Gen2_Set_noPermissionException) { - kuksa::kuksaChannel channel; + KuksaChannel channel; jsoncons::json jsonSetRequestForSignal; jsoncons::json jsonNoAccess; @@ -410,8 +410,8 @@ BOOST_AUTO_TEST_CASE(Gen2_Set_noPermissionException) { const VSSPath vss_path = VSSPath::fromVSSGen2("Vehicle/VehicleIdentification/Brand"); // setup - channel.set_authorized(false); - channel.set_connectionid(1); + channel.setAuthorized(false); + channel.setConnID(1); jsonSetRequestForSignal["action"] = "set"; jsonSetRequestForSignal["path"] = vss_path.to_string(); diff --git a/kuksa-val-server/test/unit-test/KuksavalUnitTest.cpp b/kuksa-val-server/test/unit-test/KuksavalUnitTest.cpp index 38789fb22..7872fae2e 100755 --- a/kuksa-val-server/test/unit-test/KuksavalUnitTest.cpp +++ b/kuksa-val-server/test/unit-test/KuksavalUnitTest.cpp @@ -35,7 +35,7 @@ #include "SubscriptionHandler.hpp" #include "VssDatabase.hpp" #include "VssCommandProcessor.hpp" -#include "WsChannel.hpp" +#include "KuksaChannel.hpp" #include "ILogger.hpp" #include "BasicLogger.hpp" #include "IServerMock.hpp" @@ -44,7 +44,7 @@ #include "kuksa.grpc.pb.h" #include "grpcHandler.hpp" #include "kuksa_mock.grpc.pb.h" -#include "GrpcConnection.hpp" + /* AUTH_JWT permission token looks like this { @@ -115,9 +115,9 @@ kuksavalunittest::~kuksavalunittest() { // For testing the client the server could be mocked //-------------------------------------gRPC Client Logic Test -class FakeClient { +/*class FakeClient { public: - FakeClient(kuksa::viss_client::StubInterface* stub) : connGrpcSes(grpc::CreateChannel("127.0.0.1", grpc::InsecureChannelCredentials())), stub_(stub){ + FakeClient(kuksa::kuksa_grpc_if::StubInterface* stub) : connGrpcSes(grpc::CreateChannel("127.0.0.1", grpc::InsecureChannelCredentials())), stub_(stub){ } ~FakeClient() = default; void Setup(){ @@ -212,14 +212,14 @@ class FakeClient { BOOST_TEST(result["requestId"].to_string() == expected["requestId"].to_string()); } private: - kuksa::viss_client::StubInterface* stub_; - kuksa::kuksaChannel kuksa_channel; + /kuksa::viss_client::StubInterface* stub_; + KuksaChannel kuksa_channel; GrpcConnection connGrpcSes; -}; +};*/ //--------Do not change the order of the tests in this file, because some results are dependent on the previous tests and data in the db------- //----------------------------------------------------gRPC Client Logic Tests -BOOST_AUTO_TEST_CASE(Test_GetMetaDataService){ +/*BOOST_AUTO_TEST_CASE(Test_GetMetaDataService){ kuksa::Mockviss_clientStub stub; FakeClient client(&stub); client.Setup(); @@ -299,7 +299,7 @@ BOOST_AUTO_TEST_CASE(Test_AuthService){ })"); EXPECT_CALL(stub, AuthorizeChannel(testing::_,testing::_,testing::_)).Times(testing::AtLeast(1)).WillOnce(testing::DoAll(testing::SetArgPointee<2>(resp), testing::Return(grpc::Status::OK))); client.doAuth(); -} +}*/ //----------------------------------------------------VssDatabase Tests @@ -343,8 +343,8 @@ BOOST_AUTO_TEST_CASE(set_get_test_all_datatypes_boundary_conditions) MOCK_EXPECT(accesshandler->checkReadAccess).returns(true); MOCK_EXPECT(mqttPublisher->sendPathValue).returns(true); json result; - kuksa::kuksaChannel channel; - channel.set_connectionid(1234); + KuksaChannel channel; + channel.setConnID(1234); string authReq(R"({ "action": "authorize", "requestId": "87568" @@ -375,7 +375,7 @@ BOOST_AUTO_TEST_CASE(set_get_test_all_datatypes_boundary_conditions) database->setSignal(vss_test_path_Uint8, "value", test_value_Uint8_boundary_high); result = database->getSignal(vss_test_path_Uint8, "value"); - BOOST_TEST(result["dp"]["value"].as() == numeric_limits::max()); + BOOST_TEST(result["dp"]["value"].as() == numeric_limits::max()); json test_value_Uint8_boundary_middle; test_value_Uint8_boundary_middle = numeric_limits::max() / 2; @@ -431,7 +431,7 @@ BOOST_AUTO_TEST_CASE(set_get_test_all_datatypes_boundary_conditions) test_value_Uint16_boundary_middle = numeric_limits::max() / 2; database->setSignal(vss_test_path_Uint16, "value", test_value_Uint16_boundary_middle); - result = database->getSignal(vss_test_path_Uint16,"value"); + result = database->getSignal(vss_test_path_Uint16, "value"); BOOST_TEST(result["dp"]["value"].as() == numeric_limits::max() / 2); @@ -481,7 +481,7 @@ BOOST_AUTO_TEST_CASE(set_get_test_all_datatypes_boundary_conditions) test_value_Uint32_boundary_middle = numeric_limits::max() / 2; database->setSignal(vss_test_path_Uint32, "value", test_value_Uint32_boundary_middle); - result = database->getSignal(vss_test_path_Uint32,"value"); + result = database->getSignal(vss_test_path_Uint32, "value"); BOOST_TEST(result["dp"]["value"].as() == numeric_limits::max() / 2); @@ -630,7 +630,7 @@ BOOST_AUTO_TEST_CASE(set_get_test_all_datatypes_boundary_conditions) test_value_int32_boundary_low = numeric_limits::min(); database->setSignal(vss_test_path_int32, "value", test_value_int32_boundary_low); - result = database->getSignal(vss_test_path_int32,"value"); + result = database->getSignal(vss_test_path_int32, "value"); BOOST_TEST(result["dp"]["value"].as() == numeric_limits::min()); @@ -697,7 +697,7 @@ BOOST_AUTO_TEST_CASE(set_get_test_all_datatypes_boundary_conditions) test_value_Float_boundary_high = std::numeric_limits::max(); database->setSignal(vss_test_path_Float, "value", test_value_Float_boundary_high); - result = database->getSignal(vss_test_path_Float,"value"); + result = database->getSignal(vss_test_path_Float, "value"); BOOST_TEST(result["dp"]["value"].as() == std::numeric_limits::max()); @@ -706,7 +706,7 @@ BOOST_AUTO_TEST_CASE(set_get_test_all_datatypes_boundary_conditions) test_value_Float_boundary_middle = std::numeric_limits::max() / 2; database->setSignal(vss_test_path_Float, "value", test_value_Float_boundary_middle); - result = database->getSignal(vss_test_path_Float,"value"); + result = database->getSignal(vss_test_path_Float, "value"); BOOST_TEST(result["dp"]["value"].as() == std::numeric_limits::max() / 2); @@ -727,7 +727,7 @@ BOOST_AUTO_TEST_CASE(set_get_test_all_datatypes_boundary_conditions) test_value_Double_boundary_low = std::numeric_limits::min(); database->setSignal(vss_test_path_Double, "value", test_value_Double_boundary_low); - result = database->getSignal(vss_test_path_Double,"value"); + result = database->getSignal(vss_test_path_Double, "value"); BOOST_TEST(result["dp"]["value"].as() == std::numeric_limits::min()); @@ -990,8 +990,8 @@ BOOST_AUTO_TEST_CASE(test_metadata_branch_with_wildcard) BOOST_AUTO_TEST_CASE(process_query_set_get_simple) { - kuksa::kuksaChannel channel; - channel.set_connectionid(1234); + KuksaChannel channel; + channel.setConnID(1234); string authReq(R"({ "action": "authorize", "requestId": "87568" @@ -1051,8 +1051,8 @@ BOOST_AUTO_TEST_CASE(process_query_set_get_simple) BOOST_AUTO_TEST_CASE(process_query_get_withwildcard) { - kuksa::kuksaChannel channel; - channel.set_connectionid(1234); + KuksaChannel channel; + channel.setConnID(1234); string authReq(R"({ "action": "authorize", "requestId": "87568" @@ -1168,8 +1168,8 @@ BOOST_AUTO_TEST_CASE(process_query_set_get_withwildcard) BOOST_AUTO_TEST_CASE(process_query_get_withwildcard_invalid) { - kuksa::kuksaChannel channel; - channel.set_connectionid(1234); + KuksaChannel channel; + channel.setConnID(1234); string authReq(R"({ "action": "authorize", "requestId": "87568" @@ -1219,8 +1219,8 @@ BOOST_AUTO_TEST_CASE(permission_basic_read) string AUTH_TOKEN = "eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiJFeGFtcGxlIEpXVCIsImlzcyI6IkVjbGlwc2Uga3Vrc2EiLCJhZG1pbiI6dHJ1ZSwiaWF0IjoxNTE2MjM5MDIyLCJleHAiOjE2MDkzNzI4MDAsInczYy12c3MiOnsiVmVoaWNsZS5PQkQuRW5naW5lU3BlZWQiOiJyIn19.jbhdMq5hEWXXNfZn9xE4rECIWEVsw-q3g-jxp5lLS0VAZ2WYOGoSd5JX2P9YG0Lals7Ue0wdXtgLSFtvIGU4Ol2MuPaF-Rbb-Q5O4njxg60AZ00kr6RywpyGZHK0eT9MuFCnVMN8Krf3lo2pPB1ms-WAHX6rfArbXxx0FsMau9Ewn_3m3Sc-6sz5alQw1Y7Rk0GD9Y7WP_mbICU__gd40Ypu_ki1i59M8ba5GNfd8RytEIJXAg7RTcKREWDZfMdFH5X7F6gAPA7h_tVH3-bsbT-nOsKCbM-3PM0EKAOl104SwmKcqoWnfXbUow5zt25O8LYwmrukuRBtWiLI5FxeW6ovmS-1acvS3w1LXlQZVGWtM_ZC7shtHh-iz7nyL1WCTpZswHgoqVrvnJ0PVZQkBMBFKvsbu9WkWPUqHe0sx2cDUOdolelspfClO6iP7CYTUQQqyDov9zByDiBfQ7rILQ_LcwPG6UAAbEgM0pC_lntsPzbdcq0V-rE_OMO6y7HtmGN7GPhYHGU0K4qQBuYI_Pdn2gqyCEciI6_awB1LG4RwfoC8ietGUuGmxdcl2PWm0DI-Kj1f1bNlwc-54LKg8v5K54zsBdmK4SrrJ6Nt6OgCqq3On7zHfTDFN01dqWP6EoQHhEn6Akx5HiioTW3CHSVq6pd09Po5cgAAIoQE2U0"; - kuksa::kuksaChannel channel; - channel.set_connectionid(1234); + KuksaChannel channel; + channel.setConnID(1234); string authReq(R"({ "action": "authorize", "requestId": "87568" @@ -1273,8 +1273,8 @@ BOOST_AUTO_TEST_CASE(permission_basic_read_with_wildcard_path) string AUTH_TOKEN = "eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiJFeGFtcGxlIEpXVCIsImlzcyI6IkVjbGlwc2Uga3Vrc2EiLCJhZG1pbiI6dHJ1ZSwiaWF0IjoxNTE2MjM5MDIyLCJleHAiOjE2MDkzNzI4MDAsInczYy12c3MiOnsiVmVoaWNsZS5PQkQuRW5naW5lU3BlZWQiOiJyIn19.jbhdMq5hEWXXNfZn9xE4rECIWEVsw-q3g-jxp5lLS0VAZ2WYOGoSd5JX2P9YG0Lals7Ue0wdXtgLSFtvIGU4Ol2MuPaF-Rbb-Q5O4njxg60AZ00kr6RywpyGZHK0eT9MuFCnVMN8Krf3lo2pPB1ms-WAHX6rfArbXxx0FsMau9Ewn_3m3Sc-6sz5alQw1Y7Rk0GD9Y7WP_mbICU__gd40Ypu_ki1i59M8ba5GNfd8RytEIJXAg7RTcKREWDZfMdFH5X7F6gAPA7h_tVH3-bsbT-nOsKCbM-3PM0EKAOl104SwmKcqoWnfXbUow5zt25O8LYwmrukuRBtWiLI5FxeW6ovmS-1acvS3w1LXlQZVGWtM_ZC7shtHh-iz7nyL1WCTpZswHgoqVrvnJ0PVZQkBMBFKvsbu9WkWPUqHe0sx2cDUOdolelspfClO6iP7CYTUQQqyDov9zByDiBfQ7rILQ_LcwPG6UAAbEgM0pC_lntsPzbdcq0V-rE_OMO6y7HtmGN7GPhYHGU0K4qQBuYI_Pdn2gqyCEciI6_awB1LG4RwfoC8ietGUuGmxdcl2PWm0DI-Kj1f1bNlwc-54LKg8v5K54zsBdmK4SrrJ6Nt6OgCqq3On7zHfTDFN01dqWP6EoQHhEn6Akx5HiioTW3CHSVq6pd09Po5cgAAIoQE2U0"; - kuksa::kuksaChannel channel; - channel.set_connectionid(1234); + KuksaChannel channel; + channel.setConnID(1234); string authReq(R"({ "action": "authorize", "requestId": "87568" @@ -1344,8 +1344,8 @@ BOOST_AUTO_TEST_CASE(permission_basic_read_with_branch_path) string AUTH_TOKEN = "eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiJFeGFtcGxlIEpXVCIsImlzcyI6IkVjbGlwc2Uga3Vrc2EiLCJhZG1pbiI6dHJ1ZSwiaWF0IjoxNTE2MjM5MDIyLCJleHAiOjE2MDkzNzI4MDAsInczYy12c3MiOnsiVmVoaWNsZS5PQkQuRW5naW5lU3BlZWQiOiJyIn19.jbhdMq5hEWXXNfZn9xE4rECIWEVsw-q3g-jxp5lLS0VAZ2WYOGoSd5JX2P9YG0Lals7Ue0wdXtgLSFtvIGU4Ol2MuPaF-Rbb-Q5O4njxg60AZ00kr6RywpyGZHK0eT9MuFCnVMN8Krf3lo2pPB1ms-WAHX6rfArbXxx0FsMau9Ewn_3m3Sc-6sz5alQw1Y7Rk0GD9Y7WP_mbICU__gd40Ypu_ki1i59M8ba5GNfd8RytEIJXAg7RTcKREWDZfMdFH5X7F6gAPA7h_tVH3-bsbT-nOsKCbM-3PM0EKAOl104SwmKcqoWnfXbUow5zt25O8LYwmrukuRBtWiLI5FxeW6ovmS-1acvS3w1LXlQZVGWtM_ZC7shtHh-iz7nyL1WCTpZswHgoqVrvnJ0PVZQkBMBFKvsbu9WkWPUqHe0sx2cDUOdolelspfClO6iP7CYTUQQqyDov9zByDiBfQ7rILQ_LcwPG6UAAbEgM0pC_lntsPzbdcq0V-rE_OMO6y7HtmGN7GPhYHGU0K4qQBuYI_Pdn2gqyCEciI6_awB1LG4RwfoC8ietGUuGmxdcl2PWm0DI-Kj1f1bNlwc-54LKg8v5K54zsBdmK4SrrJ6Nt6OgCqq3On7zHfTDFN01dqWP6EoQHhEn6Akx5HiioTW3CHSVq6pd09Po5cgAAIoQE2U0"; - kuksa::kuksaChannel channel; - channel.set_connectionid(1234); + KuksaChannel channel; + channel.setConnID(1234); string authReq(R"({ "action": "authorize", "requestId": "87568" @@ -1415,8 +1415,8 @@ BOOST_AUTO_TEST_CASE(permission_basic_read_with_non_permitted_path) string AUTH_TOKEN = "eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiJFeGFtcGxlIEpXVCIsImlzcyI6IkVjbGlwc2Uga3Vrc2EiLCJhZG1pbiI6dHJ1ZSwiaWF0IjoxNTE2MjM5MDIyLCJleHAiOjE2MDkzNzI4MDAsInczYy12c3MiOnsiVmVoaWNsZS5PQkQuRW5naW5lU3BlZWQiOiJyIn19.VDr_UU_efYVaotMSRs-Ga7xf1a7ArEb0oTfJixTR4ah9aXnXYNHL-f4N4YZQ1A4mX3YhdcxifgV2kE1XwXE0XBoYjydy9g8pZhPm-fMF3z9zTeWRhPBSSHYLgcJQRINChtipmn1RIQxeeEqDX3E0n4utb0HfNXcEDTOKSeP4sFygjiDyEJYl_zn1JoMWfV8HJ9beYgVybKyMRLkM7FsGqT-aUOVfdxhH3nQSGFleI-nzFh6fFIaVbNdZo9u4moeIcaoeZJLJEe2410-xTtByxp_fN0OTxntHbloLSRLjY8MxC1hu1Uhbxs5GKPfJDV7ZhhbULzqqiRMSGn13ELJO-yPEnaHV8NZ8V9U6My-rBkEGgVcwCsbyDu-i7hAP8fepFCpyYfmZkypXxrZQHj8idJ16SXHNzNLL4Q7uiXSwc9oPSRI8FcbEwk-Ul7sD-X7kUqfFukO49NGUdobc-JhVzsJl-eofwe0H0Rq3hme6Rj1kFjitLYU2SyZjUsYrrGpYrghahh7MfSjf2lqNi159wfYtZtopoBrbPmAJ3HnzWXYM2ai0kroELRCaHz4adodMtem4qTBGJoYgG7hAg1OxvnbOdYOD7yZ46-RxBGgaoWuxAnQRHsnGs4j0SaXRTVWvTBHg21tI6AHo4wwyfUD4pGEaxB3M3bEH9m2hWl4HZpk"; - kuksa::kuksaChannel channel; - channel.set_connectionid(1234); + KuksaChannel channel; + channel.setConnID(1234); string authReq(R"({ "action": "authorize", "requestId": "87568" @@ -1464,8 +1464,8 @@ BOOST_AUTO_TEST_CASE(permission_basic_read_with_invalid_permission_valid_path) */ string AUTH_TOKEN = "eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiJFeGFtcGxlIEpXVCIsImlzcyI6IkVjbGlwc2Uga3Vrc2EiLCJhZG1pbiI6dHJ1ZSwiaWF0IjoxNTE2MjM5MDIyLCJleHAiOjE5MjQ5NDg4MDAsImt1a3NhLXZzcyI6eyJWZWhpY2xlLk9CRC5FbmdpbmVTcGVlZDEiOiJyIn19.rST_a1LunN5PT1UbqFfiSS5-75nX29fXh0ZUFbIGWADk7JInDDo7EP6tt2HmiX6vW3RoeKVoZCM_UB9fKfKmJMA9-pgBkeGjVcf8PmGzIJUKJPjPp3vRUrWop0UABeCqlnlQ7SFO3IlfcSarHg0P9SdmPQm6WOtJSqv806KIe5cLVhl9Ikr0cmYMO5IJ5IQzQP6cDcWl5zro75v5MtQbjHrNBKAm7qclQnBtx0oeMmdSmLQLJR0RLy10VeORtqqrSksy2QKmVkrmK2vX1GuwR-kOOEqBZWz9j8HJ4I05XpCdltKx1P41mQIWxZKUp87uKsqZBe_8V5Bd2bqYbP3MKyIxsZEUGUjjpbLogu1DBS05oJHc4_Al6AMclX5DVkWDL7M1HMGwgOAqIfsQwwiGJah6n9c43K2oDGHmsc0zrKmNcx-UDA7dqbg1PnrAWx7Ex__nI95zhoDYnbsoxLhg_tOVaCzvvA3pCU8IEDcTBSyDp-PUVzF6m3TbzJlwrLRP2_kzl48asn5U1fiMvGTFiVzRUv34uvnelQuK0954NsqnOi9tHAP2ljNrP75KuehAqmdWhHXWMkxoUFbQ974bWP6J0eYu1SnuQs2mR-3bf_HhxxPNI-5tgNOZ0ROwfDfHrOLdMP1RgoweLrpvmffwhV1aFTAQyvqjSJYVl9tZKfk"; - kuksa::kuksaChannel channel; - channel.set_connectionid(1234); + KuksaChannel channel; + channel.setConnID(1234); string authReq(R"({ "action": "authorize", "requestId": "87568" @@ -1513,8 +1513,8 @@ BOOST_AUTO_TEST_CASE(permission_basic_read_with_branch_permission_valid_path) string AUTH_TOKEN = "eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiJFeGFtcGxlIEpXVCIsImlzcyI6IkVjbGlwc2Uga3Vrc2EiLCJhZG1pbiI6dHJ1ZSwiaWF0IjoxNTE2MjM5MDIyLCJleHAiOjE2MDkzNzI4MDAsInczYy12c3MiOnsiVmVoaWNsZS5PQkQiOiJyIn19.aFM4kmqmupJmxkCXXPHUnmC5JC4ioIYwczk_YcGLy8ULfT4As6fzZNnAFTZVk-axBbIHnU3aUTigI5wZroF0ZkdWzJ1FA1-ZEXRLwUug9pigOC4hvTn4layT4tSEylHm3Mhh8M3Z0O4QKr-TuKZgZcbIICjrI3GQvm0kdkAO1hUTDPF2yQv16qCPuWvmJEDmy70MjzZfKIy94LCXL6Gf1OdIo4hXIbhLFPOR4ea8iaEz35VEjEZ828KbP8DCXRNWlad-CjAx7f4whS_YHctVZelFoa5G-MzNXRcr54VmkGbYM4WGDn6Twamsfb7YmwROzNmsI8DNahWWXciWxVZElsAexKx5yFXr3CslxG8dbgZgHWQ1tZe0Nq1b-4XUkomz6e6hd0iUF913D-TjvBACz4fpl5_28Wr0TMy84w1DvkpfNmgQ_1fiZNbho2uBxDoisfDWq_sI_ph0xO5mu-HKrs2T_tkuFveCPDHvIm1uZIzT8hX2cFDoBNClUlf4BOo6EHw3Ax9ISr28WzRxpZPOs9bYh4AIlnkqh28P91emK7pdb4eXhZKm3ZVWGEA17pLUUraxEhTYWXAFMsafwqTAaUhYt-JUBiExvHRvZpa49UDkXd4lJvl9gYO9YPiyrG6dioIsK9QSw-Mhob2WacRUzbG0O8V9uVApjw73tK4FYhA"; - kuksa::kuksaChannel channel; - channel.set_connectionid(1234); + KuksaChannel channel; + channel.setConnID(1234); string authReq(R"({ "action": "authorize", "requestId": "87568" @@ -1567,8 +1567,8 @@ BOOST_AUTO_TEST_CASE(permission_basic_read_with_branch_permission_valid_path_2) string AUTH_TOKEN = "eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiJFeGFtcGxlIEpXVCIsImlzcyI6IkVjbGlwc2Uga3Vrc2EiLCJhZG1pbiI6dHJ1ZSwiaWF0IjoxNTE2MjM5MDIyLCJleHAiOjE2MDkzNzI4MDAsInczYy12c3MiOnsiVmVoaWNsZS5PQkQiOiJyIn19.aFM4kmqmupJmxkCXXPHUnmC5JC4ioIYwczk_YcGLy8ULfT4As6fzZNnAFTZVk-axBbIHnU3aUTigI5wZroF0ZkdWzJ1FA1-ZEXRLwUug9pigOC4hvTn4layT4tSEylHm3Mhh8M3Z0O4QKr-TuKZgZcbIICjrI3GQvm0kdkAO1hUTDPF2yQv16qCPuWvmJEDmy70MjzZfKIy94LCXL6Gf1OdIo4hXIbhLFPOR4ea8iaEz35VEjEZ828KbP8DCXRNWlad-CjAx7f4whS_YHctVZelFoa5G-MzNXRcr54VmkGbYM4WGDn6Twamsfb7YmwROzNmsI8DNahWWXciWxVZElsAexKx5yFXr3CslxG8dbgZgHWQ1tZe0Nq1b-4XUkomz6e6hd0iUF913D-TjvBACz4fpl5_28Wr0TMy84w1DvkpfNmgQ_1fiZNbho2uBxDoisfDWq_sI_ph0xO5mu-HKrs2T_tkuFveCPDHvIm1uZIzT8hX2cFDoBNClUlf4BOo6EHw3Ax9ISr28WzRxpZPOs9bYh4AIlnkqh28P91emK7pdb4eXhZKm3ZVWGEA17pLUUraxEhTYWXAFMsafwqTAaUhYt-JUBiExvHRvZpa49UDkXd4lJvl9gYO9YPiyrG6dioIsK9QSw-Mhob2WacRUzbG0O8V9uVApjw73tK4FYhA"; - kuksa::kuksaChannel channel; - channel.set_connectionid(1234); + KuksaChannel channel; + channel.setConnID(1234); string authReq(R"({ "action": "authorize", "requestId": "87568" @@ -1620,8 +1620,8 @@ BOOST_AUTO_TEST_CASE(permission_basic_read_with_wildcard_permission) string AUTH_TOKEN = "eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiJFeGFtcGxlIEpXVCIsImlzcyI6IkVjbGlwc2Uga3Vrc2EiLCJhZG1pbiI6dHJ1ZSwiaWF0IjoxNTE2MjM5MDIyLCJleHAiOjE2MDkzNzI4MDAsInczYy12c3MiOnsiVmVoaWNsZS4qLkVuZ2luZVNwZWVkIjoiciJ9fQ.fUyHFOh3rD2IwOVMIYzNKdR4Y6IbKmQhN3Y2pGfcOy8SjXcE5MS6owIYRUVCxnlnH9-ywpNrwvePgKPHnjnWq8wSHr6I22zh3dNty0dFn-gJ82LQ-aNRKcweFqZXXP7-b-__Lc_ivEZpl-w0T9IzPWsUhZyt82XIPkzOZrfULv-DhXpoVIFTr-nz7KSpypcp0j_zXvbkf35bLLwcca7nMY5a9ftMKzMcv4xWekjPQQYvGchtLi1lOG1k8iHlf_cGsVEE4CK55x3bkrEjOYagT7WlRkMgR4F4HOzG0LNHsiXEVpNf17cs1Fsy6K5ObY-_J4BCx8wWGc7Bnkg4yap_3jG1IW_o7gcINcx4WiTNHz42LU6d0GQ9spc3vSP5vPm7J1aglBqazYf-tWRHp7QF8WDtAgenLpb4Ld4n_Aq5gHBWfOlt4tCyMgOgLlnzUJT1yc65vNesB7zUAFCdJ49kSV4Lwf0hv4W-hXl3wUPvb06yaff4U2_zrDQOc7GhoVLMzHmAYccNlDEMfM6HjQAnGLLIdvMxfs5g4a2CLKfxbOusRAQYNd4XwU4CpNAWabiu0FHIC43vy578zY3dpCHBOtpEC5csNEnHqyTSWdJwMy9BLmPneNM04NIHni-4ir4ExzK1TUmIDisk5_KBWmcjKyW-HX8k_u2gxylCf9I82Y0"; - kuksa::kuksaChannel channel; - channel.set_connectionid(1234); + KuksaChannel channel; + channel.setConnID(1234); string authReq(R"({ "action": "authorize", "requestId": "87568" @@ -1673,8 +1673,8 @@ BOOST_AUTO_TEST_CASE(permission_basic_read_with_wildcard_write_permission) string AUTH_TOKEN = "eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiJFeGFtcGxlIEpXVCIsImlzcyI6IkVjbGlwc2Uga3Vrc2EiLCJhZG1pbiI6dHJ1ZSwiaWF0IjoxNTE2MjM5MDIyLCJleHAiOjE5MjQ5NDg4MDAsImt1a3NhLXZzcyI6eyJWZWhpY2xlLiouRW5naW5lU3BlZWQiOiJ3In19.ILMNoPpsF9OD_EhBRvm679kGFFzQVOWpxtws9flHjyoXBUuswfTYo6VTZySksyIv2EEVsFwgHG6EpYU18dXvpBXWI7KtUlkUy0ewiwNXZDsrpPVD1_dhlSs5aNvHsGJr2X_aHF-gZ89XtZ1sBBcza7FdtoMQMn9hyWs3rPi5d552uwxCpMO7EDwzb8rNrndEbtuORQmSCSHb74gVP5_thZvKmfCvJLOYaqXbtIff7CNJc5JtmOp7Suv2ICVhDAyiVRAF8wC5yXCRS_MfHRHT-VVO6PvnOzUkZU4VskkCz10L4XyHhj-2GEnXaPnVV76H1BZscLAnshoiR1I6rWAA4yvRcriJkmnM3DSJqvPJ4wQ7pZsZE48n6jfrPU1fZPGrCIMbJ67-YntL9XL0GHO2AdJTD9nj4sYpVVSPJPheQSLVbQwUJq7JPczkJ04kvDpLIOp27A8GnT0JN78liQSH4VUuExY3et2f5VbyGKZbEbwtV_R8WuVOuFKGlrI07KhpYsz3avVNwNZonjEuU7f6Uadad2zZh96nJ623BgbdNhMCC-WkjoXZos7JjKIXKKLH1_LyHIVpubZFlzh2GUJNItr7k-VlLodjrvqsoBcz-Zi0KyUco69X5qz9qousN4E3LPSP5btefq-D2nhFUkn2lW_YPyWA6Wtfi6Fauby0ZD8"; - kuksa::kuksaChannel channel; - channel.set_connectionid(1234); + KuksaChannel channel; + channel.setConnID(1234); string authReq(R"({ "action": "authorize", "requestId": "87568" @@ -1722,8 +1722,8 @@ BOOST_AUTO_TEST_CASE(permission_basic_read_with_wildcard_permission_wildcard_req string AUTH_TOKEN = "eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiJFeGFtcGxlIEpXVCIsImlzcyI6IkVjbGlwc2Uga3Vrc2EiLCJhZG1pbiI6dHJ1ZSwiaWF0IjoxNTE2MjM5MDIyLCJleHAiOjE5MjQ5NDg4MDAsImt1a3NhLXZzcyI6eyJWZWhpY2xlLiouRW5naW5lU3BlZWQiOiJyIn19.4L_gleoOJ29SR75go0qtBgYjwkwWE0ofYMMQJm884-ifCNihl3aSNhxjVy-6KUQckTd-OMiGkd1RRXElHfnaLfVSmpaFAIjupzvXaKwEoLa6duXfh3-qaEQPSCUxSjr8Tur3aXkj8nJEcSYBYUo_RTX-Srgto0dSTLQza0Lvm0aYPHhE6oIy2dniMIxwCSNxtarFt6-DWIxR3RqFcTVcuGtgn3A6JCm-WurI2zHsmF2BHrIfUYWuTdzUH16QLSfviTVcMjBLgGhVGdQPz22t4nKtdwcVMJkYfLsaU-GYuRi-ZMIrbi7F1oU8pU21U4Ja9C9CuR-H4Xhy2uG_FVQmog-_K-kR6_tndbM-AL7BnfOt-T_QpD-CSfCY0K5Y1bS_IuiM6MrXu5J2q1lfLp_TAK9YBWpuKRGhxdke7zHlSB37dpbiqZFIdGwfJ7Kq6XzqZNFRkWw7_XM2U4s5OXcw2JDklJYJ_EA1bUBhoPb-UHCqYxTP6G5OAHgD1Ydji93o3IsRSt6cX8o7hsmF79L3HvSzCm-qTN_EPhvbVfucJFj5phOd_9GjoFn3ySkwTINX_Pe3aT-Kz9qn5_Sb6utxw4eYvf_e_TYH6bAICjb9OmOyvH5gS9u2ieJ_1ra4SIGuZ25d86m3aRBybJSnFCprpsv63ziKXNGcL2vIGlCzKUc"; - kuksa::kuksaChannel channel; - channel.set_connectionid(1234); + KuksaChannel channel; + channel.setConnID(1234); string authReq(R"({ "action": "authorize", "requestId": "87568" @@ -1771,8 +1771,8 @@ BOOST_AUTO_TEST_CASE(permission_basic_read_with_wildcard_permission_branch_path_ string AUTH_TOKEN = "eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiJFeGFtcGxlIEpXVCIsImlzcyI6IkVjbGlwc2Uga3Vrc2EiLCJhZG1pbiI6dHJ1ZSwiaWF0IjoxNTE2MjM5MDIyLCJleHAiOjE5MjQ5NDg4MDAsImt1a3NhLXZzcyI6eyJWZWhpY2xlLiouRW5naW5lU3BlZWQiOiJyIn19.4L_gleoOJ29SR75go0qtBgYjwkwWE0ofYMMQJm884-ifCNihl3aSNhxjVy-6KUQckTd-OMiGkd1RRXElHfnaLfVSmpaFAIjupzvXaKwEoLa6duXfh3-qaEQPSCUxSjr8Tur3aXkj8nJEcSYBYUo_RTX-Srgto0dSTLQza0Lvm0aYPHhE6oIy2dniMIxwCSNxtarFt6-DWIxR3RqFcTVcuGtgn3A6JCm-WurI2zHsmF2BHrIfUYWuTdzUH16QLSfviTVcMjBLgGhVGdQPz22t4nKtdwcVMJkYfLsaU-GYuRi-ZMIrbi7F1oU8pU21U4Ja9C9CuR-H4Xhy2uG_FVQmog-_K-kR6_tndbM-AL7BnfOt-T_QpD-CSfCY0K5Y1bS_IuiM6MrXu5J2q1lfLp_TAK9YBWpuKRGhxdke7zHlSB37dpbiqZFIdGwfJ7Kq6XzqZNFRkWw7_XM2U4s5OXcw2JDklJYJ_EA1bUBhoPb-UHCqYxTP6G5OAHgD1Ydji93o3IsRSt6cX8o7hsmF79L3HvSzCm-qTN_EPhvbVfucJFj5phOd_9GjoFn3ySkwTINX_Pe3aT-Kz9qn5_Sb6utxw4eYvf_e_TYH6bAICjb9OmOyvH5gS9u2ieJ_1ra4SIGuZ25d86m3aRBybJSnFCprpsv63ziKXNGcL2vIGlCzKUc"; - kuksa::kuksaChannel channel; - channel.set_connectionid(1234); + KuksaChannel channel; + channel.setConnID(1234); string authReq(R"({ "action": "authorize", "requestId": "87568" @@ -1820,8 +1820,8 @@ BOOST_AUTO_TEST_CASE(permission_basic_read_with_full_read_permission) */ string AUTH_TOKEN = "eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiJFeGFtcGxlIEpXVCIsImlzcyI6IkVjbGlwc2Uga3Vrc2EiLCJhZG1pbiI6dHJ1ZSwiaWF0IjoxNTE2MjM5MDIyLCJleHAiOjE2MDkzNzI4MDAsInczYy12c3MiOnsiVmVoaWNsZSI6InIifX0.AKCWRDrtl4UkFzAGEzsyUZIKH4Q7jHg_Y5p8xVMLWtGTXIeFdQlz7FW-6rAy1Os9ad-H8ghEepcy2gs6DK3kr3FNDxqUyIaz8p_CDkwrgqp0Wczi1DsgwbyTsY2wsDa94Mja3ng2VszQgs4FZmsdbnzFzJeAsGucOZeIQj8w68up6YI6KXiCjO1094I2eixkclNnb1psPiucTkyListTLHxK3029fZT1EGGcrt7ziFYGiT5Z0Zk7x0PSN7dvmaT1rMOBWjbpluLCepkWZYt73ipO8YoAWhluMiW0sJI7ezrIU3UAKDkna_6kjAapm-9vAVTA63Tv4ovnRaALb_V2oxbIGCPTNoAY7ui00uFcxuN2B5l4M05OFgMIcxwS9-UEVQIWbFUxvPTQLNkOp12jd73ic786lUOs7fvuwseMZ2KX9cpV03TSAN1BIwG_TJ0iOQJ_5wuyDFRqwBK8zubg-zohUPMwsLpZgc7fTVI7AhXzGLZ57fE977NsluzfjFS0smtuzN-8JTvAMnCrgTQwu5GyTiL64a3NlYcQ2qt5K6D8xOIs7xSe8i0_PlKSgG8ECMOBE3JwSCwU1q83mTPCTSGHxTaNYnPhputc6gEiPv2VYmppGrMCeG2d5oLNzGhecIaLf_PGTTSmrUUZNK6HkuybgZStgMdN5uMTXrBkEvw"; - kuksa::kuksaChannel channel; - channel.set_connectionid(1234); + KuksaChannel channel; + channel.setConnID(1234); string authReq(R"({ "action": "authorize", "requestId": "87568" @@ -1874,8 +1874,8 @@ BOOST_AUTO_TEST_CASE(permission_basic_write) string AUTH_TOKEN = "eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiJFeGFtcGxlIEpXVCIsImlzcyI6IkVjbGlwc2Uga3Vrc2EiLCJhZG1pbiI6dHJ1ZSwiaWF0IjoxNTE2MjM5MDIyLCJleHAiOjE3MDkzNzI4MDAsImt1a3NhLXZzcyI6eyJWZWhpY2xlLk9CRC5TcGVlZCI6IncifX0.KE0I1N6Izp_5k-vj8WkB23aKaPiHyrZc0jNulQHGNmwvNnJUaXp7N79-ACZPxVVI_f_MWLkanmMXHr4NqV-nIv5Tzcc4B7WMylF_DSI2kNmOqNqArQgcAgof90Z-mTDu6mdXvlIRmP0h_Zf7Bzcmp5HzgyonNpNsqjU6NZsBJbPWZZr-jWewslIt9dPVd3ZH8Q8F84bKldx2ur8oL-3bxj9CQ426TvGqT8ey-V_79IyFOMftKL0X0QcBlLhF5FwcrUBkJ2MbfJrtNL6egHqjQ70bGvYN7fj5zLTOP2dgAN-xLTFE8HhScc6f0dCi5aAZBKobU2Uw3t_soSuKr5Gx0kYStVFkW8A_TIBVdEPIT_gWogm9AqWWj9Q9ss8sp4_ozsMruXNTyhomYt6dfLtb2D7UQkkrfxB5jC2FND5j7EYiDn4ZM3qsJApXHcwY0fQEKRjon2rmFeR1kKmrp9WSLeUbOpuhRpZYJOwnTvNSQOMIWixM51AkX0JmTdHip25ffXpmBfvGmNUD-KzLanxkY0K88pcDX1qnnyjx3c75bWsg-PCWvMNyqElqTsgQxzRQ0RhIpk0LhEU1mLMO-yVWhsHqfJc9CzNJhP0Lzt5lUYKJg3NgEvmyXbx-5SxArzIqRO2KtPI5pKT-4A_y5IVQRuJu2yTwt9qkBlX0dMnfnhs"; - kuksa::kuksaChannel channel; - channel.set_connectionid(1234); + KuksaChannel channel; + channel.setConnID(1234); string authReq(R"({ "action": "authorize", @@ -1924,8 +1924,8 @@ BOOST_AUTO_TEST_CASE(permission_basic_write_not_permitted) string AUTH_TOKEN = "eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiJFeGFtcGxlIEpXVCIsImlzcyI6IkVjbGlwc2Uga3Vrc2EiLCJhZG1pbiI6dHJ1ZSwiaWF0IjoxNTE2MjM5MDIyLCJleHAiOjE5MjQ5NDg4MDAsImt1a3NhLXZzcyI6eyJWZWhpY2xlLk9CRC5TcGVlZCI6IncifX0.HOAb7fh1IRTtIXGI3GlptjIZgUYGXKkF8Zp0A2CrqhYY3-5RzuuQ4cTzc_FQfn8hRO0CzF5hARGpvECR7fMxTyKMOelnqI9DJbCL_wyHIrizOo_fZwoEt_GH5AMKawryn3XkFsyOwCl74V8coYboycCpQXKyMHfz4zXGOh6Re9iXX7eBU6U0RCxCUso1pALmMvF2PoUHlZRtFJg1VhhErRoCSu5F-dCDykd04rorbzTOsgRuzHfAXoRQVprb4NwoT99jw1qg-Su0q8LxsDUtRfxdDHBmAXJVhmTzWSwzzD6da08PLoIojyIuSPk2AWTH8u0tMz9anI13I2R4nS6ikXeg3oVaxcXcj4gTnhYfJmwx0zyThuHSJ4lEpxYMAOgP49s6jpHdSBamOiTnB4Nkrm_stCcT4bCZCZ-9bjVxXkXZe49fLVDOrg1FhGJ5sJazYZC6z7JKly8BE-FO2bQiYiMB-XD7AEgPSp61nAY_JtSQTsxa3lEBSGJJQYLqcQMZ_aLIQY0fSUjrtjG4jQpi-walriUUyP87-1SqdIV12rgvOtn1sSHm0rwGfSKf43f3HnwngbotVkWaZ7t4NvBkLU2FMrMeiG_8x5Xjq1mnZlI_K3bMRg7yAzznrrDIe3sUxP0Etnjky0CNYpeqwYGZmHNRdHAUNnWaNVGRt_tJBZc"; - kuksa::kuksaChannel channel; - channel.set_connectionid(1234); + KuksaChannel channel; + channel.setConnID(1234); string authReq(R"({ "action": "authorize", "requestId": "87568" @@ -1974,8 +1974,8 @@ BOOST_AUTO_TEST_CASE(permission_basic_write_with_wildcard_permission) string AUTH_TOKEN = "eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiJFeGFtcGxlIEpXVCIsImlzcyI6IkVjbGlwc2Uga3Vrc2EiLCJhZG1pbiI6dHJ1ZSwiaWF0IjoxNTE2MjM5MDIyLCJleHAiOjE3MDkzNzI4MDAsImt1a3NhLXZzcyI6eyJWZWhpY2xlLk9CRC4qIjoicncifX0.U4zpy38DBTx2thPWfOMKALfZovJdkr5xQWDQaGSQo6sMhG-MgDz2UZDvVyRllHiv76f2VmZ2X0TnUZ_Z6yFUmjVYq83LGzUjSDY-xFLLRqOPvFKsQbTmOLbT629uU5Pz2m6x1HcxHBVCxNvI3pZw1D_rHODkVVlgSjycDK5NaHi9EdbSDmccmwk3jI6tPag0eKC7adzBlqkt-h6vqlx_FRz7kjyhiLXmR95QIV3_0MIyq484SsU4ztMPgmHBn1VUWz0x5EW065J2BIavXpaF20oNek0ZzsGcDq-UEQOLPDFoAnYykFrcYmIlXc51wRU2Mw-IIIIs4CV9-Vp1GkQfhQCicmR3OprRepzi_C0Fdh6kwSetAYJWqlVOeo1oUIxFIYbxGFjtdG38dOaacDddBnJ93K8JlnbFdp79Ins39HCmRPit198vdf7gLRcM_GLtvGF6SbT0V2tn17CNt2UxLEniHp7hGybxBVKqgTws2H73ZLe4HEq3UU8vhbeg2V2KXeSXvDJeE3LZvDWARafyHVXrkOx8-O9HqIClfAr-LAl7nnBqq2f9DneW1hjFZOFV5RUCrJ_UpZR_hyEU_aroXO6MNw_MC6KvZeOC6ti1NO6uAB3BYHzpNP1mlyUHlfRl-oLuKZFFqFVBrxY3tBrQwgzfhPZwi427ZIwrNlfv-aU"; - kuksa::kuksaChannel channel; - channel.set_connectionid(1234); + KuksaChannel channel; + channel.setConnID(1234); string authReq(R"({ "action": "authorize", "requestId": "87568" @@ -2049,8 +2049,8 @@ BOOST_AUTO_TEST_CASE(permission_basic_write_with_branch_permission) */ string AUTH_TOKEN = "eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiJFeGFtcGxlIEpXVCIsImlzcyI6IkVjbGlwc2Uga3Vrc2EiLCJhZG1pbiI6dHJ1ZSwiaWF0IjoxNTE2MjM5MDIyLCJleHAiOjE5MjQ5NDg4MDAsImt1a3NhLXZzcyI6eyJWZWhpY2xlLk9CRCI6IncifX0.SEWdQbdA8GIbxyC_2f1vV5CB_k7JF-krXnBplROgmvG5qLhZn8QTWkfjdEpPLhsnClpc3meX-bkAJA1T25ISJGRwg5fugRBtjgbpk9sSP3grRuhQVjZSvWoajIB7sHrRkI0J9ggS7jegQpZjGnrBh0nFuEAAbCQY6ToQCYWnz5phTqO9YKZK3AZ3JfPKIqxZ0_MSrrfK_VTWtSE5TDzo8_NVu9Mmqzz_2_EcPiF5r9te-Pe_y4WsVj1WGkbXQoSlLw4b5aTk19DipQAqTS7nL-b0ce1ljuKnSE5-ksM0zMMWQ2Fh_hJyppkUi-vDBQPL4ZHTBDl33AaZnwwlNbUbWOqbuEDKmJk7jRQBfLqKkh2NsifI4wY0Bhmbm9v8-wJESItBw3AVQI1uyan9KHO5OBaH-qKnY1CcGCnNq04-BEsXT5vlVbGlFoFXzB1pw4d27oHkm73Yz2or9MxO5Uv3UPMjqRy-czIdncfewLxBzgT13owfuAP9Fm2t5YXaRpSPiki-QI4Zf02iSRETIM6l5CdSLHAdqOnujYkZjjRauhulp1nuCMQuXxotmn-Mp9OHENtSonddmXC3NtDc5WDMir9lf1NdAItEFfeS8TmeyyTiqxERmxyu8heAeKiOKYQAIrbcNgap7ggiCAjKviQfv-sQIJvFJ0gmHNN9xqQkNTg"; - kuksa::kuksaChannel channel; - channel.set_connectionid(1234); + KuksaChannel channel; + channel.setConnID(1234); string authReq(R"({ "action": "authorize", "requestId": "87568" @@ -2138,8 +2138,8 @@ BOOST_AUTO_TEST_CASE(subscription_test) */ string AUTH_TOKEN = "eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiJFeGFtcGxlIEpXVCIsImlzcyI6IkVjbGlwc2Uga3Vrc2EiLCJhZG1pbiI6dHJ1ZSwiaWF0IjoxNTE2MjM5MDIyLCJleHAiOjE2MDkzNzI4MDAsInczYy12c3MiOnsiVmVoaWNsZS5PQkQuRW5naW5lU3BlZWQiOiJ3ciIsIlZlaGljbGUuT0JELlNwZWVkIjoidyJ9fQ.R4Ulq0T84oiTJFb8scj-t4C-GnFQ0QvYVCd4glsXxiOlaNUIovZUehQwJAO5WK3b3Phz86yILuFCxNO7fsdHMmyUzNLhjiXMrL7Y2PU3gvr20EIoWYKyh52BFTH_YT6sB1EWfyhPb63_tWP0P2aa1JcXhBjAlXtmnIghjcj7KloH8MQGzKArjXa4R2NaKLH0FrO5aK8hBH3tevWp38Wae-fIypr4MgG-tXoKMt8juaE7RVDVTRiYyHJkCHjbZ0EZB9gAmy-_FyMiPxHNo8f49UtCGdBq82ZlQ_SKF6cMfH3iPw19BYG9ayIgzfEIm3HFhW8RdnxuxHzHYRtqaQKFYr37qNNk3lg4NRS3g9Mn4XA3ubi07JxBUcFl8_2ReJkcVqhua3ZiTcISkBmje6CUg1DmbH8-7SMaZhC-LJsZc8K9DBZN1cYCId7smhln5LcfjkZRh8N3d-hamrVRvfbdbee7_Ua-2SiJpWlPiIEgx65uYTV7flMgdnng0KVxv5-t_8QjySfKFruXE-HkYKN7TH8EqQA1RXuiDhj8bdFGtrB36HAlVah-cHnCCgL-p-29GceNIEoWJQT9hKWk8kQieXfJfiFUZPOxInDxHyUQEjblY049qMbU2kVSNvQ7nrmwP9OTjcXfnp7bndbstTHCGsVj1ixq8QF3tOdEGlC3Brg"; - kuksa::kuksaChannel channel; - channel.set_connectionid(1234); + KuksaChannel channel; + channel.setConnID(1234); string authReq(R"({ "action": "authorize", "requestId": "87568" @@ -2223,8 +2223,8 @@ BOOST_AUTO_TEST_CASE(subscription_test_wildcard_permission) */ string AUTH_TOKEN = "eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiJFeGFtcGxlIEpXVCIsImlzcyI6IkVjbGlwc2Uga3Vrc2EiLCJhZG1pbiI6dHJ1ZSwiaWF0IjoxNTE2MjM5MDIyLCJleHAiOjE2MDkzNzI4MDAsInczYy12c3MiOnsiVmVoaWNsZS5PQkQuKiI6InJ3In19.LLdJFIuoViNF4uVv1IL30fXPySoM1oCHxLrWm6xM_4eynvXqPvrCI9fW__GMI0d8PxBLpM8FhgG3ynVVlOuLV_Sl6lDImZlkNQiR02lJwFqf67RWVdI4f4uhdHdKjEpe0a0F-6e7McS__3qQYyjNuQAZIIXkZUIDyXye9upwNARj1wGPtZyNzSY1uyxmuc7MMPaILAIzL8ZnY_D9qgbpbiInGavZtDE_X1iy9GhxbUguP8oiVYn14-H6RBDIF0s5dXwXnJ0cm9Q2DTFpb0YRq4sMgTC4PT1Smdda_6Pj2ELmBjGbH7PYlqfVk1jVdSPGcUpU48e__qVitSRkEK_unM5CihrDVIy7nw3_KclIZJa8_af3kQ4x-leg-ErRCt78j5l0DDxIo5EtCxAeLbO7baZD6D1tPrb3vYkI_9zl1vzydp_nmNMS9QzCRq5yEJfP07gpvG0Z1O0tSLedSCG9cZJ-lJ3Oj3bqxNxk3ih6vKfjnvjAgli7wEP_etHofZmqs3NI-qtP6ldz93fBfAK_iApsSnG4PV7oS_-3UQIow6fUHAA8szn4Ad1ZYiaDsXRcHbdIoLEemGDllkRTYNBe_5vFDT3s1gY82L3fvgwAzTGZ2k46eh66Zx3SmuPgHlCQK6gR-6eAVn0jh_Tjk5vubtin6UdRjHF0Y4BvCwvE0bk"; - kuksa::kuksaChannel channel; - channel.set_connectionid(1234); + KuksaChannel channel; + channel.setConnID(1234); string authReq(R"({ "action": "authorize", "requestId": "87568" @@ -2313,8 +2313,8 @@ BOOST_AUTO_TEST_CASE(subscription_test_no_permission) */ string AUTH_TOKEN = "eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiJFeGFtcGxlIEpXVCIsImlzcyI6IkVjbGlwc2Uga3Vrc2EiLCJhZG1pbiI6dHJ1ZSwiaWF0IjoxNTE2MjM5MDIyLCJleHAiOjE5MjQ5NDg4MDAsImt1a3NhLXZzcyI6eyJWZWhpY2xlLk9CRC5FbmdpbmVTcGVlZCI6IndyIiwiVmVoaWNsZS5PQkQuU3BlZWQiOiJ3In19.ob9r5oT8R5TEtQ1ZULw2jJZpplv3-hMSd9rgFqU0CUTg-G4zhMLwegTmNDgY2EAyhOQ2LSNXK46b-ftCiVINWfnOIlNAwTmXoRNNqJ5F81aVpt8ub1aMUt0B8iKHH1Vy9sNMDrdjbB8qnNK-9SodsEafxvHAN816b81FZplA8z4S5F1gRjiCeK_tI_ZltiGYHp5FKcu25WuQosasZOUiGS7i_WFLftSn59S4lb2cBgpYIVxsGYjsnDKxc_mTNJRaCF5W5kF9zMaOR2x0sXJaZRWQnl5ioCu6tbneUF9Sb5ri1hR5m720WdNuu9iBaWbYno8QtjS8Di5L6KoIRNAcvGkAXuhLhmhSTd4ANYd9Ccc2xU6v4YWiKR4Sq3PXRvSfI-RUBuniOGi_v4Bpe8571B6EBZ3sPI3lkdgekusjqo_Man0WUc-h56ZttWsaqPVFyrSBz7uVtlcRHCwXrLaTwF-7rvNKwR5n3tIy-QG2YCQqQVr7-2934-NSADY8yTuKg-7bvv0DQv0pvNwwPjXE0Y6DSXGsk2PdujD8qai2aW5bZd9LI2WNxFqftm_t-cdicKgipzZVCzwwK9kTbpPq5KesVUymc8TIhmJynrh7lIVh-1EfvEY8T-v374kVppQ-k6aZmPphMvcWNF04x07_rw1DWxKoLIX4tTBvXiApSWo"; - kuksa::kuksaChannel channel; - channel.set_connectionid(1234); + KuksaChannel channel; + channel.setConnID(1234); string authReq(R"({ "action": "authorize", "requestId": "87568" @@ -2364,8 +2364,8 @@ BOOST_AUTO_TEST_CASE(subscription_test_invalidpath) */ string AUTH_TOKEN = "eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiJFeGFtcGxlIEpXVCIsImlzcyI6IkVjbGlwc2Uga3Vrc2EiLCJhZG1pbiI6dHJ1ZSwiaWF0IjoxNTE2MjM5MDIyLCJleHAiOjE5MjQ5NDg4MDAsImt1a3NhLXZzcyI6eyJWZWhpY2xlLk9CRC5FbmdpbmVTcGVlZCI6IndyIiwiVmVoaWNsZS5PQkQuU3BlZWQiOiJ3In19.ob9r5oT8R5TEtQ1ZULw2jJZpplv3-hMSd9rgFqU0CUTg-G4zhMLwegTmNDgY2EAyhOQ2LSNXK46b-ftCiVINWfnOIlNAwTmXoRNNqJ5F81aVpt8ub1aMUt0B8iKHH1Vy9sNMDrdjbB8qnNK-9SodsEafxvHAN816b81FZplA8z4S5F1gRjiCeK_tI_ZltiGYHp5FKcu25WuQosasZOUiGS7i_WFLftSn59S4lb2cBgpYIVxsGYjsnDKxc_mTNJRaCF5W5kF9zMaOR2x0sXJaZRWQnl5ioCu6tbneUF9Sb5ri1hR5m720WdNuu9iBaWbYno8QtjS8Di5L6KoIRNAcvGkAXuhLhmhSTd4ANYd9Ccc2xU6v4YWiKR4Sq3PXRvSfI-RUBuniOGi_v4Bpe8571B6EBZ3sPI3lkdgekusjqo_Man0WUc-h56ZttWsaqPVFyrSBz7uVtlcRHCwXrLaTwF-7rvNKwR5n3tIy-QG2YCQqQVr7-2934-NSADY8yTuKg-7bvv0DQv0pvNwwPjXE0Y6DSXGsk2PdujD8qai2aW5bZd9LI2WNxFqftm_t-cdicKgipzZVCzwwK9kTbpPq5KesVUymc8TIhmJynrh7lIVh-1EfvEY8T-v374kVppQ-k6aZmPphMvcWNF04x07_rw1DWxKoLIX4tTBvXiApSWo"; - kuksa::kuksaChannel channel; - channel.set_connectionid(1234); + KuksaChannel channel; + channel.setConnID(1234); string authReq(R"({ "action": "authorize", "requestId": "87568" @@ -2418,11 +2418,11 @@ BOOST_AUTO_TEST_CASE(process_sub_with_wildcard) std::string channelperm; perm.dump_pretty(channelperm); - kuksa::kuksaChannel channel; - channel.set_connectionid(1234); - channel.set_authorized(true); - channel.set_authtoken(AUTH_TOKEN); - channel.set_permissions(channelperm); + KuksaChannel channel; + channel.setConnID(1234); + channel.setAuthorized(true); + channel.setAuthToken(AUTH_TOKEN); + channel.setPermissions(channelperm); string request(R"({ "action": "subscribe", "path": "Vehicle.*.EngineSpeed", @@ -2464,8 +2464,8 @@ BOOST_AUTO_TEST_CASE(process_sub_without_wildcard) }*/ string AUTH_TOKEN = "eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiJFeGFtcGxlIEpXVCIsImlzcyI6IkVjbGlwc2Uga3Vrc2EiLCJhZG1pbiI6dHJ1ZSwiaWF0IjoxNTE2MjM5MDIyLCJleHAiOjE5MjQ5NDg4MDAsImt1a3NhLXZzcyI6eyJWZWhpY2xlLk9CRC5FbmdpbmVTcGVlZCI6IndyIiwiVmVoaWNsZS5PQkQuU3BlZWQiOiJ3In19.ob9r5oT8R5TEtQ1ZULw2jJZpplv3-hMSd9rgFqU0CUTg-G4zhMLwegTmNDgY2EAyhOQ2LSNXK46b-ftCiVINWfnOIlNAwTmXoRNNqJ5F81aVpt8ub1aMUt0B8iKHH1Vy9sNMDrdjbB8qnNK-9SodsEafxvHAN816b81FZplA8z4S5F1gRjiCeK_tI_ZltiGYHp5FKcu25WuQosasZOUiGS7i_WFLftSn59S4lb2cBgpYIVxsGYjsnDKxc_mTNJRaCF5W5kF9zMaOR2x0sXJaZRWQnl5ioCu6tbneUF9Sb5ri1hR5m720WdNuu9iBaWbYno8QtjS8Di5L6KoIRNAcvGkAXuhLhmhSTd4ANYd9Ccc2xU6v4YWiKR4Sq3PXRvSfI-RUBuniOGi_v4Bpe8571B6EBZ3sPI3lkdgekusjqo_Man0WUc-h56ZttWsaqPVFyrSBz7uVtlcRHCwXrLaTwF-7rvNKwR5n3tIy-QG2YCQqQVr7-2934-NSADY8yTuKg-7bvv0DQv0pvNwwPjXE0Y6DSXGsk2PdujD8qai2aW5bZd9LI2WNxFqftm_t-cdicKgipzZVCzwwK9kTbpPq5KesVUymc8TIhmJynrh7lIVh-1EfvEY8T-v374kVppQ-k6aZmPphMvcWNF04x07_rw1DWxKoLIX4tTBvXiApSWo"; - kuksa::kuksaChannel channel; - channel.set_connectionid(1234); + KuksaChannel channel; + channel.setConnID(1234); string authReq(R"({ "action": "authorize", @@ -2523,8 +2523,8 @@ BOOST_AUTO_TEST_CASE(subscription_test_invalid_wildcard) string AUTH_TOKEN = "eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiJFeGFtcGxlIEpXVCIsImlzcyI6IkVjbGlwc2Uga3Vrc2EiLCJhZG1pbiI6dHJ1ZSwiaWF0IjoxNTE2MjM5MDIyLCJleHAiOjE2MDkzNzI4MDAsInczYy12c3MiOnsiVmVoaWNsZS5PQkQuRW5naW5lU3BlZWQiOiJ3ciIsIlZlaGljbGUuT0JELlNwZWVkIjoidyJ9fQ.R4Ulq0T84oiTJFb8scj-t4C-GnFQ0QvYVCd4glsXxiOlaNUIovZUehQwJAO5WK3b3Phz86yILuFCxNO7fsdHMmyUzNLhjiXMrL7Y2PU3gvr20EIoWYKyh52BFTH_YT6sB1EWfyhPb63_tWP0P2aa1JcXhBjAlXtmnIghjcj7KloH8MQGzKArjXa4R2NaKLH0FrO5aK8hBH3tevWp38Wae-fIypr4MgG-tXoKMt8juaE7RVDVTRiYyHJkCHjbZ0EZB9gAmy-_FyMiPxHNo8f49UtCGdBq82ZlQ_SKF6cMfH3iPw19BYG9ayIgzfEIm3HFhW8RdnxuxHzHYRtqaQKFYr37qNNk3lg4NRS3g9Mn4XA3ubi07JxBUcFl8_2ReJkcVqhua3ZiTcISkBmje6CUg1DmbH8-7SMaZhC-LJsZc8K9DBZN1cYCId7smhln5LcfjkZRh8N3d-hamrVRvfbdbee7_Ua-2SiJpWlPiIEgx65uYTV7flMgdnng0KVxv5-t_8QjySfKFruXE-HkYKN7TH8EqQA1RXuiDhj8bdFGtrB36HAlVah-cHnCCgL-p-29GceNIEoWJQT9hKWk8kQieXfJfiFUZPOxInDxHyUQEjblY049qMbU2kVSNvQ7nrmwP9OTjcXfnp7bndbstTHCGsVj1ixq8QF3tOdEGlC3Brg"; - kuksa::kuksaChannel channel; - channel.set_connectionid(1234); + KuksaChannel channel; + channel.setConnID(1234); string authReq(R"({ "action": "authorize", "requestId": "878787" diff --git a/kuksa-val-server/test/unit-test/RestV1ApiHandlerTests.cpp b/kuksa-val-server/test/unit-test/RestV1ApiHandlerTests.cpp index 31fef461e..b6cf64769 100644 --- a/kuksa-val-server/test/unit-test/RestV1ApiHandlerTests.cpp +++ b/kuksa-val-server/test/unit-test/RestV1ApiHandlerTests.cpp @@ -26,7 +26,6 @@ #include #include -#include "WsChannel.hpp" #include "ILoggerMock.hpp" #include "JsonResponses.hpp" #include "exception.hpp" diff --git a/kuksa-val-server/test/unit-test/SubscriptionHandlerTests.cpp b/kuksa-val-server/test/unit-test/SubscriptionHandlerTests.cpp index 75e199fb6..6d06228d6 100644 --- a/kuksa-val-server/test/unit-test/SubscriptionHandlerTests.cpp +++ b/kuksa-val-server/test/unit-test/SubscriptionHandlerTests.cpp @@ -31,7 +31,7 @@ #include #include -#include "WsChannel.hpp" +#include "KuksaChannel.hpp" #include "ILoggerMock.hpp" #include "IVssDatabaseMock.hpp" #include "IServerMock.hpp" @@ -76,7 +76,7 @@ BOOST_FIXTURE_TEST_SUITE(SubscriptionHandlerTests, TestSuiteFixture) BOOST_AUTO_TEST_CASE(Given_SingleClient_When_SubscribeRequest_Shall_SubscribeClient) { - kuksa::kuksaChannel channel; + KuksaChannel channel; // setup @@ -115,7 +115,7 @@ BOOST_AUTO_TEST_CASE(Given_SingleClient_When_SubscribeRequest_Shall_SubscribeCli BOOST_AUTO_TEST_CASE(Given_SingleClient_When_SubscribeRequestOnDifferentPaths_Shall_SubscribeAll) { - kuksa::kuksaChannel channel; + KuksaChannel channel; unsigned paths = 4; // setup @@ -169,16 +169,16 @@ BOOST_AUTO_TEST_CASE(Given_SingleClient_When_SubscribeRequestOnDifferentPaths_Sh BOOST_AUTO_TEST_CASE(Given_MultipleClients_When_SubscribeRequestOnSinglePath_Shall_SubscribeAllClients) { - std::vector channels; + std::vector channels; unsigned clientNum = 4; // setup // add multiple channels to request subscriptions for (unsigned index = 0; index < clientNum; index++) { - kuksa::kuksaChannel ch; + KuksaChannel ch; - ch.set_connectionid(index); - ch.set_typeofconnection(kuksa::kuksaChannel_Type_WEBSOCKET_SSL); + ch.setConnID(index); + ch.setType(KuksaChannel::Type::WEBSOCKET_SSL); channels.push_back(std::move(ch)); } @@ -225,16 +225,16 @@ BOOST_AUTO_TEST_CASE(Given_MultipleClients_When_SubscribeRequestOnSinglePath_Sha BOOST_AUTO_TEST_CASE(Given_MultipleClients_When_SubscribeRequestOnDifferentPaths_Shall_SubscribeAllClients) { - std::vector channels; + std::vector channels; unsigned clientNum = 4; // setup // add multiple channels to request subscriptions for (unsigned index = 0; index < clientNum; index++) { - kuksa::kuksaChannel ch; + KuksaChannel ch; - ch.set_connectionid(index); - ch.set_typeofconnection(kuksa::kuksaChannel_Type_WEBSOCKET_SSL); + ch.setConnID(index); + ch.setType(KuksaChannel::Type::WEBSOCKET_SSL); channels.push_back(std::move(ch)); } @@ -289,7 +289,7 @@ BOOST_AUTO_TEST_CASE(Given_MultipleClients_When_SubscribeRequestOnDifferentPaths BOOST_AUTO_TEST_CASE(Given_SingleClient_When_UnsubscribeRequestOnDifferentPaths_Shall_UnsubscribeAll) { - kuksa::kuksaChannel channel; + KuksaChannel channel; unsigned paths = 4; // setup @@ -346,16 +346,16 @@ BOOST_AUTO_TEST_CASE(Given_SingleClient_When_UnsubscribeRequestOnDifferentPaths_ BOOST_AUTO_TEST_CASE(Given_MultipleClients_When_Unsubscribe_Shall_UnsubscribeAllClients) { - std::vector channels; + std::vector channels; unsigned clientNum = 4; // setup // add multiple channels to request subscriptions for (unsigned index = 0; index < clientNum; index++) { - kuksa::kuksaChannel ch; + KuksaChannel ch; - ch.set_connectionid(index); - ch.set_typeofconnection(kuksa::kuksaChannel_Type_WEBSOCKET_SSL); + ch.setConnID(index); + ch.setType(KuksaChannel::Type::WEBSOCKET_SSL); channels.push_back(std::move(ch)); } @@ -405,13 +405,13 @@ BOOST_AUTO_TEST_CASE(Given_MultipleClients_When_Unsubscribe_Shall_UnsubscribeAll BOOST_AUTO_TEST_CASE(Given_SingleClient_When_MultipleSignalsSubscribedAndUpdated_Shall_NotifyClient) { - kuksa::kuksaChannel channel; + KuksaChannel channel; jsoncons::json answer; unsigned paths = 3; // setup - channel.set_connectionid(131313); + channel.setConnID(131313); std::vector retDbListWider{"$['Vehicle']['children']['Acceleration']['children']['Vertical']", "$['Vehicle']['children']['Acceleration']['children']['Longitudinal']", @@ -477,7 +477,7 @@ BOOST_AUTO_TEST_CASE(Given_SingleClient_When_MultipleSignalsSubscribedAndUpdated MOCK_EXPECT(serverMock->SendToConnection) .once() - .with(channel.connectionid(), jsonVerify) + .with(channel.getConnID(), jsonVerify) .returns(true); BOOST_TEST(subHandler->publishForVSSPath(vsspath[index], "value", data) == 0); @@ -487,15 +487,15 @@ BOOST_AUTO_TEST_CASE(Given_SingleClient_When_MultipleSignalsSubscribedAndUpdated BOOST_AUTO_TEST_CASE(Given_MultipleClients_When_MultipleSignalsSubscribedAndUpdated_Shall_NotifyClients) { - std::vector channels; + std::vector channels; jsoncons::json answer; unsigned paths = 3; unsigned channelCount = 3; // setup for (unsigned index = 0; index < channelCount; index++) { - kuksa::kuksaChannel channel; - channel.set_connectionid(111100 + index); + KuksaChannel channel; + channel.setConnID(111100 + index); channels.push_back(std::move(channel)); } @@ -570,7 +570,7 @@ BOOST_AUTO_TEST_CASE(Given_MultipleClients_When_MultipleSignalsSubscribedAndUpda for (auto & ch : channels) { MOCK_EXPECT(serverMock->SendToConnection) .exactly(paths) - .with(ch.connectionid(), jsonVerify) + .with(ch.getConnID(), jsonVerify) .returns(true); } @@ -584,7 +584,7 @@ BOOST_AUTO_TEST_CASE(Given_MultipleClients_When_MultipleSignalsSubscribedAndUpda BOOST_AUTO_TEST_CASE(Given_MultipleClients_When_MultipleSignalsSubscribedAndUpdatedAndClientUnsubscribeAll_Shall_NotifyOnlySubscribedClients) { - std::vector channels; + std::vector channels; jsoncons::json answer; unsigned paths = 3; unsigned channelCount = 3; @@ -592,8 +592,8 @@ BOOST_AUTO_TEST_CASE(Given_MultipleClients_When_MultipleSignalsSubscribedAndUpda // setup for (unsigned index = 0; index < channelCount; index++) { - kuksa::kuksaChannel channel; - channel.set_connectionid(111100 + index); + KuksaChannel channel; + channel.setConnID(111100 + index); channels.push_back(std::move(channel)); } @@ -649,7 +649,7 @@ BOOST_AUTO_TEST_CASE(Given_MultipleClients_When_MultipleSignalsSubscribedAndUpda for (auto & ch : channels) { MOCK_EXPECT(serverMock->SendToConnection) .exactly(paths) - .with(ch.connectionid(), jsonVerify) + .with(ch.getConnID(), jsonVerify) .returns(true); } @@ -691,7 +691,7 @@ BOOST_AUTO_TEST_CASE(Given_MultipleClients_When_MultipleSignalsSubscribedAndUpda usleep(100000); // allow for subthread handler to run - BOOST_TEST(subHandler->unsubscribeAll(channels.begin()->connectionid()) == 0); + BOOST_TEST(subHandler->unsubscribeAll(channels.begin()->getConnID()) == 0); channels.erase(channels.begin()); // now prepare expectations for only left signals @@ -703,7 +703,7 @@ BOOST_AUTO_TEST_CASE(Given_MultipleClients_When_MultipleSignalsSubscribedAndUpda for (auto & ch : channels) { MOCK_EXPECT(serverMock->SendToConnection) .exactly(paths) - .with(ch.connectionid(), jsonVerify) + .with(ch.getConnID(), jsonVerify) .returns(true); } diff --git a/kuksa-val-server/test/unit-test/UpdateMetadataTest.cpp b/kuksa-val-server/test/unit-test/UpdateMetadataTest.cpp index c0090a905..0ff7d8fc8 100644 --- a/kuksa-val-server/test/unit-test/UpdateMetadataTest.cpp +++ b/kuksa-val-server/test/unit-test/UpdateMetadataTest.cpp @@ -30,7 +30,7 @@ #include "IAuthenticatorMock.hpp" #include "ILoggerMock.hpp" #include "ISubscriptionHandlerMock.hpp" -#include "WsChannel.hpp" +#include "KuksaChannel.hpp" #include "kuksa.pb.h" #include "exception.hpp" @@ -91,10 +91,10 @@ BOOST_FIXTURE_TEST_SUITE(UpdateMetadataTests, TestSuiteFixture); /* Adding to VSS tree */ BOOST_AUTO_TEST_CASE(update_metadata_change) { - kuksa::kuksaChannel channel; - channel.set_authorized(false); - channel.set_modifytree(true); - channel.set_connectionid(1); + KuksaChannel channel; + channel.setAuthorized(false); + channel.enableModifyTree(); + channel.setConnID(1); std::string updateMetadataRequestString = R"( { @@ -177,10 +177,10 @@ BOOST_AUTO_TEST_CASE(update_metadata_change) { } BOOST_AUTO_TEST_CASE(update_metadata_brokenrequest) { - kuksa::kuksaChannel channel; - channel.set_authorized(false); - channel.set_modifytree(true); - channel.set_connectionid(1); + KuksaChannel channel; + channel.setAuthorized(false); + channel.enableModifyTree(); + channel.setConnID(1); std::string updateMetadataRequestString = R"( { diff --git a/kuksa-val-server/test/unit-test/UpdateVSSTreeTest.cpp b/kuksa-val-server/test/unit-test/UpdateVSSTreeTest.cpp index 124b9fc8e..e1bbe921f 100644 --- a/kuksa-val-server/test/unit-test/UpdateVSSTreeTest.cpp +++ b/kuksa-val-server/test/unit-test/UpdateVSSTreeTest.cpp @@ -30,7 +30,7 @@ #include "IAuthenticatorMock.hpp" #include "ILoggerMock.hpp" #include "ISubscriptionHandlerMock.hpp" -#include "WsChannel.hpp" +#include "KuksaChannel.hpp" #include "exception.hpp" @@ -90,10 +90,10 @@ BOOST_FIXTURE_TEST_SUITE(UpdateVSSTreeTests, TestSuiteFixture); /* Adding to VSS tree */ BOOST_AUTO_TEST_CASE(update_vss_tree_add) { - kuksa::kuksaChannel channel; - channel.set_authorized(false); - channel.set_modifytree(true); - channel.set_connectionid(1); + KuksaChannel channel; + channel.setAuthorized(false); + channel.enableModifyTree(); + channel.setConnID(1); json metatdata = json::parse(R"( { @@ -195,10 +195,10 @@ BOOST_AUTO_TEST_CASE(update_vss_tree_add) { /* Check whether a default is applied */ BOOST_AUTO_TEST_CASE(update_vss_tree_apply_default) { - kuksa::kuksaChannel channel; - channel.set_authorized(false); - channel.set_modifytree(true); - channel.set_connectionid(1); + KuksaChannel channel; + channel.setAuthorized(false); + channel.enableModifyTree(); + channel.setConnID(1); json metatdata = json::parse(R"( { @@ -288,10 +288,10 @@ BOOST_AUTO_TEST_CASE(update_vss_tree_apply_default) { /* Override existing metadata in tree */ BOOST_AUTO_TEST_CASE(update_vss_tree_override) { - kuksa::kuksaChannel channel; - channel.set_authorized(false); - channel.set_modifytree(true); - channel.set_connectionid(1); + KuksaChannel channel; + channel.setAuthorized(false); + channel.enableModifyTree(); + channel.setConnID(1); json metatdata = json::parse(R"( { @@ -382,10 +382,10 @@ BOOST_AUTO_TEST_CASE(update_vss_tree_override) { /* Broken Request */ BOOST_AUTO_TEST_CASE(update_vss_tree_brokenrequest) { - kuksa::kuksaChannel channel; - channel.set_authorized(false); - channel.set_modifytree(true); - channel.set_connectionid(1); + KuksaChannel channel; + channel.setAuthorized(false); + channel.enableModifyTree(); + channel.setConnID(1); std::string brokenUpdateVSSTreeRequest{R"( { diff --git a/kuksa-val-server/test/unit-test/VSSTypeSanitizerTests.cpp b/kuksa-val-server/test/unit-test/VSSTypeSanitizerTests.cpp index bc6025c8d..eb68238b6 100644 --- a/kuksa-val-server/test/unit-test/VSSTypeSanitizerTests.cpp +++ b/kuksa-val-server/test/unit-test/VSSTypeSanitizerTests.cpp @@ -26,8 +26,6 @@ #include "IAuthenticatorMock.hpp" #include "ILoggerMock.hpp" #include "ISubscriptionHandlerMock.hpp" -#include "WsChannel.hpp" - #include "exception.hpp" #include "VSSPath.hpp" diff --git a/kuksa-val-server/test/unit-test/VssCommandProcessorTests.cpp b/kuksa-val-server/test/unit-test/VssCommandProcessorTests.cpp index 7e81f72f4..9460d4515 100644 --- a/kuksa-val-server/test/unit-test/VssCommandProcessorTests.cpp +++ b/kuksa-val-server/test/unit-test/VssCommandProcessorTests.cpp @@ -24,7 +24,7 @@ #include #include -#include "WsChannel.hpp" +#include "KuksaChannel.hpp" #include "ILoggerMock.hpp" #include "IVssDatabaseMock.hpp" #include "IAuthenticatorMock.hpp" @@ -81,7 +81,7 @@ BOOST_FIXTURE_TEST_SUITE(VssCommandProcessorTests, TestSuiteFixture) BOOST_AUTO_TEST_CASE(Given_ValidGetQuery_When_PathNotValid_Shall_ReturnError) { - kuksa::kuksaChannel channel; + KuksaChannel channel; jsoncons::json jsonGetRequestForSignal; jsoncons::json jsonPathNotFound; @@ -92,8 +92,8 @@ BOOST_AUTO_TEST_CASE(Given_ValidGetQuery_When_PathNotValid_Shall_ReturnError) // setup - channel.set_authorized(false); - channel.set_connectionid(1); + channel.setAuthorized(false); + channel.setConnID(1); jsonGetRequestForSignal["action"] = "get"; jsonGetRequestForSignal["path"] = path; @@ -125,7 +125,7 @@ BOOST_AUTO_TEST_CASE(Given_ValidGetQuery_When_PathNotValid_Shall_ReturnError) BOOST_AUTO_TEST_CASE(Given_ValidGetQuery_When_DBThrowsNotExpectedException_Shall_ReturnError) { - kuksa::kuksaChannel channel; + KuksaChannel channel; jsoncons::json jsonGetRequestForSignal; jsoncons::json jsonMalformedReq; @@ -137,8 +137,8 @@ BOOST_AUTO_TEST_CASE(Given_ValidGetQuery_When_DBThrowsNotExpectedException_Shall // setup - channel.set_authorized(false); - channel.set_connectionid(1); + channel.setAuthorized(false); + channel.setConnID(1); jsonGetRequestForSignal["action"] = "get"; jsonGetRequestForSignal["path"] = path; @@ -183,7 +183,7 @@ BOOST_AUTO_TEST_CASE(Given_ValidGetQuery_When_DBThrowsNotExpectedException_Shall BOOST_AUTO_TEST_CASE(Given_ValidGetQuery_When_UserNotAuthorized_Shall_ReturnError) { - kuksa::kuksaChannel channel; + KuksaChannel channel; jsoncons::json jsonGetRequestForSignal; jsoncons::json jsonNoAccess; @@ -194,8 +194,8 @@ BOOST_AUTO_TEST_CASE(Given_ValidGetQuery_When_UserNotAuthorized_Shall_ReturnErro // setup - channel.set_authorized(false); - channel.set_connectionid(1); + channel.setAuthorized(false); + channel.setConnID(1); jsonGetRequestForSignal["action"] = "get"; jsonGetRequestForSignal["path"] = path; @@ -235,7 +235,7 @@ BOOST_AUTO_TEST_CASE(Given_ValidGetQuery_When_UserNotAuthorized_Shall_ReturnErro BOOST_AUTO_TEST_CASE(Given_ValidGetQuery_When_UserAuthorized_Shall_ReturnValue) { - kuksa::kuksaChannel channel; + KuksaChannel channel; jsoncons::json jsonGetRequestForSignal; jsoncons::json jsonSignalData; @@ -248,8 +248,8 @@ BOOST_AUTO_TEST_CASE(Given_ValidGetQuery_When_UserAuthorized_Shall_ReturnValue) // setup - channel.set_authorized(true); - channel.set_connectionid(1); + channel.setAuthorized(true); + channel.setConnID(1); jsonGetRequestForSignal["action"] = "get"; jsonGetRequestForSignal["path"] = path; @@ -297,7 +297,7 @@ BOOST_AUTO_TEST_CASE(Given_ValidGetQuery_When_UserAuthorized_Shall_ReturnValue) BOOST_AUTO_TEST_CASE(Given_ValidGetQuery_When_NoValueFromDB_Shall_ReturnError) { - kuksa::kuksaChannel channel; + KuksaChannel channel; jsoncons::json jsonGetRequestForSignal; jsoncons::json jsonSignalValue; @@ -310,8 +310,8 @@ BOOST_AUTO_TEST_CASE(Given_ValidGetQuery_When_NoValueFromDB_Shall_ReturnError) // setup - channel.set_authorized(true); - channel.set_connectionid(1); + channel.setAuthorized(true); + channel.setConnID(1); jsonGetRequestForSignal["action"] = "get"; jsonGetRequestForSignal["path"] = path; @@ -351,7 +351,7 @@ BOOST_AUTO_TEST_CASE(Given_ValidGetQuery_When_NoValueFromDB_Shall_ReturnError) BOOST_AUTO_TEST_CASE(Given_ValidSetQuery_When_InvalidPath_Shall_ReturnError) { - kuksa::kuksaChannel channel; + KuksaChannel channel; jsoncons::json jsonSetRequestForSignal; jsoncons::json jsonPathNotFound; @@ -365,10 +365,10 @@ BOOST_AUTO_TEST_CASE(Given_ValidSetQuery_When_InvalidPath_Shall_ReturnError) //We need permission first, (otherwise get 403 before checking for invalid path) std::string perm = "{\"Vehicle.OBD.*\" : \"wr\"}"; - channel.set_permissions(perm); + channel.setPermissions(perm); - channel.set_authorized(true); - channel.set_connectionid(1); + channel.setAuthorized(true); + channel.setConnID(1); jsonSetRequestForSignal["action"] = "set"; jsonSetRequestForSignal["path"] = path; @@ -401,7 +401,7 @@ BOOST_AUTO_TEST_CASE(Given_ValidSetQuery_When_InvalidPath_Shall_ReturnError) BOOST_AUTO_TEST_CASE(Given_ValidSetQuery_When_ValueOutOfBound_Shall_ReturnError) { - kuksa::kuksaChannel channel; + KuksaChannel channel; jsoncons::json jsonSetRequestForSignal; jsoncons::json jsonSignalValue; @@ -410,7 +410,7 @@ BOOST_AUTO_TEST_CASE(Given_ValidSetQuery_When_ValueOutOfBound_Shall_ReturnError) // setup //We need permission first, (otherwise get 403 before checking for invalid path) std::string perm = "{\"Vehicle.OBD.*\" : \"wr\"}"; - channel.set_permissions(perm); + channel.setPermissions(perm); string requestId = "1"; int requestValue = 300; //OoB for uint8 @@ -419,8 +419,8 @@ BOOST_AUTO_TEST_CASE(Given_ValidSetQuery_When_ValueOutOfBound_Shall_ReturnError) // setup - channel.set_authorized(true); - channel.set_connectionid(1); + channel.setAuthorized(true); + channel.setConnID(1); jsonSetRequestForSignal["action"] = "set"; jsonSetRequestForSignal["path"] = path; @@ -468,7 +468,7 @@ BOOST_AUTO_TEST_CASE(Given_ValidSetQuery_When_ValueOutOfBound_Shall_ReturnError) BOOST_AUTO_TEST_CASE(Given_ValidSetQuery_When_NoPermission_Shall_ReturnError) { - kuksa::kuksaChannel channel; + KuksaChannel channel; jsoncons::json jsonSetRequestForSignal; jsoncons::json jsonSignalValue; @@ -481,8 +481,8 @@ BOOST_AUTO_TEST_CASE(Given_ValidSetQuery_When_NoPermission_Shall_ReturnError) // setup - channel.set_authorized(true); - channel.set_connectionid(1); + channel.setAuthorized(true); + channel.setConnID(1); jsonSetRequestForSignal["action"] = "set"; jsonSetRequestForSignal["path"] = path; @@ -525,7 +525,7 @@ BOOST_AUTO_TEST_CASE(Given_ValidSetQuery_When_NoPermission_Shall_ReturnError) BOOST_AUTO_TEST_CASE(Given_ValidSetQuery_When_DBThrowsNotExpectedException_Shall_ReturnError) { - kuksa::kuksaChannel channel; + KuksaChannel channel; jsoncons::json jsonSetRequestForSignal; jsoncons::json jsonSignalValue; @@ -539,9 +539,9 @@ BOOST_AUTO_TEST_CASE(Given_ValidSetQuery_When_DBThrowsNotExpectedException_Shall // setup //We need permission first, (otherwise get 403 before checking for invalid path) std::string perm = "{\"Vehicle.OBD.*\" : \"wr\"}"; - channel.set_permissions(perm); - channel.set_authorized(true); - channel.set_connectionid(1); + channel.setPermissions(perm); + channel.setAuthorized(true); + channel.setConnID(1); jsonSetRequestForSignal["action"] = "set"; jsonSetRequestForSignal["path"] = path; @@ -588,7 +588,7 @@ BOOST_AUTO_TEST_CASE(Given_ValidSetQuery_When_DBThrowsNotExpectedException_Shall BOOST_AUTO_TEST_CASE(Given_ValidSetQuery_When_UserAuthorized_Shall_UpdateValue) { - kuksa::kuksaChannel channel; + KuksaChannel channel; jsoncons::json jsonSetRequestForSignal; jsoncons::json jsonSignalValue; @@ -602,9 +602,9 @@ BOOST_AUTO_TEST_CASE(Given_ValidSetQuery_When_UserAuthorized_Shall_UpdateValue) // setup //We need permission first, (otherwise get 403 before checking for invalid path) std::string perm = "{\"Vehicle.OBD.*\" : \"wr\"}"; - channel.set_permissions(perm); - channel.set_authorized(true); - channel.set_connectionid(1); + channel.setPermissions(perm); + channel.setAuthorized(true); + channel.setConnID(1); jsonSetRequestForSignal["action"] = "set"; jsonSetRequestForSignal["path"] = path; @@ -653,7 +653,7 @@ BOOST_AUTO_TEST_CASE(Given_ValidSetQuery_When_UserAuthorized_Shall_UpdateValue) BOOST_AUTO_TEST_CASE(Given_ValidSetTargetValueQuery_When_InvalidPath_Shall_ReturnError) { - kuksa::kuksaChannel channel; + KuksaChannel channel; jsoncons::json jsonSetRequestForSignal; jsoncons::json jsonPathNotFound; @@ -667,10 +667,10 @@ BOOST_AUTO_TEST_CASE(Given_ValidSetTargetValueQuery_When_InvalidPath_Shall_Retur //We need permission first, (otherwise get 403 before checking for invalid path) std::string perm = "{\"Vehicle.OBD.*\" : \"wr\"}"; - channel.set_permissions(perm); + channel.setPermissions(perm); - channel.set_authorized(true); - channel.set_connectionid(1); + channel.setAuthorized(true); + channel.setConnID(1); jsonSetRequestForSignal["action"] = "set"; jsonSetRequestForSignal["path"] = path; @@ -703,7 +703,7 @@ BOOST_AUTO_TEST_CASE(Given_ValidSetTargetValueQuery_When_InvalidPath_Shall_Retur BOOST_AUTO_TEST_CASE(Given_ValidSetTargetValueQuery_When_Sensor_Shall_ReturnError) { - kuksa::kuksaChannel channel; + KuksaChannel channel; jsoncons::json jsonSetRequestForSignal; jsoncons::json jsonNoAccess; @@ -717,10 +717,10 @@ BOOST_AUTO_TEST_CASE(Given_ValidSetTargetValueQuery_When_Sensor_Shall_ReturnErro //We need permission first, (otherwise get 403 before checking for invalid path) std::string perm = "{\"Vehicle.*\" : \"wr\"}"; - channel.set_permissions(perm); + channel.setPermissions(perm); - channel.set_authorized(true); - channel.set_connectionid(1); + channel.setAuthorized(true); + channel.setConnID(1); jsonSetRequestForSignal["action"] = "set"; jsonSetRequestForSignal["attribute"] = "targetValue"; @@ -760,7 +760,7 @@ BOOST_AUTO_TEST_CASE(Given_ValidSetTargetValueQuery_When_Sensor_Shall_ReturnErro BOOST_AUTO_TEST_CASE(Given_ValidSetTargetValueQuery_When_Actor_Shall_Work) { - kuksa::kuksaChannel channel; + KuksaChannel channel; jsoncons::json jsonSetRequestForSignal; jsoncons::json jsonGetResponseForSignal; @@ -774,10 +774,10 @@ BOOST_AUTO_TEST_CASE(Given_ValidSetTargetValueQuery_When_Actor_Shall_Work) //We need permission first, (otherwise get 403 before checking for invalid path) std::string perm = "{\"Vehicle.*\" : \"wr\"}"; - channel.set_permissions(perm); + channel.setPermissions(perm); - channel.set_authorized(true); - channel.set_connectionid(1); + channel.setAuthorized(true); + channel.setConnID(1); jsonSetRequestForSignal["action"] = "set"; jsonSetRequestForSignal["attribute"] = "targetValue"; @@ -822,7 +822,7 @@ BOOST_AUTO_TEST_CASE(Given_ValidSetTargetValueQuery_When_Actor_Shall_Work) BOOST_AUTO_TEST_CASE(Given_ValidSubscribeQuery_When_UserAuthorized_Shall_ReturnSubscrId) { - kuksa::kuksaChannel channel; + KuksaChannel channel; jsoncons::json jsonSubscribeRequestForSignal; jsoncons::json jsonSignalValue; @@ -833,8 +833,8 @@ BOOST_AUTO_TEST_CASE(Given_ValidSubscribeQuery_When_UserAuthorized_Shall_ReturnS // setup - channel.set_authorized(true); - channel.set_connectionid(1); + channel.setAuthorized(true); + channel.setConnID(1); jsonSubscribeRequestForSignal["action"] = "subscribe"; jsonSubscribeRequestForSignal["path"] = path; @@ -869,7 +869,7 @@ BOOST_AUTO_TEST_CASE(Given_ValidSubscribeQuery_When_UserAuthorized_Shall_ReturnS BOOST_AUTO_TEST_CASE(Given_ValidSubscribeQuery_When_UserAuthorizedButSubIdZero_Shall_ReturnError) { - kuksa::kuksaChannel channel; + KuksaChannel channel; jsoncons::json jsonSubscribeRequestForSignal; jsoncons::json jsonSignalValue; @@ -880,8 +880,8 @@ BOOST_AUTO_TEST_CASE(Given_ValidSubscribeQuery_When_UserAuthorizedButSubIdZero_S // setup - channel.set_authorized(true); - channel.set_connectionid(1); + channel.setAuthorized(true); + channel.setConnID(1); jsonSubscribeRequestForSignal["action"] = "subscribe"; jsonSubscribeRequestForSignal["path"] = path; @@ -919,7 +919,7 @@ BOOST_AUTO_TEST_CASE(Given_ValidSubscribeQuery_When_UserAuthorizedButSubIdZero_S BOOST_AUTO_TEST_CASE(Given_ValidSubscribeQuery_When_UserNotAuthorized_Shall_ReturnError) { - kuksa::kuksaChannel channel; + KuksaChannel channel; jsoncons::json jsonSubscribeRequestForSignal; jsoncons::json jsonNoAccess; @@ -929,8 +929,8 @@ BOOST_AUTO_TEST_CASE(Given_ValidSubscribeQuery_When_UserNotAuthorized_Shall_Retu // setup - channel.set_authorized(true); - channel.set_connectionid(1); + channel.setAuthorized(true); + channel.setConnID(1); jsonSubscribeRequestForSignal["action"] = "subscribe"; jsonSubscribeRequestForSignal["path"] = path; @@ -962,7 +962,7 @@ BOOST_AUTO_TEST_CASE(Given_ValidSubscribeQuery_When_UserNotAuthorized_Shall_Retu BOOST_AUTO_TEST_CASE(Given_ValidSubscribeQuery_When_PathNotValid_Shall_ReturnError) { - kuksa::kuksaChannel channel; + KuksaChannel channel; jsoncons::json jsonSubscribeRequestForSignal; jsoncons::json jsonPathNotFound; @@ -972,8 +972,8 @@ BOOST_AUTO_TEST_CASE(Given_ValidSubscribeQuery_When_PathNotValid_Shall_ReturnErr // setup - channel.set_authorized(true); - channel.set_connectionid(1); + channel.setAuthorized(true); + channel.setConnID(1); jsonSubscribeRequestForSignal["action"] = "subscribe"; jsonSubscribeRequestForSignal["path"] = path; @@ -1006,7 +1006,7 @@ BOOST_AUTO_TEST_CASE(Given_ValidSubscribeQuery_When_PathNotValid_Shall_ReturnErr BOOST_AUTO_TEST_CASE(Given_ValidSubscribeQuery_When_OutOfBounds_Shall_ReturnError) { - kuksa::kuksaChannel channel; + KuksaChannel channel; jsoncons::json jsonSubscribeRequestForSignal; jsoncons::json jsonOutOfBound; @@ -1016,8 +1016,8 @@ BOOST_AUTO_TEST_CASE(Given_ValidSubscribeQuery_When_OutOfBounds_Shall_ReturnErro // setup - channel.set_authorized(true); - channel.set_connectionid(1); + channel.setAuthorized(true); + channel.setConnID(1); jsonSubscribeRequestForSignal["action"] = "subscribe"; jsonSubscribeRequestForSignal["path"] = path; @@ -1049,7 +1049,7 @@ BOOST_AUTO_TEST_CASE(Given_ValidSubscribeQuery_When_OutOfBounds_Shall_ReturnErro BOOST_AUTO_TEST_CASE(Given_ValidSubscribeQuery_When_SubHandlerThrowsNotExpectedException_Shall_ReturnError) { - kuksa::kuksaChannel channel; + KuksaChannel channel; jsoncons::json jsonSubscribeRequestForSignal; jsoncons::json jsonMalformedReq; @@ -1059,8 +1059,8 @@ BOOST_AUTO_TEST_CASE(Given_ValidSubscribeQuery_When_SubHandlerThrowsNotExpectedE // setup - channel.set_authorized(true); - channel.set_connectionid(1); + channel.setAuthorized(true); + channel.setConnID(1); jsonSubscribeRequestForSignal["action"] = "subscribe"; jsonSubscribeRequestForSignal["path"] = path; @@ -1095,7 +1095,7 @@ BOOST_AUTO_TEST_CASE(Given_ValidSubscribeQuery_When_SubHandlerThrowsNotExpectedE BOOST_AUTO_TEST_CASE(Given_ValidUnsubscribeQuery_When_UserAuthorized_Shall_Unsubscribe) { - kuksa::kuksaChannel channel; + KuksaChannel channel; jsoncons::json jsonUnsubscribeRequestForSignal; jsoncons::json jsonSignalValue; @@ -1105,8 +1105,8 @@ BOOST_AUTO_TEST_CASE(Given_ValidUnsubscribeQuery_When_UserAuthorized_Shall_Unsub // setup - channel.set_authorized(true); - channel.set_connectionid(1); + channel.setAuthorized(true); + channel.setConnID(1); jsonUnsubscribeRequestForSignal["action"] = "unsubscribe"; jsonUnsubscribeRequestForSignal["subscriptionId"] = boost::uuids::to_string(subscriptionId); @@ -1140,7 +1140,7 @@ BOOST_AUTO_TEST_CASE(Given_ValidUnsubscribeQuery_When_UserAuthorized_Shall_Unsub BOOST_AUTO_TEST_CASE(Given_ValidUnsubscribeQuery_When_Error_Shall_ReturnError) { - kuksa::kuksaChannel channel; + KuksaChannel channel; jsoncons::json jsonUnsubscribeRequestForSignal; jsoncons::json jsonSignalValue, jsonSignalValueErr; @@ -1150,8 +1150,8 @@ BOOST_AUTO_TEST_CASE(Given_ValidUnsubscribeQuery_When_Error_Shall_ReturnError) // setup - channel.set_authorized(true); - channel.set_connectionid(1); + channel.setAuthorized(true); + channel.setConnID(1); jsonUnsubscribeRequestForSignal["action"] = "unsubscribe"; jsonUnsubscribeRequestForSignal["subscriptionId"] = boost::uuids::to_string(subscriptionId); @@ -1188,7 +1188,7 @@ BOOST_AUTO_TEST_CASE(Given_ValidUnsubscribeQuery_When_Error_Shall_ReturnError) BOOST_AUTO_TEST_CASE(Given_MalformedUUD_In_Unsubscribe) { - kuksa::kuksaChannel channel; + KuksaChannel channel; jsoncons::json jsonUnsubscribeRequestForSignal; jsoncons::json jsonSignalValue, jsonSignalValueErr; @@ -1198,8 +1198,8 @@ BOOST_AUTO_TEST_CASE(Given_MalformedUUD_In_Unsubscribe) // setup - channel.set_authorized(true); - channel.set_connectionid(1); + channel.setAuthorized(true); + channel.setConnID(1); jsonUnsubscribeRequestForSignal["action"] = "unsubscribe"; jsonUnsubscribeRequestForSignal["subscriptionId"] = "definitely-not-an-uuid"; @@ -1239,7 +1239,7 @@ BOOST_AUTO_TEST_CASE(Given_MalformedUUD_In_Unsubscribe) BOOST_AUTO_TEST_CASE(Given_ValidGetMetadataQuery_When_UserAuthorized_Shall_GetMetadata) { - kuksa::kuksaChannel channel; + KuksaChannel channel; jsoncons::json jsonGetMetaRequest; jsoncons::json jsonValue, jsonMetadata; @@ -1250,8 +1250,8 @@ BOOST_AUTO_TEST_CASE(Given_ValidGetMetadataQuery_When_UserAuthorized_Shall_GetMe // setup - channel.set_authorized(true); - channel.set_connectionid(1); + channel.setAuthorized(true); + channel.setConnID(1); jsonGetMetaRequest["action"] = "getMetaData"; jsonGetMetaRequest["requestId"] = requestId; @@ -1290,7 +1290,7 @@ BOOST_AUTO_TEST_CASE(Given_ValidGetMetadataQuery_When_UserAuthorized_Shall_GetMe BOOST_AUTO_TEST_CASE(Given_ValidAuthJson_When_TokenValid_Shall_Authorize) { - kuksa::kuksaChannel channel; + KuksaChannel channel; jsoncons::json jsonAuthRequest; jsoncons::json jsonValue, jsonMetadata; @@ -1301,8 +1301,8 @@ BOOST_AUTO_TEST_CASE(Given_ValidAuthJson_When_TokenValid_Shall_Authorize) // setup - channel.set_authorized(false); - channel.set_connectionid(1); + channel.setAuthorized(false); + channel.setConnID(1); jsonAuthRequest["action"] = "authorize"; jsonAuthRequest["requestId"] = requestId; @@ -1338,7 +1338,7 @@ BOOST_AUTO_TEST_CASE(Given_ValidAuthJson_When_TokenValid_Shall_Authorize) BOOST_AUTO_TEST_CASE(Given_ValidAuthJson_When_TokenInvalid_Shall_ReturnError) { - kuksa::kuksaChannel channel; + KuksaChannel channel; jsoncons::json jsonAuthRequest; jsoncons::json jsonValue, jsonValueErr; @@ -1349,8 +1349,8 @@ BOOST_AUTO_TEST_CASE(Given_ValidAuthJson_When_TokenInvalid_Shall_ReturnError) // setup - channel.set_authorized(true); - channel.set_connectionid(1); + channel.setAuthorized(true); + channel.setConnID(1); jsonAuthRequest["action"] = "authorize"; jsonAuthRequest["requestId"] = requestId; @@ -1392,7 +1392,7 @@ BOOST_AUTO_TEST_CASE(Given_ValidAuthJson_When_TokenInvalid_Shall_ReturnError) BOOST_AUTO_TEST_CASE(Given_JsonStrings_When_processQuery_Shall_HandleCorrectlyErrors) { - kuksa::kuksaChannel channel; + KuksaChannel channel; jsoncons::json jsonRequest; jsoncons::json jsonExpected, jsonValueErr; diff --git a/kuksa-val-server/test/unit-test/VssDatabaseTests.cpp b/kuksa-val-server/test/unit-test/VssDatabaseTests.cpp index 66aff98e9..fe8921fcb 100644 --- a/kuksa-val-server/test/unit-test/VssDatabaseTests.cpp +++ b/kuksa-val-server/test/unit-test/VssDatabaseTests.cpp @@ -21,7 +21,6 @@ #include #include -#include "WsChannel.hpp" #include "ILoggerMock.hpp" #include "IAccessCheckerMock.hpp" #include "ISubscriptionHandlerMock.hpp" @@ -120,10 +119,10 @@ BOOST_AUTO_TEST_CASE(Given_ValidVssFilename_When_GetMetadataForInvalidPath_Shall BOOST_AUTO_TEST_CASE(Given_ValidVssFilenameAndChannelAuthorized_When_updateMetadata) { jsoncons::json newMetaData, returnJson; - kuksa::kuksaChannel channel; + KuksaChannel channel; - channel.set_connectionid(11); - channel.set_authorized(true); + channel.setConnID(11); + channel.setAuthorized(true); // setup db->initJsonTree(validFilename); @@ -137,10 +136,10 @@ BOOST_AUTO_TEST_CASE(Given_ValidVssFilenameAndChannelAuthorized_When_updateMetad } BOOST_AUTO_TEST_CASE(Given_ValidVssFilename_When_updateMetadataForInvalidPath_Shall_throwException) { jsoncons::json newMetaData, returnJson; - kuksa::kuksaChannel channel; + KuksaChannel channel; - channel.set_connectionid(11); - channel.set_modifytree(true); + channel.setConnID(11); + channel.enableModifyTree(); // setup db->initJsonTree(validFilename); @@ -154,10 +153,10 @@ BOOST_AUTO_TEST_CASE(Given_ValidVssFilename_When_updateMetadataForInvalidPath_Sh } BOOST_AUTO_TEST_CASE(Given_ValidVssFilename_When_updateMetadataValidPath) { jsoncons::json newMetaData, returnJson; - kuksa::kuksaChannel channel; + KuksaChannel channel; - channel.set_connectionid(11); - channel.set_modifytree(true); + channel.setConnID(11); + channel.enableModifyTree(); // setup db->initJsonTree(validFilename); diff --git a/kuksa-val-server/test/unit-test/kuksa_grpc_client_mock.cpp b/kuksa-val-server/test/unit-test/kuksa_grpc_client_mock.cpp deleted file mode 100644 index 8b1378917..000000000 --- a/kuksa-val-server/test/unit-test/kuksa_grpc_client_mock.cpp +++ /dev/null @@ -1 +0,0 @@ -