Commit bb2102cf authored by jan.koester's avatar jan.koester
Browse files

test

parent 9fee5541
Loading
Loading
Loading
Loading
+24 −3
Changes for tools/proxyplus-bootstrap.cpp: 24 added lines, 3 removed lines.
Original line number Diff line number Diff line
@@ -109,23 +109,44 @@ const std::vector<PermissionSpec> kPermissions = {
} // namespace

int main(int argc, char **argv) {
    if (argc < 5) {
    // --insecure may appear anywhere among the positional args; strip it out first so the
    // remaining argv indices below stay fixed regardless of where the caller put it.
    std::vector<std::string> args;
    bool tlsVerify = true;
    for (int i = 1; i < argc; ++i) {
        if (std::string(argv[i]) == "--insecure") {
            tlsVerify = false;
        } else {
            args.push_back(argv[i]);
        }
    }

    if (args.size() < 4) {
        std::cerr << "usage: " << argv[0]
                  << " <authdb-url> <admin-username> <admin-password> <data-dir>" << std::endl;
                  << " [--insecure] <authdb-url> <admin-username> <admin-password> <data-dir>"
                  << std::endl;
        std::cerr << "  --insecure  skip TLS peer verification (needed when authdb is reached"
                     " by an IP not covered by its certificate's SAN)" << std::endl;
        return 1;
    }
    std::string url = argv[1], username = argv[2], password = argv[3], dataDir = argv[4];
    std::string url = args[0], username = args[1], password = args[2], dataDir = args[3];

    authdb::client::ClientConnection con;
    con.setUrl(url);
    con.setTlsVerify(tlsVerify);
    con.setUsername(username);
    con.setUserPassword(password);
    authdb::client::Client admin(con);

    try {
        if (!admin.UserAuth()) {
            std::cerr << "authdb login failed for " << username << std::endl;
            return 1;
        }
    } catch (const std::exception &e) {
        std::cerr << "authdb login failed for " << username << ": " << e.what() << std::endl;
        return 1;
    }

    const std::string serviceClientName = "proxyplus-service";
    uuid::uuid secretSeed;