Commit 7b2c43a2 authored by jan.koester's avatar jan.koester
Browse files

test

parent 53b4bf55
Loading
Loading
Loading
Loading
+48 −0
Changes for test/test_bootstrapconfig.cpp: 48 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -108,6 +108,54 @@ proxyplus:
    }
    assert(threw);

    // tls_profiles (plural) -- SNI virtual hosting, multiple profiles on one listener
    writeFile(path, R"YAML(
proxyplus:
  node:
    id: "node-01"
    name: "proxyplus-test"
  paths:
    data: "/tmp/proxyplus_test_data"
    authdb: "http://127.0.0.1:8080/api/domain"
  http:
    listen:
      - address: "0.0.0.0"
        port: 443
        tls_profiles:
          - "www"
          - "shop"
)YAML");
    BootstrapConfig sni(path);
    auto sniListeners = sni.get().httpListeners;
    assert(sniListeners.size() == 1);
    assert(sniListeners[0].tlsProfile.empty());
    assert((sniListeners[0].tlsProfiles == std::vector<std::string>{"www", "shop"}));

    // tls_profile and tls_profiles both set -> ConfigValidationError
    writeFile(path, R"YAML(
proxyplus:
  node:
    id: "node-01"
    name: "proxyplus-test"
  paths:
    data: "/tmp/proxyplus_test_data"
    authdb: "http://127.0.0.1:8080/api/domain"
  http:
    listen:
      - address: "0.0.0.0"
        port: 443
        tls_profile: "www"
        tls_profiles:
          - "shop"
)YAML");
    threw = false;
    try {
        BootstrapConfig bad(path);
    } catch (const ConfigValidationError &) {
        threw = true;
    }
    assert(threw);

    ::remove(path.c_str());
    std::cout << "test_bootstrapconfig: OK" << std::endl;
    return 0;