Commit 926cf2a2 authored by jan.koester's avatar jan.koester
Browse files

test

parent ba8f09a9
Loading
Loading
Loading
Loading
Loading
+17 −8
Changes for src/admin.cpp: 17 added lines, 8 removed lines.
Original line number Diff line number Diff line
@@ -77,6 +77,15 @@ namespace authdb {
        json_object_put(jobj);
    }

    static std::string getRequestBody(libhttppp::HttpRequest &curreq) {
        size_t bodyLen = curreq.getContentLength();
        if (bodyLen == 0)
            bodyLen = curreq.RecvData.size();
        if (bodyLen > curreq.RecvData.size())
            throw AuthBackendError("Incomplete request body!");
        return std::string(curreq.RecvData.begin(), curreq.RecvData.begin() + bodyLen);
    }

    static AuthBackend* resolveDomain(const char *cdid, AuthBackend &adminBackend, DomainBackend &dbackend) {
        if (strcmp(cdid, "admin") == 0) {
            return &adminBackend;
@@ -506,7 +515,7 @@ namespace authdb {
            curform.parse(curreq);

            // Read JSON body
            std::string reqbody(curreq.RecvData.begin(), curreq.RecvData.end());
            std::string reqbody = getRequestBody(curreq);
            json_object *jreq = json_tokener_parse(reqbody.c_str());

            if (!jreq) throw AuthBackendError("createDomain: invalid JSON!");
@@ -695,7 +704,7 @@ namespace authdb {
            AuthBackend *backend = resolveDomain(cdid, _AdminBackend, dbackend);
            if (!backend) throw AuthBackendError("createGroup: could not resolve domain!");

            std::string reqbody(curreq.RecvData.begin(), curreq.RecvData.end());
            std::string reqbody = getRequestBody(curreq);
            json_object *jreq = json_tokener_parse(reqbody.c_str());
            if (!jreq) throw AuthBackendError("createGroup: invalid JSON!");

@@ -752,7 +761,7 @@ namespace authdb {

            uuid::uuid gid(cgid);

            std::string reqbody(curreq.RecvData.begin(), curreq.RecvData.end());
            std::string reqbody = getRequestBody(curreq);
            json_object *jreq = json_tokener_parse(reqbody.c_str());
            if (!jreq) throw AuthBackendError("editGroup: invalid JSON!");

@@ -959,7 +968,7 @@ namespace authdb {
            AuthBackend *backend = resolveDomain(cdid, _AdminBackend, dbackend);
            if (!backend) throw AuthBackendError("createGpo: could not resolve domain!");

            std::string reqbody(curreq.RecvData.begin(), curreq.RecvData.end());
            std::string reqbody = getRequestBody(curreq);
            json_object *jreq = json_tokener_parse(reqbody.c_str());
            if (!jreq) throw AuthBackendError("createGpo: invalid JSON!");

@@ -1038,7 +1047,7 @@ namespace authdb {
            size_t gppos = sizeof(authdb::AuthHeader);
            gpo.info(*backend, gpodat, gppos);

            std::string reqbody(curreq.RecvData.begin(), curreq.RecvData.end());
            std::string reqbody = getRequestBody(curreq);
            json_object *jreq = json_tokener_parse(reqbody.c_str());
            if (!jreq) throw AuthBackendError("editGpo: invalid JSON!");

@@ -1136,7 +1145,7 @@ namespace authdb {
            AuthBackend *backend = resolveDomain(cdid, _AdminBackend, dbackend);
            if (!backend) throw AuthBackendError("createClient: could not resolve domain!");

            std::string reqbody(curreq.RecvData.begin(), curreq.RecvData.end());
            std::string reqbody = getRequestBody(curreq);
            json_object *jreq = json_tokener_parse(reqbody.c_str());
            if (!jreq) throw AuthBackendError("createClient: invalid JSON!");

@@ -1202,7 +1211,7 @@ namespace authdb {
            size_t pos = sizeof(AuthHeader);
            clt.info(*backend, cldat, pos);

            std::string reqbody(curreq.RecvData.begin(), curreq.RecvData.end());
            std::string reqbody = getRequestBody(curreq);
            json_object *jreq = json_tokener_parse(reqbody.c_str());
            if (!jreq) throw AuthBackendError("editClient: invalid JSON!");

@@ -1249,7 +1258,7 @@ namespace authdb {
            AuthBackend *backend = resolveDomain(cdid, _AdminBackend, dbackend);
            if (!backend) throw AuthBackendError("import: could not resolve domain!");

            std::string reqbody(curreq.RecvData.begin(), curreq.RecvData.end());
            std::string reqbody = getRequestBody(curreq);
            json_object *jreq = json_tokener_parse(reqbody.c_str());
            if (!jreq) throw AuthBackendError("import: invalid JSON!");