From 1da6176d2411b04e6e6668d14910e05a9f253afd Mon Sep 17 00:00:00 2001 From: Andreas Eriksen Date: Thu, 9 Feb 2023 15:34:40 +0100 Subject: unit test --- .../hosted/provision/restapi/NodesV2ApiTest.java | 15 ++++ .../provision/restapi/responses/node4-wg.json | 100 +++++++++++++++++++++ 2 files changed, 115 insertions(+) create mode 100644 node-repository/src/test/java/com/yahoo/vespa/hosted/provision/restapi/responses/node4-wg.json (limited to 'node-repository/src/test/java') diff --git a/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/restapi/NodesV2ApiTest.java b/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/restapi/NodesV2ApiTest.java index 3a5960be72b..7758305deee 100644 --- a/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/restapi/NodesV2ApiTest.java +++ b/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/restapi/NodesV2ApiTest.java @@ -383,6 +383,21 @@ public class NodesV2ApiTest { } @Test + public void patch_wireguard_pubkey() throws IOException { + assertFile(new Request("http://localhost:8080/nodes/v2/node/host4.yahoo.com"), "node4.json"); + + tester.assertResponse(new Request("http://localhost:8080/nodes/v2/node/host4.yahoo.com", + Utf8.toBytes("{\"wireguardPubkey\": \"not a wg key\"}"), Request.Method.PATCH), 400, + "{\"error-code\":\"BAD_REQUEST\",\"message\":\"Could not set field 'wireguardPubkey': Wireguard key must match '^[A-Za-z0-9+/]{42}[AEIMQUYcgkosw480]=$', but got: 'not a wg key'\"}"); + + assertResponse(new Request("http://localhost:8080/nodes/v2/node/host4.yahoo.com", + Utf8.toBytes("{\"wireguardPubkey\": \"lololololololololololololololololololololoo=\"}"), Request.Method.PATCH), + "{\"message\":\"Updated host4.yahoo.com\"}"); + + assertFile(new Request("http://localhost:8080/nodes/v2/node/host4.yahoo.com"), "node4-wg.json"); + } + + @Test public void post_controller_node() throws Exception { String data = "[{\"hostname\":\"controller1.yahoo.com\", \"id\":\"fake-controller1.yahoo.com\"," + createIpAddresses("127.0.0.1") + diff --git a/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/restapi/responses/node4-wg.json b/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/restapi/responses/node4-wg.json new file mode 100644 index 00000000000..6510bdde0c8 --- /dev/null +++ b/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/restapi/responses/node4-wg.json @@ -0,0 +1,100 @@ +{ + "url": "http://localhost:8080/nodes/v2/node/host4.yahoo.com", + "id": "node4", + "state": "active", + "type": "tenant", + "hostname": "host4.yahoo.com", + "parentHostname": "dockerhost1.yahoo.com", + "flavor": "[vcpu: 1.0, memory: 4.0 Gb, disk 100.0 Gb, bandwidth: 1.0 Gbps, storage type: local, architecture: x86_64]", + "resources":{"vcpu":1.0,"memoryGb":4.0,"diskGb":100.0,"bandwidthGbps":1.0,"diskSpeed":"fast","storageType":"local","architecture":"x86_64"}, + "realResources":{"vcpu":1.0,"memoryGb":4.0,"diskGb":100.0,"bandwidthGbps":1.0,"diskSpeed":"fast","storageType":"local","architecture":"x86_64"}, + "environment": "DOCKER_CONTAINER", + "owner": { + "tenant": "tenant3", + "application": "application3", + "instance": "instance3" + }, + "membership": { + "clustertype": "content", + "clusterid": "id3", + "group": "0", + "index": 0, + "retired": false + }, + "restartGeneration": 0, + "currentRestartGeneration": 0, + "wantedDockerImage": "docker-registry.domain.tld:8080/dist/vespa:6.42.0", + "wantedVespaVersion": "6.42.0", + "requestedResources": { "vcpu":1.0, "memoryGb":4.0, "diskGb":100.0, "bandwidthGbps":1.0, "diskSpeed":"fast", "storageType":"any","architecture":"x86_64" }, + "rebootGeneration": 0, + "currentRebootGeneration": 0, + "vespaVersion": "6.41.0", + "currentDockerImage": "docker-registry.domain.tld:8080/dist/vespa:6.41.0", + "failCount": 0, + "wantToRetire": false, + "preferToRetire": false, + "wantToDeprovision": false, + "wantToRebuild": false, + "down": false, + "history": [ + { + "event": "provisioned", + "at": 123, + "agent": "system" + }, + { + "event": "readied", + "at": 123, + "agent": "system" + }, + { + "event": "reserved", + "at": 123, + "agent": "application" + }, + { + "event": "activated", + "at": 123, + "agent": "application" + } + ], + "log": [ + { + "event": "provisioned", + "at": 123, + "agent": "system" + }, + { + "event": "deallocated", + "at": 123, + "agent": "system" + }, + { + "event": "readied", + "at": 123, + "agent": "system" + }, + { + "event": "reserved", + "at": 123, + "agent": "application" + }, + { + "event": "reserved", + "at": 123, + "agent": "application" + }, + { + "event": "activated", + "at": 123, + "agent": "application" + } + ], + "ipAddresses": [ + "127.0.4.1", + "::4:1" + ], + "additionalIpAddresses": [], + "cloudAccount": "111222333444", + "wireguardPubkey": "lololololololololololololololololololololoo=" +} -- cgit v1.2.3