Skip to content
Snippets Groups Projects
Commit d1e6250c authored by Florian Spreckelsen's avatar Florian Spreckelsen
Browse files

Merge branch 'f-null-pointer-list-users' into 'dev'

F null pointer list users

See merge request !47
parents a1058f7a d166dc3a
Branches
Tags
2 merge requests!61Release 0.3.0,!47F null pointer list users
Pipeline #51781 passed
Pipeline: caosdb-julialib

#51786

    Pipeline: CaosDB Octave library

    #51785

      Pipeline: caosdb-cppinttest

      #51782

        ......@@ -10,6 +10,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
        ### Added
        - Connection::ListUsers method
        ### Changed
        - Updated dependency versions.
        ......
        ......@@ -43,6 +43,9 @@
        #include <map> // for map
        #include <memory> // for shared_ptr, unique_ptr
        #include <string> // for string, basic_string
        #ifdef BUILD_ACM
        #include <vector> // for vector
        #endif
        namespace caosdb::connection {
        #ifdef BUILD_ACM
        ......@@ -122,6 +125,11 @@ public:
        // TODO(tf) find a way to deal with this:
        // NOLINTNEXTLINE(bugprone-easily-swappable-parameters)
        auto DeleteSingleUser(const std::string &realm, const std::string &name) const -> void;
        /**
        * List known users.
        */
        auto ListUsers() const -> std::vector<User>;
        #endif
        private:
        ......
        ......@@ -15,7 +15,7 @@ pluginbase==1.0.1
        Pygments==2.13.0
        PyJWT==2.6.0
        python-dateutil==2.8.2
        PyYAML==6.0
        PyYAML==6.0.1
        requests==2.28.1
        six==1.16.0
        tqdm==4.64.1
        ......
        ......@@ -36,6 +36,9 @@
        #include <grpcpp/create_channel.h> // for CreateChannel
        #include <grpcpp/support/status.h> // for Status
        #include <string> // for string, operator+
        #ifdef BUILD_ACM
        #include <vector> // for vector
        #endif
        // IWYU pragma: no_include "net/proto2/public/repeated_field.h"
        namespace caosdb::connection {
        ......@@ -46,6 +49,8 @@ using caosdb::acm::v1alpha1::CreateSingleUserRequest;
        using caosdb::acm::v1alpha1::CreateSingleUserResponse;
        using caosdb::acm::v1alpha1::DeleteSingleUserRequest;
        using caosdb::acm::v1alpha1::DeleteSingleUserResponse;
        using caosdb::acm::v1alpha1::ListUsersRequest;
        using caosdb::acm::v1alpha1::ListUsersResponse;
        using caosdb::acm::v1alpha1::RetrieveSingleUserRequest;
        using caosdb::acm::v1alpha1::RetrieveSingleUserResponse;
        #endif
        ......@@ -204,6 +209,37 @@ auto Connection::CreateSingleUser(const User &user) const -> void {
        }
        status.ThrowExceptionIfError();
        }
        auto Connection::ListUsers() const -> std::vector<User> {
        ListUsersRequest request;
        ListUsersResponse response;
        grpc::ClientContext context;
        const grpc::Status grpc_status =
        this->access_controll_management_service->ListUsers(&context, request, &response);
        auto status = TransactionStatus::SUCCESS();
        if (!grpc_status.ok()) {
        switch (grpc_status.error_code()) {
        case grpc::StatusCode::UNAUTHENTICATED:
        status = TransactionStatus::AUTHENTICATION_ERROR(grpc_status.error_message());
        break;
        case grpc::StatusCode::UNAVAILABLE:
        status = TransactionStatus::CONNECTION_ERROR();
        break;
        default:
        auto error_message = grpc_status.error_message();
        status = TransactionStatus::RPC_ERROR(std::to_string(grpc_status.error_code()) + " - " +
        error_message);
        }
        }
        status.ThrowExceptionIfError();
        std::vector<User> results;
        for (auto &user : *(response.mutable_users())) {
        results.push_back(User(std::make_unique<UserImpl>(&user)));
        }
        return results;
        }
        #endif
        auto ConnectionManager::mHasConnection(const std::string &name) const -> bool {
        ......
        0% Loading or .
        You are about to add 0 people to the discussion. Proceed with caution.
        Please register or to comment