test: add golden parity tests for the v1 API

Pin every endpoint's behaviour with golden fixtures captured from the
retiring grpc-gateway (timestamps and secrets neutralised). Error cases
assert their HTTP status independently of the golden via assertStatus, so
a blind regenerate cannot re-pin a wrong code; HEADSCALE_UPDATE_GOLDEN
rewrites the fixtures. A unit test exercises the API-key auth middleware
on the real server router. Exclude the emitted spec and goldens from
pre-commit checks.
This commit is contained in:
Kristoffer Dalby committed 2026-06-19 15:21:00 +02:00
1 parent c9bbb5bdec
commit 1572ac551d
90 files changed
+2495 -2

No files matched your search

@@ -0,0 +1,4 @@
{
"status": 400,
"body": null
}
@@ -0,0 +1,4 @@
{
"status": 400,
"body": null
}
@@ -0,0 +1,4 @@
{
"status": 404,
"body": null
}
@@ -0,0 +1,4 @@
{
"status": 400,
"body": null
}
@@ -0,0 +1,4 @@
{
"status": 400,
"body": null
}
@@ -0,0 +1,4 @@
{
"status": 200,
"body": {}
}
@@ -0,0 +1,4 @@
{
"status": 200,
"body": {}
}
@@ -0,0 +1,4 @@
{
"status": 400,
"body": null
}
@@ -0,0 +1,4 @@
{
"status": 404,
"body": null
}
@@ -0,0 +1,6 @@
{
"status": 200,
"body": {
"apiKeys": []
}
}
@@ -0,0 +1,14 @@
{
"status": 200,
"body": {
"apiKeys": [
{
"createdAt": "\u003ctimestamp\u003e",
"expiration": null,
"id": "1",
"lastSeen": null,
"prefix": "\u003csecret\u003e"
}
]
}
}
@@ -0,0 +1,21 @@
{
"status": 200,
"body": {
"apiKeys": [
{
"createdAt": "\u003ctimestamp\u003e",
"expiration": null,
"id": "1",
"lastSeen": null,
"prefix": "\u003csecret\u003e"
},
{
"createdAt": "\u003ctimestamp\u003e",
"expiration": null,
"id": "2",
"lastSeen": null,
"prefix": "\u003csecret\u003e"
}
]
}
}
@@ -0,0 +1,14 @@
{
"status": 200,
"body": {
"apiKeys": [
{
"createdAt": "\u003ctimestamp\u003e",
"expiration": "\u003ctimestamp\u003e",
"id": "1",
"lastSeen": null,
"prefix": "\u003csecret\u003e"
}
]
}
}
@@ -0,0 +1,4 @@
{
"status": 400,
"body": null
}
@@ -0,0 +1,4 @@
{
"status": 404,
"body": null
}
@@ -0,0 +1,34 @@
{
"status": 200,
"body": {
"node": {
"approvedRoutes": [],
"availableRoutes": [],
"createdAt": "\u003ctimestamp\u003e",
"discoKey": "\u003csecret\u003e",
"expiry": null,
"givenName": "regnode",
"id": "1",
"ipAddresses": [],
"lastSeen": "\u003ctimestamp\u003e",
"machineKey": "\u003csecret\u003e",
"name": "regnode",
"nodeKey": "\u003csecret\u003e",
"online": false,
"preAuthKey": null,
"registerMethod": "REGISTER_METHOD_CLI",
"subnetRoutes": [],
"tags": [],
"user": {
"createdAt": "\u003ctimestamp\u003e",
"displayName": "",
"email": "",
"id": "1",
"name": "alice",
"profilePicUrl": "",
"provider": "",
"providerId": ""
}
}
}
}
@@ -0,0 +1,4 @@
{
"status": 400,
"body": null
}
@@ -0,0 +1,4 @@
{
"status": 404,
"body": null
}
@@ -0,0 +1,4 @@
{
"status": 404,
"body": null
}
@@ -0,0 +1,4 @@
{
"status": 400,
"body": null
}
@@ -0,0 +1,4 @@
{
"status": 404,
"body": null
}
@@ -0,0 +1,4 @@
{
"status": 400,
"body": null
}
@@ -0,0 +1,4 @@
{
"status": 400,
"body": null
}
@@ -0,0 +1,4 @@
{
"status": 400,
"body": null
}
@@ -0,0 +1,4 @@
{
"status": 404,
"body": null
}
@@ -0,0 +1,4 @@
{
"status": 409,
"body": null
}
@@ -0,0 +1,15 @@
{
"status": 200,
"body": {
"user": {
"createdAt": "\u003ctimestamp\u003e",
"displayName": "Test",
"email": "t@example.com",
"id": "1",
"name": "test",
"profilePicUrl": "",
"provider": "",
"providerId": ""
}
}
}
@@ -0,0 +1,4 @@
{
"status": 400,
"body": null
}
@@ -0,0 +1,4 @@
{
"status": 404,
"body": null
}
@@ -0,0 +1,4 @@
{
"status": 200,
"body": {}
}
@@ -0,0 +1,4 @@
{
"status": 404,
"body": null
}
@@ -0,0 +1,4 @@
{
"status": 200,
"body": {}
}
@@ -0,0 +1,4 @@
{
"status": 400,
"body": null
}
@@ -0,0 +1,4 @@
{
"status": 404,
"body": null
}
@@ -0,0 +1,4 @@
{
"status": 200,
"body": {}
}
@@ -0,0 +1,6 @@
{
"status": 200,
"body": {
"databaseConnectivity": true
}
}
@@ -0,0 +1,40 @@
{
"status": 200,
"body": {
"preAuthKeys": [
{
"aclTags": [],
"createdAt": "\u003ctimestamp\u003e",
"ephemeral": false,
"expiration": "\u003ctimestamp\u003e",
"id": "1",
"key": "\u003csecret\u003e",
"reusable": true,
"used": false,
"user": {
"createdAt": "\u003ctimestamp\u003e",
"displayName": "",
"email": "",
"id": "1",
"name": "alice",
"profilePicUrl": "",
"provider": "",
"providerId": ""
}
},
{
"aclTags": [
"tag:test"
],
"createdAt": "\u003ctimestamp\u003e",
"ephemeral": true,
"expiration": "\u003ctimestamp\u003e",
"id": "2",
"key": "\u003csecret\u003e",
"reusable": false,
"used": false,
"user": null
}
]
}
}
@@ -0,0 +1,6 @@
{
"status": 200,
"body": {
"preAuthKeys": []
}
}
@@ -0,0 +1,37 @@
{
"status": 200,
"body": {
"users": [
{
"createdAt": "\u003ctimestamp\u003e",
"displayName": "",
"email": "",
"id": "1",
"name": "alice",
"profilePicUrl": "",
"provider": "",
"providerId": ""
},
{
"createdAt": "\u003ctimestamp\u003e",
"displayName": "",
"email": "",
"id": "2",
"name": "bob",
"profilePicUrl": "",
"provider": "",
"providerId": ""
},
{
"createdAt": "\u003ctimestamp\u003e",
"displayName": "",
"email": "",
"id": "3",
"name": "carol",
"profilePicUrl": "",
"provider": "",
"providerId": ""
}
]
}
}
@@ -0,0 +1,6 @@
{
"status": 200,
"body": {
"users": []
}
}
@@ -0,0 +1,17 @@
{
"status": 200,
"body": {
"users": [
{
"createdAt": "\u003ctimestamp\u003e",
"displayName": "",
"email": "",
"id": "2",
"name": "bob",
"profilePicUrl": "",
"provider": "",
"providerId": ""
}
]
}
}
@@ -0,0 +1,17 @@
{
"status": 200,
"body": {
"users": [
{
"createdAt": "\u003ctimestamp\u003e",
"displayName": "",
"email": "",
"id": "1",
"name": "alice",
"profilePicUrl": "",
"provider": "",
"providerId": ""
}
]
}
}
@@ -0,0 +1,4 @@
{
"status": 400,
"body": null
}
@@ -0,0 +1,6 @@
{
"status": 200,
"body": {
"changes": []
}
}
@@ -0,0 +1,4 @@
{
"status": 400,
"body": null
}
@@ -0,0 +1,4 @@
{
"status": 400,
"body": null
}
@@ -0,0 +1,4 @@
{
"status": 404,
"body": null
}
@@ -0,0 +1,4 @@
{
"status": 200,
"body": {}
}
@@ -0,0 +1,4 @@
{
"status": 400,
"body": null
}
@@ -0,0 +1,4 @@
{
"status": 404,
"body": null
}
@@ -0,0 +1,4 @@
{
"status": 400,
"body": null
}
@@ -0,0 +1,4 @@
{
"status": 404,
"body": null
}
@@ -0,0 +1,53 @@
{
"status": 200,
"body": {
"node": {
"approvedRoutes": [],
"availableRoutes": [],
"createdAt": "\u003ctimestamp\u003e",
"discoKey": "\u003csecret\u003e",
"expiry": null,
"givenName": "node-a",
"id": "1",
"ipAddresses": [],
"lastSeen": "\u003ctimestamp\u003e",
"machineKey": "\u003csecret\u003e",
"name": "node-a",
"nodeKey": "\u003csecret\u003e",
"online": false,
"preAuthKey": {
"aclTags": [],
"createdAt": "\u003ctimestamp\u003e",
"ephemeral": false,
"expiration": null,
"id": "1",
"key": "\u003csecret\u003e",
"reusable": false,
"used": true,
"user": {
"createdAt": "\u003ctimestamp\u003e",
"displayName": "",
"email": "",
"id": "1",
"name": "alice",
"profilePicUrl": "",
"provider": "",
"providerId": ""
}
},
"registerMethod": "REGISTER_METHOD_AUTH_KEY",
"subnetRoutes": [],
"tags": [],
"user": {
"createdAt": "\u003ctimestamp\u003e",
"displayName": "",
"email": "",
"id": "1",
"name": "alice",
"profilePicUrl": "",
"provider": "",
"providerId": ""
}
}
}
}
@@ -0,0 +1,4 @@
{
"status": 400,
"body": null
}
@@ -0,0 +1,4 @@
{
"status": 404,
"body": null
}
@@ -0,0 +1,48 @@
{
"status": 200,
"body": {
"node": {
"approvedRoutes": [],
"availableRoutes": [],
"createdAt": "\u003ctimestamp\u003e",
"discoKey": "\u003csecret\u003e",
"expiry": null,
"givenName": "node-b",
"id": "1",
"ipAddresses": [],
"lastSeen": "\u003ctimestamp\u003e",
"machineKey": "\u003csecret\u003e",
"name": "node-b",
"nodeKey": "\u003csecret\u003e",
"online": false,
"preAuthKey": {
"aclTags": [
"tag:initial"
],
"createdAt": "\u003ctimestamp\u003e",
"ephemeral": false,
"expiration": null,
"id": "1",
"key": "\u003csecret\u003e",
"reusable": false,
"used": true,
"user": {
"createdAt": "\u003ctimestamp\u003e",
"displayName": "",
"email": "",
"id": "1",
"name": "bob",
"profilePicUrl": "",
"provider": "",
"providerId": ""
}
},
"registerMethod": "REGISTER_METHOD_AUTH_KEY",
"subnetRoutes": [],
"tags": [
"tag:initial"
],
"user": null
}
}
}
@@ -0,0 +1,103 @@
{
"status": 200,
"body": {
"nodes": [
{
"approvedRoutes": [],
"availableRoutes": [],
"createdAt": "\u003ctimestamp\u003e",
"discoKey": "\u003csecret\u003e",
"expiry": null,
"givenName": "node-a",
"id": "1",
"ipAddresses": [],
"lastSeen": "\u003ctimestamp\u003e",
"machineKey": "\u003csecret\u003e",
"name": "node-a",
"nodeKey": "\u003csecret\u003e",
"online": false,
"preAuthKey": {
"aclTags": [],
"createdAt": "\u003ctimestamp\u003e",
"ephemeral": false,
"expiration": null,
"id": "1",
"key": "\u003csecret\u003e",
"reusable": false,
"used": true,
"user": {
"createdAt": "\u003ctimestamp\u003e",
"displayName": "",
"email": "",
"id": "1",
"name": "alice",
"profilePicUrl": "",
"provider": "",
"providerId": ""
}
},
"registerMethod": "REGISTER_METHOD_AUTH_KEY",
"subnetRoutes": [],
"tags": [],
"user": {
"createdAt": "\u003ctimestamp\u003e",
"displayName": "",
"email": "",
"id": "1",
"name": "alice",
"profilePicUrl": "",
"provider": "",
"providerId": ""
}
},
{
"approvedRoutes": [],
"availableRoutes": [],
"createdAt": "\u003ctimestamp\u003e",
"discoKey": "\u003csecret\u003e",
"expiry": null,
"givenName": "node-b",
"id": "2",
"ipAddresses": [],
"lastSeen": "\u003ctimestamp\u003e",
"machineKey": "\u003csecret\u003e",
"name": "node-b",
"nodeKey": "\u003csecret\u003e",
"online": false,
"preAuthKey": {
"aclTags": [],
"createdAt": "\u003ctimestamp\u003e",
"ephemeral": false,
"expiration": null,
"id": "2",
"key": "\u003csecret\u003e",
"reusable": false,
"used": true,
"user": {
"createdAt": "\u003ctimestamp\u003e",
"displayName": "",
"email": "",
"id": "2",
"name": "bob",
"profilePicUrl": "",
"provider": "",
"providerId": ""
}
},
"registerMethod": "REGISTER_METHOD_AUTH_KEY",
"subnetRoutes": [],
"tags": [],
"user": {
"createdAt": "\u003ctimestamp\u003e",
"displayName": "",
"email": "",
"id": "2",
"name": "bob",
"profilePicUrl": "",
"provider": "",
"providerId": ""
}
}
]
}
}
@@ -0,0 +1,6 @@
{
"status": 200,
"body": {
"nodes": []
}
}
@@ -0,0 +1,55 @@
{
"status": 200,
"body": {
"nodes": [
{
"approvedRoutes": [],
"availableRoutes": [],
"createdAt": "\u003ctimestamp\u003e",
"discoKey": "\u003csecret\u003e",
"expiry": null,
"givenName": "node-a",
"id": "1",
"ipAddresses": [],
"lastSeen": "\u003ctimestamp\u003e",
"machineKey": "\u003csecret\u003e",
"name": "node-a",
"nodeKey": "\u003csecret\u003e",
"online": false,
"preAuthKey": {
"aclTags": [],
"createdAt": "\u003ctimestamp\u003e",
"ephemeral": false,
"expiration": null,
"id": "1",
"key": "\u003csecret\u003e",
"reusable": false,
"used": true,
"user": {
"createdAt": "\u003ctimestamp\u003e",
"displayName": "",
"email": "",
"id": "1",
"name": "alice",
"profilePicUrl": "",
"provider": "",
"providerId": ""
}
},
"registerMethod": "REGISTER_METHOD_AUTH_KEY",
"subnetRoutes": [],
"tags": [],
"user": {
"createdAt": "\u003ctimestamp\u003e",
"displayName": "",
"email": "",
"id": "1",
"name": "alice",
"profilePicUrl": "",
"provider": "",
"providerId": ""
}
}
]
}
}
@@ -0,0 +1,4 @@
{
"status": 404,
"body": null
}
@@ -0,0 +1,34 @@
{
"status": 200,
"body": {
"node": {
"approvedRoutes": [],
"availableRoutes": [],
"createdAt": "\u003ctimestamp\u003e",
"discoKey": "\u003csecret\u003e",
"expiry": null,
"givenName": "registered-node",
"id": "1",
"ipAddresses": [],
"lastSeen": "\u003ctimestamp\u003e",
"machineKey": "\u003csecret\u003e",
"name": "registered-node",
"nodeKey": "\u003csecret\u003e",
"online": false,
"preAuthKey": null,
"registerMethod": "REGISTER_METHOD_CLI",
"subnetRoutes": [],
"tags": [],
"user": {
"createdAt": "\u003ctimestamp\u003e",
"displayName": "",
"email": "",
"id": "1",
"name": "alice",
"profilePicUrl": "",
"provider": "",
"providerId": ""
}
}
}
}
@@ -0,0 +1,4 @@
{
"status": 400,
"body": null
}
@@ -0,0 +1,4 @@
{
"status": 404,
"body": null
}
@@ -0,0 +1,4 @@
{
"status": 400,
"body": null
}
@@ -0,0 +1,4 @@
{
"status": 404,
"body": null
}
@@ -0,0 +1,4 @@
{
"status": 400,
"body": null
}
@@ -0,0 +1,4 @@
{
"status": 404,
"body": null
}
@@ -0,0 +1,4 @@
{
"status": 400,
"body": null
}
@@ -0,0 +1,4 @@
{
"status": 400,
"body": null
}
@@ -0,0 +1,4 @@
{
"status": 404,
"body": null
}
@@ -0,0 +1,4 @@
{
"status": 400,
"body": null
}
@@ -0,0 +1,4 @@
{
"status": 400,
"body": null
}
@@ -0,0 +1,4 @@
{
"status": 200,
"body": {}
}
@@ -0,0 +1,4 @@
{
"status": 500,
"body": null
}
@@ -0,0 +1,7 @@
{
"status": 200,
"body": {
"policy": "{\"acls\":[{\"action\":\"accept\",\"src\":[\"*\"],\"dst\":[\"*:*\"]}]}",
"updatedAt": "\u003ctimestamp\u003e"
}
}
@@ -0,0 +1,4 @@
{
"status": 400,
"body": null
}
@@ -0,0 +1,7 @@
{
"status": 200,
"body": {
"policy": "{\"acls\":[{\"action\":\"accept\",\"src\":[\"*\"],\"dst\":[\"*:*\"]}]}",
"updatedAt": "\u003ctimestamp\u003e"
}
}
@@ -0,0 +1,4 @@
{
"status": 400,
"body": null
}
@@ -0,0 +1,4 @@
{
"status": 404,
"body": null
}
@@ -0,0 +1,15 @@
{
"status": 200,
"body": {
"user": {
"createdAt": "\u003ctimestamp\u003e",
"displayName": "",
"email": "",
"id": "1",
"name": "bob",
"profilePicUrl": "",
"provider": "",
"providerId": ""
}
}
}