From 204fc8084cf977bb4000c6d9f1253a5e11d716f0 Mon Sep 17 00:00:00 2001 From: black Date: Fri, 6 Dec 2024 20:19:22 +0100 Subject: [PATCH] Add tests for auto_policy, perm_create_domain and perm_delete_domain --- .../test_create_token[all_subnets].yaml | 14 +- .../test_create_token[auto_policy].yaml | 158 ++++++++++++++++++ .../test_token/test_create_token[named].yaml | 14 +- .../test_create_token[no_auto_policy].yaml | 158 ++++++++++++++++++ ...t_create_token[no_perm_create_domain].yaml | 158 ++++++++++++++++++ ...t_create_token[no_perm_delete_domain].yaml | 158 ++++++++++++++++++ ...t_create_token[no_perm_manage_tokens].yaml | 14 +- ...test_create_token[perm_create_domain].yaml | 158 ++++++++++++++++++ ...test_create_token[perm_delete_domain].yaml | 158 ++++++++++++++++++ ...test_create_token[perm_manage_tokens].yaml | 14 +- ...test_create_token[restricted_subnets].yaml | 14 +- .../test_token/test_create_token[simple].yaml | 14 +- .../test_token/test_delete_token.yaml | 10 +- .../test_token/test_list_tokens.yaml | 4 +- .../test_modify_token[auto_policy].yaml | 125 ++++++++++++++ .../test_token/test_modify_token[named].yaml | 17 +- .../test_modify_token[no_auto_policy].yaml | 125 ++++++++++++++ ...t_modify_token[no_perm_create_domain].yaml | 125 ++++++++++++++ ...t_modify_token[no_perm_delete_domain].yaml | 125 ++++++++++++++ ...t_modify_token[no_perm_manage_tokens].yaml | 17 +- ...test_modify_token[perm_create_domain].yaml | 125 ++++++++++++++ ...test_modify_token[perm_delete_domain].yaml | 125 ++++++++++++++ ...test_modify_token[perm_manage_tokens].yaml | 17 +- ...test_modify_token[restricted_subnets].yaml | 17 +- .../test_token/test_modify_token[simple].yaml | 17 +- tests/test_token.py | 50 +++++- 26 files changed, 1838 insertions(+), 93 deletions(-) create mode 100644 tests/cassettes/test_token/test_create_token[auto_policy].yaml create mode 100644 tests/cassettes/test_token/test_create_token[no_auto_policy].yaml create mode 100644 tests/cassettes/test_token/test_create_token[no_perm_create_domain].yaml create mode 100644 tests/cassettes/test_token/test_create_token[no_perm_delete_domain].yaml create mode 100644 tests/cassettes/test_token/test_create_token[perm_create_domain].yaml create mode 100644 tests/cassettes/test_token/test_create_token[perm_delete_domain].yaml create mode 100644 tests/cassettes/test_token/test_modify_token[auto_policy].yaml create mode 100644 tests/cassettes/test_token/test_modify_token[no_auto_policy].yaml create mode 100644 tests/cassettes/test_token/test_modify_token[no_perm_create_domain].yaml create mode 100644 tests/cassettes/test_token/test_modify_token[no_perm_delete_domain].yaml create mode 100644 tests/cassettes/test_token/test_modify_token[perm_create_domain].yaml create mode 100644 tests/cassettes/test_token/test_modify_token[perm_delete_domain].yaml diff --git a/tests/cassettes/test_token/test_create_token[all_subnets].yaml b/tests/cassettes/test_token/test_create_token[all_subnets].yaml index a92b241..5a30de5 100644 --- a/tests/cassettes/test_token/test_create_token[all_subnets].yaml +++ b/tests/cassettes/test_token/test_create_token[all_subnets].yaml @@ -12,7 +12,7 @@ interactions: uri: https://desec.io/api/v1/auth/tokens/ response: body: - string: '[{"id":"01234567-890a-4bcd-ef01-23456789abcd","created":"2024-01-01T00:00:00.000000Z","last_used":"2024-01-01T00:00:00.000000Z","max_age":null,"max_unused_period":null,"name":"test-main","perm_manage_tokens":true,"allowed_subnets":["0.0.0.0/0","::/0"],"is_valid":true}]' + string: '[{"id":"01234567-890a-4bcd-ef01-23456789abcd","created":"2024-01-01T00:00:00.000000Z","last_used":"2024-01-01T00:00:00.000000Z","max_age":null,"max_unused_period":null,"name":"test-main","perm_create_domain":true,"perm_delete_domain":true,"perm_manage_tokens":true,"allowed_subnets":["0.0.0.0/0","::/0"],"auto_policy":false,"is_valid":true}]' headers: Allow: - GET, POST, HEAD, OPTIONS @@ -21,7 +21,7 @@ interactions: Connection: - keep-alive Content-Length: - - '269' + - '341' Content-Type: - application/json Date: @@ -54,7 +54,7 @@ interactions: uri: https://desec.io/api/v1/auth/tokens/ response: body: - string: '{"id":"000553c2-a6d6-4f19-b8cf-e68ac740ec7b","created":"2024-01-01T00:00:00.000000Z","last_used":null,"max_age":null,"max_unused_period":null,"name":"","perm_manage_tokens":false,"allowed_subnets":["0.0.0.0/0","::/0"],"is_valid":true,"token":"rD9gp7ZpbhFKqsiDxec1phUCu81j"}' + string: '{"id":"446faa79-e268-49ac-928c-49f46c568de7","created":"2024-01-01T00:00:00.000000Z","last_used":null,"max_age":null,"max_unused_period":null,"name":"","perm_create_domain":false,"perm_delete_domain":false,"perm_manage_tokens":false,"allowed_subnets":["0.0.0.0/0","::/0"],"auto_policy":false,"is_valid":true,"token":"z8hPRrNKnU7m4KjRmqRMFpRg3oFP"}' headers: Allow: - GET, POST, HEAD, OPTIONS @@ -63,7 +63,7 @@ interactions: Connection: - keep-alive Content-Length: - - '273' + - '347' Content-Type: - application/json Date: @@ -92,7 +92,7 @@ interactions: uri: https://desec.io/api/v1/auth/tokens/ response: body: - string: '[{"id":"000553c2-a6d6-4f19-b8cf-e68ac740ec7b","created":"2024-01-01T00:00:00.000000Z","last_used":null,"max_age":null,"max_unused_period":null,"name":"","perm_manage_tokens":false,"allowed_subnets":["0.0.0.0/0","::/0"],"is_valid":true},{"id":"01234567-890a-4bcd-ef01-23456789abcd","created":"2024-01-01T00:00:00.000000Z","last_used":"2024-01-01T00:00:00.000000Z","max_age":null,"max_unused_period":null,"name":"test-main","perm_manage_tokens":true,"allowed_subnets":["0.0.0.0/0","::/0"],"is_valid":true}]' + string: '[{"id":"446faa79-e268-49ac-928c-49f46c568de7","created":"2024-01-01T00:00:00.000000Z","last_used":null,"max_age":null,"max_unused_period":null,"name":"","perm_create_domain":false,"perm_delete_domain":false,"perm_manage_tokens":false,"allowed_subnets":["0.0.0.0/0","::/0"],"auto_policy":false,"is_valid":true},{"id":"01234567-890a-4bcd-ef01-23456789abcd","created":"2024-01-01T00:00:00.000000Z","last_used":"2024-01-01T00:00:00.000000Z","max_age":null,"max_unused_period":null,"name":"test-main","perm_create_domain":true,"perm_delete_domain":true,"perm_manage_tokens":true,"allowed_subnets":["0.0.0.0/0","::/0"],"auto_policy":false,"is_valid":true}]' headers: Allow: - GET, POST, HEAD, OPTIONS @@ -101,7 +101,7 @@ interactions: Connection: - keep-alive Content-Length: - - '504' + - '650' Content-Type: - application/json Date: @@ -129,7 +129,7 @@ interactions: authorization: - Token XXXXXXXX method: DELETE - uri: https://desec.io/api/v1/auth/tokens/000553c2-a6d6-4f19-b8cf-e68ac740ec7b/ + uri: https://desec.io/api/v1/auth/tokens/446faa79-e268-49ac-928c-49f46c568de7/ response: body: string: '' diff --git a/tests/cassettes/test_token/test_create_token[auto_policy].yaml b/tests/cassettes/test_token/test_create_token[auto_policy].yaml new file mode 100644 index 0000000..fb83415 --- /dev/null +++ b/tests/cassettes/test_token/test_create_token[auto_policy].yaml @@ -0,0 +1,158 @@ +interactions: +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + authorization: + - Token XXXXXXXX + method: GET + uri: https://desec.io/api/v1/auth/tokens/ + response: + body: + string: '[{"id":"01234567-890a-4bcd-ef01-23456789abcd","created":"2024-01-01T00:00:00.000000Z","last_used":"2024-01-01T00:00:00.000000Z","max_age":null,"max_unused_period":null,"name":"test-main","perm_create_domain":true,"perm_delete_domain":true,"perm_manage_tokens":true,"allowed_subnets":["0.0.0.0/0","::/0"],"auto_policy":false,"is_valid":true}]' + headers: + Allow: + - GET, POST, HEAD, OPTIONS + Cache-Control: + - no-cache + Connection: + - keep-alive + Content-Length: + - '341' + Content-Type: + - application/json + Date: + - Mon, 01 Jan 2024 00:00:00 GMT + Expires: + - Thu, 01 Jan 1970 00:00:01 GMT + Server: + - nginx + Strict-Transport-Security: + - max-age=31536000; includeSubDomains; preload + Vary: + - origin + status: + code: 200 + message: OK +- request: + body: '{"name": "", "auto_policy": true}' + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + Content-Length: + - '33' + Content-Type: + - application/json + authorization: + - Token XXXXXXXX + method: POST + uri: https://desec.io/api/v1/auth/tokens/ + response: + body: + string: '{"id":"44f9d19e-c4d7-473c-9935-b5f6b14f3033","created":"2024-01-01T00:00:00.000000Z","last_used":null,"max_age":null,"max_unused_period":null,"name":"","perm_create_domain":false,"perm_delete_domain":false,"perm_manage_tokens":false,"allowed_subnets":["0.0.0.0/0","::/0"],"auto_policy":true,"is_valid":true,"token":"FtrXkpizj6jZmBFHanze1YYcY5Lv"}' + headers: + Allow: + - GET, POST, HEAD, OPTIONS + Cache-Control: + - no-cache + Connection: + - keep-alive + Content-Length: + - '346' + Content-Type: + - application/json + Date: + - Mon, 01 Jan 2024 00:00:00 GMT + Expires: + - Thu, 01 Jan 1970 00:00:01 GMT + Server: + - nginx + Strict-Transport-Security: + - max-age=31536000; includeSubDomains; preload + Vary: + - origin + status: + code: 201 + message: Created +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + authorization: + - Token XXXXXXXX + method: GET + uri: https://desec.io/api/v1/auth/tokens/ + response: + body: + string: '[{"id":"44f9d19e-c4d7-473c-9935-b5f6b14f3033","created":"2024-01-01T00:00:00.000000Z","last_used":null,"max_age":null,"max_unused_period":null,"name":"","perm_create_domain":false,"perm_delete_domain":false,"perm_manage_tokens":false,"allowed_subnets":["0.0.0.0/0","::/0"],"auto_policy":true,"is_valid":true},{"id":"01234567-890a-4bcd-ef01-23456789abcd","created":"2024-01-01T00:00:00.000000Z","last_used":"2024-01-01T00:00:00.000000Z","max_age":null,"max_unused_period":null,"name":"test-main","perm_create_domain":true,"perm_delete_domain":true,"perm_manage_tokens":true,"allowed_subnets":["0.0.0.0/0","::/0"],"auto_policy":false,"is_valid":true}]' + headers: + Allow: + - GET, POST, HEAD, OPTIONS + Cache-Control: + - no-cache + Connection: + - keep-alive + Content-Length: + - '649' + Content-Type: + - application/json + Date: + - Mon, 01 Jan 2024 00:00:00 GMT + Expires: + - Thu, 01 Jan 1970 00:00:01 GMT + Server: + - nginx + Strict-Transport-Security: + - max-age=31536000; includeSubDomains; preload + Vary: + - origin + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + Content-Length: + - '0' + authorization: + - Token XXXXXXXX + method: DELETE + uri: https://desec.io/api/v1/auth/tokens/44f9d19e-c4d7-473c-9935-b5f6b14f3033/ + response: + body: + string: '' + headers: + Allow: + - GET, PUT, PATCH, DELETE, HEAD, OPTIONS + Cache-Control: + - no-cache + Connection: + - keep-alive + Content-Length: + - '0' + Date: + - Mon, 01 Jan 2024 00:00:00 GMT + Expires: + - Thu, 01 Jan 1970 00:00:01 GMT + Server: + - nginx + Strict-Transport-Security: + - max-age=31536000; includeSubDomains; preload + Vary: + - origin + status: + code: 204 + message: No Content +version: 1 diff --git a/tests/cassettes/test_token/test_create_token[named].yaml b/tests/cassettes/test_token/test_create_token[named].yaml index 9797438..6b56f39 100644 --- a/tests/cassettes/test_token/test_create_token[named].yaml +++ b/tests/cassettes/test_token/test_create_token[named].yaml @@ -12,7 +12,7 @@ interactions: uri: https://desec.io/api/v1/auth/tokens/ response: body: - string: '[{"id":"01234567-890a-4bcd-ef01-23456789abcd","created":"2024-01-01T00:00:00.000000Z","last_used":"2024-01-01T00:00:00.000000Z","max_age":null,"max_unused_period":null,"name":"test-main","perm_manage_tokens":true,"allowed_subnets":["0.0.0.0/0","::/0"],"is_valid":true}]' + string: '[{"id":"01234567-890a-4bcd-ef01-23456789abcd","created":"2024-01-01T00:00:00.000000Z","last_used":"2024-01-01T00:00:00.000000Z","max_age":null,"max_unused_period":null,"name":"test-main","perm_create_domain":true,"perm_delete_domain":true,"perm_manage_tokens":true,"allowed_subnets":["0.0.0.0/0","::/0"],"auto_policy":false,"is_valid":true}]' headers: Allow: - GET, POST, HEAD, OPTIONS @@ -21,7 +21,7 @@ interactions: Connection: - keep-alive Content-Length: - - '269' + - '341' Content-Type: - application/json Date: @@ -54,7 +54,7 @@ interactions: uri: https://desec.io/api/v1/auth/tokens/ response: body: - string: '{"id":"0cafb5ef-573b-409a-9bda-47a989af3418","created":"2024-01-01T00:00:00.000000Z","last_used":null,"max_age":null,"max_unused_period":null,"name":"test-suite","perm_manage_tokens":false,"allowed_subnets":["0.0.0.0/0","::/0"],"is_valid":true,"token":"NiFoSimZ9BCD5TcQ1j2u4swUwuPL"}' + string: '{"id":"bde93c0a-5b4c-4f7c-8eca-0d995d2c61a5","created":"2024-01-01T00:00:00.000000Z","last_used":null,"max_age":null,"max_unused_period":null,"name":"test-suite","perm_create_domain":false,"perm_delete_domain":false,"perm_manage_tokens":false,"allowed_subnets":["0.0.0.0/0","::/0"],"auto_policy":false,"is_valid":true,"token":"QHUermEq31AEKydpTyHvuBSHJHfb"}' headers: Allow: - GET, POST, HEAD, OPTIONS @@ -63,7 +63,7 @@ interactions: Connection: - keep-alive Content-Length: - - '283' + - '357' Content-Type: - application/json Date: @@ -92,7 +92,7 @@ interactions: uri: https://desec.io/api/v1/auth/tokens/ response: body: - string: '[{"id":"0cafb5ef-573b-409a-9bda-47a989af3418","created":"2024-01-01T00:00:00.000000Z","last_used":null,"max_age":null,"max_unused_period":null,"name":"test-suite","perm_manage_tokens":false,"allowed_subnets":["0.0.0.0/0","::/0"],"is_valid":true},{"id":"01234567-890a-4bcd-ef01-23456789abcd","created":"2024-01-01T00:00:00.000000Z","last_used":"2024-01-01T00:00:00.000000Z","max_age":null,"max_unused_period":null,"name":"test-main","perm_manage_tokens":true,"allowed_subnets":["0.0.0.0/0","::/0"],"is_valid":true}]' + string: '[{"id":"bde93c0a-5b4c-4f7c-8eca-0d995d2c61a5","created":"2024-01-01T00:00:00.000000Z","last_used":null,"max_age":null,"max_unused_period":null,"name":"test-suite","perm_create_domain":false,"perm_delete_domain":false,"perm_manage_tokens":false,"allowed_subnets":["0.0.0.0/0","::/0"],"auto_policy":false,"is_valid":true},{"id":"01234567-890a-4bcd-ef01-23456789abcd","created":"2024-01-01T00:00:00.000000Z","last_used":"2024-01-01T00:00:00.000000Z","max_age":null,"max_unused_period":null,"name":"test-main","perm_create_domain":true,"perm_delete_domain":true,"perm_manage_tokens":true,"allowed_subnets":["0.0.0.0/0","::/0"],"auto_policy":false,"is_valid":true}]' headers: Allow: - GET, POST, HEAD, OPTIONS @@ -101,7 +101,7 @@ interactions: Connection: - keep-alive Content-Length: - - '514' + - '660' Content-Type: - application/json Date: @@ -129,7 +129,7 @@ interactions: authorization: - Token XXXXXXXX method: DELETE - uri: https://desec.io/api/v1/auth/tokens/0cafb5ef-573b-409a-9bda-47a989af3418/ + uri: https://desec.io/api/v1/auth/tokens/bde93c0a-5b4c-4f7c-8eca-0d995d2c61a5/ response: body: string: '' diff --git a/tests/cassettes/test_token/test_create_token[no_auto_policy].yaml b/tests/cassettes/test_token/test_create_token[no_auto_policy].yaml new file mode 100644 index 0000000..c8d0c78 --- /dev/null +++ b/tests/cassettes/test_token/test_create_token[no_auto_policy].yaml @@ -0,0 +1,158 @@ +interactions: +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + authorization: + - Token XXXXXXXX + method: GET + uri: https://desec.io/api/v1/auth/tokens/ + response: + body: + string: '[{"id":"3c39cad0-3f6a-45b0-9e00-8786d7133460","created":"2024-01-01T00:00:00.000000Z","last_used":null,"max_age":null,"max_unused_period":null,"name":"","perm_create_domain":false,"perm_delete_domain":false,"perm_manage_tokens":false,"allowed_subnets":["0.0.0.0/0","::/0"],"auto_policy":true,"is_valid":true},{"id":"01234567-890a-4bcd-ef01-23456789abcd","created":"2024-01-01T00:00:00.000000Z","last_used":"2024-01-01T00:00:00.000000Z","max_age":null,"max_unused_period":null,"name":"test-main","perm_create_domain":true,"perm_delete_domain":true,"perm_manage_tokens":true,"allowed_subnets":["0.0.0.0/0","::/0"],"auto_policy":false,"is_valid":true}]' + headers: + Allow: + - GET, POST, HEAD, OPTIONS + Cache-Control: + - no-cache + Connection: + - keep-alive + Content-Length: + - '649' + Content-Type: + - application/json + Date: + - Mon, 01 Jan 2024 00:00:00 GMT + Expires: + - Thu, 01 Jan 1970 00:00:01 GMT + Server: + - nginx + Strict-Transport-Security: + - max-age=31536000; includeSubDomains; preload + Vary: + - origin + status: + code: 200 + message: OK +- request: + body: '{"name": "", "auto_policy": false}' + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + Content-Length: + - '34' + Content-Type: + - application/json + authorization: + - Token XXXXXXXX + method: POST + uri: https://desec.io/api/v1/auth/tokens/ + response: + body: + string: '{"id":"9a63bd77-2eff-4784-bedd-50013ae96a0a","created":"2024-01-01T00:00:00.000000Z","last_used":null,"max_age":null,"max_unused_period":null,"name":"","perm_create_domain":false,"perm_delete_domain":false,"perm_manage_tokens":false,"allowed_subnets":["0.0.0.0/0","::/0"],"auto_policy":false,"is_valid":true,"token":"fKNuM5Uvj6YSLaxYAkvwgtoLWoWU"}' + headers: + Allow: + - GET, POST, HEAD, OPTIONS + Cache-Control: + - no-cache + Connection: + - keep-alive + Content-Length: + - '347' + Content-Type: + - application/json + Date: + - Mon, 01 Jan 2024 00:00:00 GMT + Expires: + - Thu, 01 Jan 1970 00:00:01 GMT + Server: + - nginx + Strict-Transport-Security: + - max-age=31536000; includeSubDomains; preload + Vary: + - origin + status: + code: 201 + message: Created +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + authorization: + - Token XXXXXXXX + method: GET + uri: https://desec.io/api/v1/auth/tokens/ + response: + body: + string: '[{"id":"9a63bd77-2eff-4784-bedd-50013ae96a0a","created":"2024-01-01T00:00:00.000000Z","last_used":null,"max_age":null,"max_unused_period":null,"name":"","perm_create_domain":false,"perm_delete_domain":false,"perm_manage_tokens":false,"allowed_subnets":["0.0.0.0/0","::/0"],"auto_policy":false,"is_valid":true},{"id":"3c39cad0-3f6a-45b0-9e00-8786d7133460","created":"2024-01-01T00:00:00.000000Z","last_used":null,"max_age":null,"max_unused_period":null,"name":"","perm_create_domain":false,"perm_delete_domain":false,"perm_manage_tokens":false,"allowed_subnets":["0.0.0.0/0","::/0"],"auto_policy":true,"is_valid":true},{"id":"01234567-890a-4bcd-ef01-23456789abcd","created":"2024-01-01T00:00:00.000000Z","last_used":"2024-01-01T00:00:00.000000Z","max_age":null,"max_unused_period":null,"name":"test-main","perm_create_domain":true,"perm_delete_domain":true,"perm_manage_tokens":true,"allowed_subnets":["0.0.0.0/0","::/0"],"auto_policy":false,"is_valid":true}]' + headers: + Allow: + - GET, POST, HEAD, OPTIONS + Cache-Control: + - no-cache + Connection: + - keep-alive + Content-Length: + - '958' + Content-Type: + - application/json + Date: + - Mon, 01 Jan 2024 00:00:00 GMT + Expires: + - Thu, 01 Jan 1970 00:00:01 GMT + Server: + - nginx + Strict-Transport-Security: + - max-age=31536000; includeSubDomains; preload + Vary: + - origin + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + Content-Length: + - '0' + authorization: + - Token XXXXXXXX + method: DELETE + uri: https://desec.io/api/v1/auth/tokens/9a63bd77-2eff-4784-bedd-50013ae96a0a/ + response: + body: + string: '' + headers: + Allow: + - GET, PUT, PATCH, DELETE, HEAD, OPTIONS + Cache-Control: + - no-cache + Connection: + - keep-alive + Content-Length: + - '0' + Date: + - Mon, 01 Jan 2024 00:00:00 GMT + Expires: + - Thu, 01 Jan 1970 00:00:01 GMT + Server: + - nginx + Strict-Transport-Security: + - max-age=31536000; includeSubDomains; preload + Vary: + - origin + status: + code: 204 + message: No Content +version: 1 diff --git a/tests/cassettes/test_token/test_create_token[no_perm_create_domain].yaml b/tests/cassettes/test_token/test_create_token[no_perm_create_domain].yaml new file mode 100644 index 0000000..0dfda2c --- /dev/null +++ b/tests/cassettes/test_token/test_create_token[no_perm_create_domain].yaml @@ -0,0 +1,158 @@ +interactions: +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + authorization: + - Token XXXXXXXX + method: GET + uri: https://desec.io/api/v1/auth/tokens/ + response: + body: + string: '[{"id":"01234567-890a-4bcd-ef01-23456789abcd","created":"2024-01-01T00:00:00.000000Z","last_used":"2024-01-01T00:00:00.000000Z","max_age":null,"max_unused_period":null,"name":"test-main","perm_create_domain":true,"perm_delete_domain":true,"perm_manage_tokens":true,"allowed_subnets":["0.0.0.0/0","::/0"],"auto_policy":false,"is_valid":true}]' + headers: + Allow: + - GET, POST, HEAD, OPTIONS + Cache-Control: + - no-cache + Connection: + - keep-alive + Content-Length: + - '341' + Content-Type: + - application/json + Date: + - Mon, 01 Jan 2024 00:00:00 GMT + Expires: + - Thu, 01 Jan 1970 00:00:01 GMT + Server: + - nginx + Strict-Transport-Security: + - max-age=31536000; includeSubDomains; preload + Vary: + - origin + status: + code: 200 + message: OK +- request: + body: '{"name": "", "perm_create_domain": false}' + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + Content-Length: + - '41' + Content-Type: + - application/json + authorization: + - Token XXXXXXXX + method: POST + uri: https://desec.io/api/v1/auth/tokens/ + response: + body: + string: '{"id":"27457765-0523-4cca-8049-cd3f65845685","created":"2024-01-01T00:00:00.000000Z","last_used":null,"max_age":null,"max_unused_period":null,"name":"","perm_create_domain":false,"perm_delete_domain":false,"perm_manage_tokens":false,"allowed_subnets":["0.0.0.0/0","::/0"],"auto_policy":false,"is_valid":true,"token":"VaPDcAvUYJkWSd86UecivYP14hwe"}' + headers: + Allow: + - GET, POST, HEAD, OPTIONS + Cache-Control: + - no-cache + Connection: + - keep-alive + Content-Length: + - '347' + Content-Type: + - application/json + Date: + - Mon, 01 Jan 2024 00:00:00 GMT + Expires: + - Thu, 01 Jan 1970 00:00:01 GMT + Server: + - nginx + Strict-Transport-Security: + - max-age=31536000; includeSubDomains; preload + Vary: + - origin + status: + code: 201 + message: Created +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + authorization: + - Token XXXXXXXX + method: GET + uri: https://desec.io/api/v1/auth/tokens/ + response: + body: + string: '[{"id":"27457765-0523-4cca-8049-cd3f65845685","created":"2024-01-01T00:00:00.000000Z","last_used":null,"max_age":null,"max_unused_period":null,"name":"","perm_create_domain":false,"perm_delete_domain":false,"perm_manage_tokens":false,"allowed_subnets":["0.0.0.0/0","::/0"],"auto_policy":false,"is_valid":true},{"id":"01234567-890a-4bcd-ef01-23456789abcd","created":"2024-01-01T00:00:00.000000Z","last_used":"2024-01-01T00:00:00.000000Z","max_age":null,"max_unused_period":null,"name":"test-main","perm_create_domain":true,"perm_delete_domain":true,"perm_manage_tokens":true,"allowed_subnets":["0.0.0.0/0","::/0"],"auto_policy":false,"is_valid":true}]' + headers: + Allow: + - GET, POST, HEAD, OPTIONS + Cache-Control: + - no-cache + Connection: + - keep-alive + Content-Length: + - '650' + Content-Type: + - application/json + Date: + - Mon, 01 Jan 2024 00:00:00 GMT + Expires: + - Thu, 01 Jan 1970 00:00:01 GMT + Server: + - nginx + Strict-Transport-Security: + - max-age=31536000; includeSubDomains; preload + Vary: + - origin + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + Content-Length: + - '0' + authorization: + - Token XXXXXXXX + method: DELETE + uri: https://desec.io/api/v1/auth/tokens/27457765-0523-4cca-8049-cd3f65845685/ + response: + body: + string: '' + headers: + Allow: + - GET, PUT, PATCH, DELETE, HEAD, OPTIONS + Cache-Control: + - no-cache + Connection: + - keep-alive + Content-Length: + - '0' + Date: + - Mon, 01 Jan 2024 00:00:00 GMT + Expires: + - Thu, 01 Jan 1970 00:00:01 GMT + Server: + - nginx + Strict-Transport-Security: + - max-age=31536000; includeSubDomains; preload + Vary: + - origin + status: + code: 204 + message: No Content +version: 1 diff --git a/tests/cassettes/test_token/test_create_token[no_perm_delete_domain].yaml b/tests/cassettes/test_token/test_create_token[no_perm_delete_domain].yaml new file mode 100644 index 0000000..44c77bd --- /dev/null +++ b/tests/cassettes/test_token/test_create_token[no_perm_delete_domain].yaml @@ -0,0 +1,158 @@ +interactions: +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + authorization: + - Token XXXXXXXX + method: GET + uri: https://desec.io/api/v1/auth/tokens/ + response: + body: + string: '[{"id":"01234567-890a-4bcd-ef01-23456789abcd","created":"2024-01-01T00:00:00.000000Z","last_used":"2024-01-01T00:00:00.000000Z","max_age":null,"max_unused_period":null,"name":"test-main","perm_create_domain":true,"perm_delete_domain":true,"perm_manage_tokens":true,"allowed_subnets":["0.0.0.0/0","::/0"],"auto_policy":false,"is_valid":true}]' + headers: + Allow: + - GET, POST, HEAD, OPTIONS + Cache-Control: + - no-cache + Connection: + - keep-alive + Content-Length: + - '341' + Content-Type: + - application/json + Date: + - Mon, 01 Jan 2024 00:00:00 GMT + Expires: + - Thu, 01 Jan 1970 00:00:01 GMT + Server: + - nginx + Strict-Transport-Security: + - max-age=31536000; includeSubDomains; preload + Vary: + - origin + status: + code: 200 + message: OK +- request: + body: '{"name": "", "perm_delete_domain": false}' + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + Content-Length: + - '41' + Content-Type: + - application/json + authorization: + - Token XXXXXXXX + method: POST + uri: https://desec.io/api/v1/auth/tokens/ + response: + body: + string: '{"id":"d894d7e3-ff85-47e5-84e2-2f4109d582fe","created":"2024-01-01T00:00:00.000000Z","last_used":null,"max_age":null,"max_unused_period":null,"name":"","perm_create_domain":false,"perm_delete_domain":false,"perm_manage_tokens":false,"allowed_subnets":["0.0.0.0/0","::/0"],"auto_policy":false,"is_valid":true,"token":"rEKUU799s3Rzjx3redaqZrMUL2RV"}' + headers: + Allow: + - GET, POST, HEAD, OPTIONS + Cache-Control: + - no-cache + Connection: + - keep-alive + Content-Length: + - '347' + Content-Type: + - application/json + Date: + - Mon, 01 Jan 2024 00:00:00 GMT + Expires: + - Thu, 01 Jan 1970 00:00:01 GMT + Server: + - nginx + Strict-Transport-Security: + - max-age=31536000; includeSubDomains; preload + Vary: + - origin + status: + code: 201 + message: Created +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + authorization: + - Token XXXXXXXX + method: GET + uri: https://desec.io/api/v1/auth/tokens/ + response: + body: + string: '[{"id":"d894d7e3-ff85-47e5-84e2-2f4109d582fe","created":"2024-01-01T00:00:00.000000Z","last_used":null,"max_age":null,"max_unused_period":null,"name":"","perm_create_domain":false,"perm_delete_domain":false,"perm_manage_tokens":false,"allowed_subnets":["0.0.0.0/0","::/0"],"auto_policy":false,"is_valid":true},{"id":"01234567-890a-4bcd-ef01-23456789abcd","created":"2024-01-01T00:00:00.000000Z","last_used":"2024-01-01T00:00:00.000000Z","max_age":null,"max_unused_period":null,"name":"test-main","perm_create_domain":true,"perm_delete_domain":true,"perm_manage_tokens":true,"allowed_subnets":["0.0.0.0/0","::/0"],"auto_policy":false,"is_valid":true}]' + headers: + Allow: + - GET, POST, HEAD, OPTIONS + Cache-Control: + - no-cache + Connection: + - keep-alive + Content-Length: + - '650' + Content-Type: + - application/json + Date: + - Mon, 01 Jan 2024 00:00:00 GMT + Expires: + - Thu, 01 Jan 1970 00:00:01 GMT + Server: + - nginx + Strict-Transport-Security: + - max-age=31536000; includeSubDomains; preload + Vary: + - origin + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + Content-Length: + - '0' + authorization: + - Token XXXXXXXX + method: DELETE + uri: https://desec.io/api/v1/auth/tokens/d894d7e3-ff85-47e5-84e2-2f4109d582fe/ + response: + body: + string: '' + headers: + Allow: + - GET, PUT, PATCH, DELETE, HEAD, OPTIONS + Cache-Control: + - no-cache + Connection: + - keep-alive + Content-Length: + - '0' + Date: + - Mon, 01 Jan 2024 00:00:00 GMT + Expires: + - Thu, 01 Jan 1970 00:00:01 GMT + Server: + - nginx + Strict-Transport-Security: + - max-age=31536000; includeSubDomains; preload + Vary: + - origin + status: + code: 204 + message: No Content +version: 1 diff --git a/tests/cassettes/test_token/test_create_token[no_perm_manage_tokens].yaml b/tests/cassettes/test_token/test_create_token[no_perm_manage_tokens].yaml index 8b7084c..f83bb3b 100644 --- a/tests/cassettes/test_token/test_create_token[no_perm_manage_tokens].yaml +++ b/tests/cassettes/test_token/test_create_token[no_perm_manage_tokens].yaml @@ -12,7 +12,7 @@ interactions: uri: https://desec.io/api/v1/auth/tokens/ response: body: - string: '[{"id":"01234567-890a-4bcd-ef01-23456789abcd","created":"2024-01-01T00:00:00.000000Z","last_used":"2024-01-01T00:00:00.000000Z","max_age":null,"max_unused_period":null,"name":"test-main","perm_manage_tokens":true,"allowed_subnets":["0.0.0.0/0","::/0"],"is_valid":true}]' + string: '[{"id":"01234567-890a-4bcd-ef01-23456789abcd","created":"2024-01-01T00:00:00.000000Z","last_used":"2024-01-01T00:00:00.000000Z","max_age":null,"max_unused_period":null,"name":"test-main","perm_create_domain":true,"perm_delete_domain":true,"perm_manage_tokens":true,"allowed_subnets":["0.0.0.0/0","::/0"],"auto_policy":false,"is_valid":true}]' headers: Allow: - GET, POST, HEAD, OPTIONS @@ -21,7 +21,7 @@ interactions: Connection: - keep-alive Content-Length: - - '269' + - '341' Content-Type: - application/json Date: @@ -54,7 +54,7 @@ interactions: uri: https://desec.io/api/v1/auth/tokens/ response: body: - string: '{"id":"078370da-6d23-46e9-8239-5c9c433f9ccf","created":"2024-01-01T00:00:00.000000Z","last_used":null,"max_age":null,"max_unused_period":null,"name":"","perm_manage_tokens":false,"allowed_subnets":["0.0.0.0/0","::/0"],"is_valid":true,"token":"cNzX2ZmZVAXBMN9R8aRRMTEJXjd9"}' + string: '{"id":"1ac9008f-196f-48c9-af85-9bbda3499b18","created":"2024-01-01T00:00:00.000000Z","last_used":null,"max_age":null,"max_unused_period":null,"name":"","perm_create_domain":false,"perm_delete_domain":false,"perm_manage_tokens":false,"allowed_subnets":["0.0.0.0/0","::/0"],"auto_policy":false,"is_valid":true,"token":"hA8tjcKSYosyhPFkSWn4psm4whaP"}' headers: Allow: - GET, POST, HEAD, OPTIONS @@ -63,7 +63,7 @@ interactions: Connection: - keep-alive Content-Length: - - '273' + - '347' Content-Type: - application/json Date: @@ -92,7 +92,7 @@ interactions: uri: https://desec.io/api/v1/auth/tokens/ response: body: - string: '[{"id":"078370da-6d23-46e9-8239-5c9c433f9ccf","created":"2024-01-01T00:00:00.000000Z","last_used":null,"max_age":null,"max_unused_period":null,"name":"","perm_manage_tokens":false,"allowed_subnets":["0.0.0.0/0","::/0"],"is_valid":true},{"id":"01234567-890a-4bcd-ef01-23456789abcd","created":"2024-01-01T00:00:00.000000Z","last_used":"2024-01-01T00:00:00.000000Z","max_age":null,"max_unused_period":null,"name":"test-main","perm_manage_tokens":true,"allowed_subnets":["0.0.0.0/0","::/0"],"is_valid":true}]' + string: '[{"id":"1ac9008f-196f-48c9-af85-9bbda3499b18","created":"2024-01-01T00:00:00.000000Z","last_used":null,"max_age":null,"max_unused_period":null,"name":"","perm_create_domain":false,"perm_delete_domain":false,"perm_manage_tokens":false,"allowed_subnets":["0.0.0.0/0","::/0"],"auto_policy":false,"is_valid":true},{"id":"01234567-890a-4bcd-ef01-23456789abcd","created":"2024-01-01T00:00:00.000000Z","last_used":"2024-01-01T00:00:00.000000Z","max_age":null,"max_unused_period":null,"name":"test-main","perm_create_domain":true,"perm_delete_domain":true,"perm_manage_tokens":true,"allowed_subnets":["0.0.0.0/0","::/0"],"auto_policy":false,"is_valid":true}]' headers: Allow: - GET, POST, HEAD, OPTIONS @@ -101,7 +101,7 @@ interactions: Connection: - keep-alive Content-Length: - - '504' + - '650' Content-Type: - application/json Date: @@ -129,7 +129,7 @@ interactions: authorization: - Token XXXXXXXX method: DELETE - uri: https://desec.io/api/v1/auth/tokens/078370da-6d23-46e9-8239-5c9c433f9ccf/ + uri: https://desec.io/api/v1/auth/tokens/1ac9008f-196f-48c9-af85-9bbda3499b18/ response: body: string: '' diff --git a/tests/cassettes/test_token/test_create_token[perm_create_domain].yaml b/tests/cassettes/test_token/test_create_token[perm_create_domain].yaml new file mode 100644 index 0000000..ee2fdbb --- /dev/null +++ b/tests/cassettes/test_token/test_create_token[perm_create_domain].yaml @@ -0,0 +1,158 @@ +interactions: +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + authorization: + - Token XXXXXXXX + method: GET + uri: https://desec.io/api/v1/auth/tokens/ + response: + body: + string: '[{"id":"01234567-890a-4bcd-ef01-23456789abcd","created":"2024-01-01T00:00:00.000000Z","last_used":"2024-01-01T00:00:00.000000Z","max_age":null,"max_unused_period":null,"name":"test-main","perm_create_domain":true,"perm_delete_domain":true,"perm_manage_tokens":true,"allowed_subnets":["0.0.0.0/0","::/0"],"auto_policy":false,"is_valid":true}]' + headers: + Allow: + - GET, POST, HEAD, OPTIONS + Cache-Control: + - no-cache + Connection: + - keep-alive + Content-Length: + - '341' + Content-Type: + - application/json + Date: + - Mon, 01 Jan 2024 00:00:00 GMT + Expires: + - Thu, 01 Jan 1970 00:00:01 GMT + Server: + - nginx + Strict-Transport-Security: + - max-age=31536000; includeSubDomains; preload + Vary: + - origin + status: + code: 200 + message: OK +- request: + body: '{"name": "", "perm_create_domain": true}' + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + Content-Length: + - '40' + Content-Type: + - application/json + authorization: + - Token XXXXXXXX + method: POST + uri: https://desec.io/api/v1/auth/tokens/ + response: + body: + string: '{"id":"e7671388-caeb-4a75-ab00-9a197a1d90f4","created":"2024-01-01T00:00:00.000000Z","last_used":null,"max_age":null,"max_unused_period":null,"name":"","perm_create_domain":true,"perm_delete_domain":false,"perm_manage_tokens":false,"allowed_subnets":["0.0.0.0/0","::/0"],"auto_policy":false,"is_valid":true,"token":"AL6Pb7qF5H5927a9x5Eo2ZCDp1fG"}' + headers: + Allow: + - GET, POST, HEAD, OPTIONS + Cache-Control: + - no-cache + Connection: + - keep-alive + Content-Length: + - '346' + Content-Type: + - application/json + Date: + - Mon, 01 Jan 2024 00:00:00 GMT + Expires: + - Thu, 01 Jan 1970 00:00:01 GMT + Server: + - nginx + Strict-Transport-Security: + - max-age=31536000; includeSubDomains; preload + Vary: + - origin + status: + code: 201 + message: Created +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + authorization: + - Token XXXXXXXX + method: GET + uri: https://desec.io/api/v1/auth/tokens/ + response: + body: + string: '[{"id":"e7671388-caeb-4a75-ab00-9a197a1d90f4","created":"2024-01-01T00:00:00.000000Z","last_used":null,"max_age":null,"max_unused_period":null,"name":"","perm_create_domain":true,"perm_delete_domain":false,"perm_manage_tokens":false,"allowed_subnets":["0.0.0.0/0","::/0"],"auto_policy":false,"is_valid":true},{"id":"01234567-890a-4bcd-ef01-23456789abcd","created":"2024-01-01T00:00:00.000000Z","last_used":"2024-01-01T00:00:00.000000Z","max_age":null,"max_unused_period":null,"name":"test-main","perm_create_domain":true,"perm_delete_domain":true,"perm_manage_tokens":true,"allowed_subnets":["0.0.0.0/0","::/0"],"auto_policy":false,"is_valid":true}]' + headers: + Allow: + - GET, POST, HEAD, OPTIONS + Cache-Control: + - no-cache + Connection: + - keep-alive + Content-Length: + - '649' + Content-Type: + - application/json + Date: + - Mon, 01 Jan 2024 00:00:00 GMT + Expires: + - Thu, 01 Jan 1970 00:00:01 GMT + Server: + - nginx + Strict-Transport-Security: + - max-age=31536000; includeSubDomains; preload + Vary: + - origin + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + Content-Length: + - '0' + authorization: + - Token XXXXXXXX + method: DELETE + uri: https://desec.io/api/v1/auth/tokens/e7671388-caeb-4a75-ab00-9a197a1d90f4/ + response: + body: + string: '' + headers: + Allow: + - GET, PUT, PATCH, DELETE, HEAD, OPTIONS + Cache-Control: + - no-cache + Connection: + - keep-alive + Content-Length: + - '0' + Date: + - Mon, 01 Jan 2024 00:00:00 GMT + Expires: + - Thu, 01 Jan 1970 00:00:01 GMT + Server: + - nginx + Strict-Transport-Security: + - max-age=31536000; includeSubDomains; preload + Vary: + - origin + status: + code: 204 + message: No Content +version: 1 diff --git a/tests/cassettes/test_token/test_create_token[perm_delete_domain].yaml b/tests/cassettes/test_token/test_create_token[perm_delete_domain].yaml new file mode 100644 index 0000000..ead4656 --- /dev/null +++ b/tests/cassettes/test_token/test_create_token[perm_delete_domain].yaml @@ -0,0 +1,158 @@ +interactions: +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + authorization: + - Token XXXXXXXX + method: GET + uri: https://desec.io/api/v1/auth/tokens/ + response: + body: + string: '[{"id":"01234567-890a-4bcd-ef01-23456789abcd","created":"2024-01-01T00:00:00.000000Z","last_used":"2024-01-01T00:00:00.000000Z","max_age":null,"max_unused_period":null,"name":"test-main","perm_create_domain":true,"perm_delete_domain":true,"perm_manage_tokens":true,"allowed_subnets":["0.0.0.0/0","::/0"],"auto_policy":false,"is_valid":true}]' + headers: + Allow: + - GET, POST, HEAD, OPTIONS + Cache-Control: + - no-cache + Connection: + - keep-alive + Content-Length: + - '341' + Content-Type: + - application/json + Date: + - Mon, 01 Jan 2024 00:00:00 GMT + Expires: + - Thu, 01 Jan 1970 00:00:01 GMT + Server: + - nginx + Strict-Transport-Security: + - max-age=31536000; includeSubDomains; preload + Vary: + - origin + status: + code: 200 + message: OK +- request: + body: '{"name": "", "perm_delete_domain": true}' + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + Content-Length: + - '40' + Content-Type: + - application/json + authorization: + - Token XXXXXXXX + method: POST + uri: https://desec.io/api/v1/auth/tokens/ + response: + body: + string: '{"id":"81ab0973-58da-465f-8189-961e2b0061a3","created":"2024-01-01T00:00:00.000000Z","last_used":null,"max_age":null,"max_unused_period":null,"name":"","perm_create_domain":false,"perm_delete_domain":true,"perm_manage_tokens":false,"allowed_subnets":["0.0.0.0/0","::/0"],"auto_policy":false,"is_valid":true,"token":"DGMbwxVuMYhfrT2oQgUvvWSURabP"}' + headers: + Allow: + - GET, POST, HEAD, OPTIONS + Cache-Control: + - no-cache + Connection: + - keep-alive + Content-Length: + - '346' + Content-Type: + - application/json + Date: + - Mon, 01 Jan 2024 00:00:00 GMT + Expires: + - Thu, 01 Jan 1970 00:00:01 GMT + Server: + - nginx + Strict-Transport-Security: + - max-age=31536000; includeSubDomains; preload + Vary: + - origin + status: + code: 201 + message: Created +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + authorization: + - Token XXXXXXXX + method: GET + uri: https://desec.io/api/v1/auth/tokens/ + response: + body: + string: '[{"id":"81ab0973-58da-465f-8189-961e2b0061a3","created":"2024-01-01T00:00:00.000000Z","last_used":null,"max_age":null,"max_unused_period":null,"name":"","perm_create_domain":false,"perm_delete_domain":true,"perm_manage_tokens":false,"allowed_subnets":["0.0.0.0/0","::/0"],"auto_policy":false,"is_valid":true},{"id":"01234567-890a-4bcd-ef01-23456789abcd","created":"2024-01-01T00:00:00.000000Z","last_used":"2024-01-01T00:00:00.000000Z","max_age":null,"max_unused_period":null,"name":"test-main","perm_create_domain":true,"perm_delete_domain":true,"perm_manage_tokens":true,"allowed_subnets":["0.0.0.0/0","::/0"],"auto_policy":false,"is_valid":true}]' + headers: + Allow: + - GET, POST, HEAD, OPTIONS + Cache-Control: + - no-cache + Connection: + - keep-alive + Content-Length: + - '649' + Content-Type: + - application/json + Date: + - Mon, 01 Jan 2024 00:00:00 GMT + Expires: + - Thu, 01 Jan 1970 00:00:01 GMT + Server: + - nginx + Strict-Transport-Security: + - max-age=31536000; includeSubDomains; preload + Vary: + - origin + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + Content-Length: + - '0' + authorization: + - Token XXXXXXXX + method: DELETE + uri: https://desec.io/api/v1/auth/tokens/81ab0973-58da-465f-8189-961e2b0061a3/ + response: + body: + string: '' + headers: + Allow: + - GET, PUT, PATCH, DELETE, HEAD, OPTIONS + Cache-Control: + - no-cache + Connection: + - keep-alive + Content-Length: + - '0' + Date: + - Mon, 01 Jan 2024 00:00:00 GMT + Expires: + - Thu, 01 Jan 1970 00:00:01 GMT + Server: + - nginx + Strict-Transport-Security: + - max-age=31536000; includeSubDomains; preload + Vary: + - origin + status: + code: 204 + message: No Content +version: 1 diff --git a/tests/cassettes/test_token/test_create_token[perm_manage_tokens].yaml b/tests/cassettes/test_token/test_create_token[perm_manage_tokens].yaml index 187e9b2..598d066 100644 --- a/tests/cassettes/test_token/test_create_token[perm_manage_tokens].yaml +++ b/tests/cassettes/test_token/test_create_token[perm_manage_tokens].yaml @@ -12,7 +12,7 @@ interactions: uri: https://desec.io/api/v1/auth/tokens/ response: body: - string: '[{"id":"01234567-890a-4bcd-ef01-23456789abcd","created":"2024-01-01T00:00:00.000000Z","last_used":"2024-01-01T00:00:00.000000Z","max_age":null,"max_unused_period":null,"name":"test-main","perm_manage_tokens":true,"allowed_subnets":["0.0.0.0/0","::/0"],"is_valid":true}]' + string: '[{"id":"01234567-890a-4bcd-ef01-23456789abcd","created":"2024-01-01T00:00:00.000000Z","last_used":"2024-01-01T00:00:00.000000Z","max_age":null,"max_unused_period":null,"name":"test-main","perm_create_domain":true,"perm_delete_domain":true,"perm_manage_tokens":true,"allowed_subnets":["0.0.0.0/0","::/0"],"auto_policy":false,"is_valid":true}]' headers: Allow: - GET, POST, HEAD, OPTIONS @@ -21,7 +21,7 @@ interactions: Connection: - keep-alive Content-Length: - - '269' + - '341' Content-Type: - application/json Date: @@ -54,7 +54,7 @@ interactions: uri: https://desec.io/api/v1/auth/tokens/ response: body: - string: '{"id":"2e24f785-b4a4-4b9d-a46f-1b54316e76e3","created":"2024-01-01T00:00:00.000000Z","last_used":null,"max_age":null,"max_unused_period":null,"name":"","perm_manage_tokens":true,"allowed_subnets":["0.0.0.0/0","::/0"],"is_valid":true,"token":"LE1ghPdSY16KMD2AKz5pXWVENGCX"}' + string: '{"id":"1f7d31fb-8eda-4fbc-a906-bccedb509370","created":"2024-01-01T00:00:00.000000Z","last_used":null,"max_age":null,"max_unused_period":null,"name":"","perm_create_domain":false,"perm_delete_domain":false,"perm_manage_tokens":true,"allowed_subnets":["0.0.0.0/0","::/0"],"auto_policy":false,"is_valid":true,"token":"iwWRJmW7JGh9Gh1HPaYBqwn3Zz7G"}' headers: Allow: - GET, POST, HEAD, OPTIONS @@ -63,7 +63,7 @@ interactions: Connection: - keep-alive Content-Length: - - '272' + - '346' Content-Type: - application/json Date: @@ -92,7 +92,7 @@ interactions: uri: https://desec.io/api/v1/auth/tokens/ response: body: - string: '[{"id":"2e24f785-b4a4-4b9d-a46f-1b54316e76e3","created":"2024-01-01T00:00:00.000000Z","last_used":null,"max_age":null,"max_unused_period":null,"name":"","perm_manage_tokens":true,"allowed_subnets":["0.0.0.0/0","::/0"],"is_valid":true},{"id":"01234567-890a-4bcd-ef01-23456789abcd","created":"2024-01-01T00:00:00.000000Z","last_used":"2024-01-01T00:00:00.000000Z","max_age":null,"max_unused_period":null,"name":"test-main","perm_manage_tokens":true,"allowed_subnets":["0.0.0.0/0","::/0"],"is_valid":true}]' + string: '[{"id":"1f7d31fb-8eda-4fbc-a906-bccedb509370","created":"2024-01-01T00:00:00.000000Z","last_used":null,"max_age":null,"max_unused_period":null,"name":"","perm_create_domain":false,"perm_delete_domain":false,"perm_manage_tokens":true,"allowed_subnets":["0.0.0.0/0","::/0"],"auto_policy":false,"is_valid":true},{"id":"01234567-890a-4bcd-ef01-23456789abcd","created":"2024-01-01T00:00:00.000000Z","last_used":"2024-01-01T00:00:00.000000Z","max_age":null,"max_unused_period":null,"name":"test-main","perm_create_domain":true,"perm_delete_domain":true,"perm_manage_tokens":true,"allowed_subnets":["0.0.0.0/0","::/0"],"auto_policy":false,"is_valid":true}]' headers: Allow: - GET, POST, HEAD, OPTIONS @@ -101,7 +101,7 @@ interactions: Connection: - keep-alive Content-Length: - - '503' + - '649' Content-Type: - application/json Date: @@ -129,7 +129,7 @@ interactions: authorization: - Token XXXXXXXX method: DELETE - uri: https://desec.io/api/v1/auth/tokens/2e24f785-b4a4-4b9d-a46f-1b54316e76e3/ + uri: https://desec.io/api/v1/auth/tokens/1f7d31fb-8eda-4fbc-a906-bccedb509370/ response: body: string: '' diff --git a/tests/cassettes/test_token/test_create_token[restricted_subnets].yaml b/tests/cassettes/test_token/test_create_token[restricted_subnets].yaml index ca29a7c..1378600 100644 --- a/tests/cassettes/test_token/test_create_token[restricted_subnets].yaml +++ b/tests/cassettes/test_token/test_create_token[restricted_subnets].yaml @@ -12,7 +12,7 @@ interactions: uri: https://desec.io/api/v1/auth/tokens/ response: body: - string: '[{"id":"01234567-890a-4bcd-ef01-23456789abcd","created":"2024-01-01T00:00:00.000000Z","last_used":"2024-01-01T00:00:00.000000Z","max_age":null,"max_unused_period":null,"name":"test-main","perm_manage_tokens":true,"allowed_subnets":["0.0.0.0/0","::/0"],"is_valid":true}]' + string: '[{"id":"01234567-890a-4bcd-ef01-23456789abcd","created":"2024-01-01T00:00:00.000000Z","last_used":"2024-01-01T00:00:00.000000Z","max_age":null,"max_unused_period":null,"name":"test-main","perm_create_domain":true,"perm_delete_domain":true,"perm_manage_tokens":true,"allowed_subnets":["0.0.0.0/0","::/0"],"auto_policy":false,"is_valid":true}]' headers: Allow: - GET, POST, HEAD, OPTIONS @@ -21,7 +21,7 @@ interactions: Connection: - keep-alive Content-Length: - - '269' + - '341' Content-Type: - application/json Date: @@ -54,7 +54,7 @@ interactions: uri: https://desec.io/api/v1/auth/tokens/ response: body: - string: '{"id":"a48f8a69-b9eb-4ef5-8c4e-687a76d1780c","created":"2024-01-01T00:00:00.000000Z","last_used":null,"max_age":null,"max_unused_period":null,"name":"","perm_manage_tokens":false,"allowed_subnets":["192.0.2.0/24","2001:db8::/32"],"is_valid":true,"token":"adK2RNck7H8bn5U346cq41P1UwFn"}' + string: '{"id":"c10a3249-5a4b-4acf-9133-e78fd21ca4ed","created":"2024-01-01T00:00:00.000000Z","last_used":null,"max_age":null,"max_unused_period":null,"name":"","perm_create_domain":false,"perm_delete_domain":false,"perm_manage_tokens":false,"allowed_subnets":["192.0.2.0/24","2001:db8::/32"],"auto_policy":false,"is_valid":true,"token":"s4F139KFDJxi5cna4Tt6SMsfz6aA"}' headers: Allow: - GET, POST, HEAD, OPTIONS @@ -63,7 +63,7 @@ interactions: Connection: - keep-alive Content-Length: - - '285' + - '359' Content-Type: - application/json Date: @@ -92,7 +92,7 @@ interactions: uri: https://desec.io/api/v1/auth/tokens/ response: body: - string: '[{"id":"a48f8a69-b9eb-4ef5-8c4e-687a76d1780c","created":"2024-01-01T00:00:00.000000Z","last_used":null,"max_age":null,"max_unused_period":null,"name":"","perm_manage_tokens":false,"allowed_subnets":["192.0.2.0/24","2001:db8::/32"],"is_valid":true},{"id":"01234567-890a-4bcd-ef01-23456789abcd","created":"2024-01-01T00:00:00.000000Z","last_used":"2024-01-01T00:00:00.000000Z","max_age":null,"max_unused_period":null,"name":"test-main","perm_manage_tokens":true,"allowed_subnets":["0.0.0.0/0","::/0"],"is_valid":true}]' + string: '[{"id":"c10a3249-5a4b-4acf-9133-e78fd21ca4ed","created":"2024-01-01T00:00:00.000000Z","last_used":null,"max_age":null,"max_unused_period":null,"name":"","perm_create_domain":false,"perm_delete_domain":false,"perm_manage_tokens":false,"allowed_subnets":["192.0.2.0/24","2001:db8::/32"],"auto_policy":false,"is_valid":true},{"id":"01234567-890a-4bcd-ef01-23456789abcd","created":"2024-01-01T00:00:00.000000Z","last_used":"2024-01-01T00:00:00.000000Z","max_age":null,"max_unused_period":null,"name":"test-main","perm_create_domain":true,"perm_delete_domain":true,"perm_manage_tokens":true,"allowed_subnets":["0.0.0.0/0","::/0"],"auto_policy":false,"is_valid":true}]' headers: Allow: - GET, POST, HEAD, OPTIONS @@ -101,7 +101,7 @@ interactions: Connection: - keep-alive Content-Length: - - '516' + - '662' Content-Type: - application/json Date: @@ -129,7 +129,7 @@ interactions: authorization: - Token XXXXXXXX method: DELETE - uri: https://desec.io/api/v1/auth/tokens/a48f8a69-b9eb-4ef5-8c4e-687a76d1780c/ + uri: https://desec.io/api/v1/auth/tokens/c10a3249-5a4b-4acf-9133-e78fd21ca4ed/ response: body: string: '' diff --git a/tests/cassettes/test_token/test_create_token[simple].yaml b/tests/cassettes/test_token/test_create_token[simple].yaml index 83fb7a6..98d668b 100644 --- a/tests/cassettes/test_token/test_create_token[simple].yaml +++ b/tests/cassettes/test_token/test_create_token[simple].yaml @@ -12,7 +12,7 @@ interactions: uri: https://desec.io/api/v1/auth/tokens/ response: body: - string: '[{"id":"01234567-890a-4bcd-ef01-23456789abcd","created":"2024-01-01T00:00:00.000000Z","last_used":"2024-01-01T00:00:00.000000Z","max_age":null,"max_unused_period":null,"name":"test-main","perm_manage_tokens":true,"allowed_subnets":["0.0.0.0/0","::/0"],"is_valid":true}]' + string: '[{"id":"01234567-890a-4bcd-ef01-23456789abcd","created":"2024-01-01T00:00:00.000000Z","last_used":"2024-01-01T00:00:00.000000Z","max_age":null,"max_unused_period":null,"name":"test-main","perm_create_domain":true,"perm_delete_domain":true,"perm_manage_tokens":true,"allowed_subnets":["0.0.0.0/0","::/0"],"auto_policy":false,"is_valid":true}]' headers: Allow: - GET, POST, HEAD, OPTIONS @@ -21,7 +21,7 @@ interactions: Connection: - keep-alive Content-Length: - - '269' + - '341' Content-Type: - application/json Date: @@ -54,7 +54,7 @@ interactions: uri: https://desec.io/api/v1/auth/tokens/ response: body: - string: '{"id":"859e3190-e345-403a-b842-0a53daa95c35","created":"2024-01-01T00:00:00.000000Z","last_used":null,"max_age":null,"max_unused_period":null,"name":"","perm_manage_tokens":false,"allowed_subnets":["0.0.0.0/0","::/0"],"is_valid":true,"token":"WDgfg49s3L4dzT4JzoYd41zfzxDB"}' + string: '{"id":"d03e5f97-728f-476c-b907-c980c2f06b8d","created":"2024-01-01T00:00:00.000000Z","last_used":null,"max_age":null,"max_unused_period":null,"name":"","perm_create_domain":false,"perm_delete_domain":false,"perm_manage_tokens":false,"allowed_subnets":["0.0.0.0/0","::/0"],"auto_policy":false,"is_valid":true,"token":"AZ5ybtZfM1TRa2xWvRd4hbQejQ8S"}' headers: Allow: - GET, POST, HEAD, OPTIONS @@ -63,7 +63,7 @@ interactions: Connection: - keep-alive Content-Length: - - '273' + - '347' Content-Type: - application/json Date: @@ -92,7 +92,7 @@ interactions: uri: https://desec.io/api/v1/auth/tokens/ response: body: - string: '[{"id":"859e3190-e345-403a-b842-0a53daa95c35","created":"2024-01-01T00:00:00.000000Z","last_used":null,"max_age":null,"max_unused_period":null,"name":"","perm_manage_tokens":false,"allowed_subnets":["0.0.0.0/0","::/0"],"is_valid":true},{"id":"01234567-890a-4bcd-ef01-23456789abcd","created":"2024-01-01T00:00:00.000000Z","last_used":"2024-01-01T00:00:00.000000Z","max_age":null,"max_unused_period":null,"name":"test-main","perm_manage_tokens":true,"allowed_subnets":["0.0.0.0/0","::/0"],"is_valid":true}]' + string: '[{"id":"d03e5f97-728f-476c-b907-c980c2f06b8d","created":"2024-01-01T00:00:00.000000Z","last_used":null,"max_age":null,"max_unused_period":null,"name":"","perm_create_domain":false,"perm_delete_domain":false,"perm_manage_tokens":false,"allowed_subnets":["0.0.0.0/0","::/0"],"auto_policy":false,"is_valid":true},{"id":"01234567-890a-4bcd-ef01-23456789abcd","created":"2024-01-01T00:00:00.000000Z","last_used":"2024-01-01T00:00:00.000000Z","max_age":null,"max_unused_period":null,"name":"test-main","perm_create_domain":true,"perm_delete_domain":true,"perm_manage_tokens":true,"allowed_subnets":["0.0.0.0/0","::/0"],"auto_policy":false,"is_valid":true}]' headers: Allow: - GET, POST, HEAD, OPTIONS @@ -101,7 +101,7 @@ interactions: Connection: - keep-alive Content-Length: - - '504' + - '650' Content-Type: - application/json Date: @@ -129,7 +129,7 @@ interactions: authorization: - Token XXXXXXXX method: DELETE - uri: https://desec.io/api/v1/auth/tokens/859e3190-e345-403a-b842-0a53daa95c35/ + uri: https://desec.io/api/v1/auth/tokens/d03e5f97-728f-476c-b907-c980c2f06b8d/ response: body: string: '' diff --git a/tests/cassettes/test_token/test_delete_token.yaml b/tests/cassettes/test_token/test_delete_token.yaml index dbf66f5..536a772 100644 --- a/tests/cassettes/test_token/test_delete_token.yaml +++ b/tests/cassettes/test_token/test_delete_token.yaml @@ -16,7 +16,7 @@ interactions: uri: https://desec.io/api/v1/auth/tokens/ response: body: - string: '{"id":"30c11607-63d6-46f3-90c6-bbe7778ea1f9","created":"2024-01-01T00:00:00.000000Z","last_used":null,"max_age":null,"max_unused_period":null,"name":"","perm_manage_tokens":false,"allowed_subnets":["0.0.0.0/0","::/0"],"is_valid":true,"token":"KPv9QMyHBNxT8xDfhbJA6hN87tBF"}' + string: '{"id":"e9415ee9-8adb-4b33-91f8-728f1878b691","created":"2024-01-01T00:00:00.000000Z","last_used":null,"max_age":null,"max_unused_period":null,"name":"","perm_create_domain":false,"perm_delete_domain":false,"perm_manage_tokens":false,"allowed_subnets":["0.0.0.0/0","::/0"],"auto_policy":false,"is_valid":true,"token":"5DHSV6GhDGpT8cs4KZqXfxN1H7KY"}' headers: Allow: - GET, POST, HEAD, OPTIONS @@ -25,7 +25,7 @@ interactions: Connection: - keep-alive Content-Length: - - '273' + - '347' Content-Type: - application/json Date: @@ -53,7 +53,7 @@ interactions: authorization: - Token XXXXXXXX method: DELETE - uri: https://desec.io/api/v1/auth/tokens/30c11607-63d6-46f3-90c6-bbe7778ea1f9/ + uri: https://desec.io/api/v1/auth/tokens/e9415ee9-8adb-4b33-91f8-728f1878b691/ response: body: string: '' @@ -92,7 +92,7 @@ interactions: uri: https://desec.io/api/v1/auth/tokens/ response: body: - string: '[{"id":"01234567-890a-4bcd-ef01-23456789abcd","created":"2024-01-01T00:00:00.000000Z","last_used":"2024-01-01T00:00:00.000000Z","max_age":null,"max_unused_period":null,"name":"test-main","perm_manage_tokens":true,"allowed_subnets":["0.0.0.0/0","::/0"],"is_valid":true}]' + string: '[{"id":"01234567-890a-4bcd-ef01-23456789abcd","created":"2024-01-01T00:00:00.000000Z","last_used":"2024-01-01T00:00:00.000000Z","max_age":null,"max_unused_period":null,"name":"test-main","perm_create_domain":true,"perm_delete_domain":true,"perm_manage_tokens":true,"allowed_subnets":["0.0.0.0/0","::/0"],"auto_policy":false,"is_valid":true}]' headers: Allow: - GET, POST, HEAD, OPTIONS @@ -101,7 +101,7 @@ interactions: Connection: - keep-alive Content-Length: - - '269' + - '341' Content-Type: - application/json Date: diff --git a/tests/cassettes/test_token/test_list_tokens.yaml b/tests/cassettes/test_token/test_list_tokens.yaml index abbc3c4..4bc9aad 100644 --- a/tests/cassettes/test_token/test_list_tokens.yaml +++ b/tests/cassettes/test_token/test_list_tokens.yaml @@ -12,7 +12,7 @@ interactions: uri: https://desec.io/api/v1/auth/tokens/ response: body: - string: '[{"id":"01234567-890a-4bcd-ef01-23456789abcd","created":"2024-01-01T00:00:00.000000Z","last_used":"2024-01-01T00:00:00.000000Z","max_age":null,"max_unused_period":null,"name":"test-main","perm_manage_tokens":true,"allowed_subnets":["0.0.0.0/0","::/0"],"is_valid":true}]' + string: '[{"id":"01234567-890a-4bcd-ef01-23456789abcd","created":"2024-01-01T00:00:00.000000Z","last_used":"2024-01-01T00:00:00.000000Z","max_age":null,"max_unused_period":null,"name":"test-main","perm_create_domain":true,"perm_delete_domain":true,"perm_manage_tokens":true,"allowed_subnets":["0.0.0.0/0","::/0"],"auto_policy":false,"is_valid":true}]' headers: Allow: - GET, POST, HEAD, OPTIONS @@ -21,7 +21,7 @@ interactions: Connection: - keep-alive Content-Length: - - '269' + - '341' Content-Type: - application/json Date: diff --git a/tests/cassettes/test_token/test_modify_token[auto_policy].yaml b/tests/cassettes/test_token/test_modify_token[auto_policy].yaml new file mode 100644 index 0000000..28f5f05 --- /dev/null +++ b/tests/cassettes/test_token/test_modify_token[auto_policy].yaml @@ -0,0 +1,125 @@ +interactions: +- request: + body: '{"name": "", "perm_manage_tokens": false, "perm_create_domain": false, + "perm_delete_domain": false, "auto_policy": false}' + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + Content-Length: + - '121' + Content-Type: + - application/json + authorization: + - Token XXXXXXXX + method: POST + uri: https://desec.io/api/v1/auth/tokens/ + response: + body: + string: '{"id":"b7960c27-d49e-4e05-aef1-134a3e1649f4","created":"2024-01-01T00:00:00.000000Z","last_used":null,"max_age":null,"max_unused_period":null,"name":"","perm_create_domain":false,"perm_delete_domain":false,"perm_manage_tokens":false,"allowed_subnets":["0.0.0.0/0","::/0"],"auto_policy":false,"is_valid":true,"token":"b4YcNvihLau2tw1ynyPKPKxb5LLX"}' + headers: + Allow: + - GET, POST, HEAD, OPTIONS + Cache-Control: + - no-cache + Connection: + - keep-alive + Content-Length: + - '347' + Content-Type: + - application/json + Date: + - Mon, 01 Jan 2024 00:00:00 GMT + Expires: + - Thu, 01 Jan 1970 00:00:01 GMT + Server: + - nginx + Strict-Transport-Security: + - max-age=31536000; includeSubDomains; preload + Vary: + - origin + status: + code: 201 + message: Created +- request: + body: '{"auto_policy": true}' + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + Content-Length: + - '21' + Content-Type: + - application/json + authorization: + - Token XXXXXXXX + method: PATCH + uri: https://desec.io/api/v1/auth/tokens/b7960c27-d49e-4e05-aef1-134a3e1649f4/ + response: + body: + string: '{"id":"b7960c27-d49e-4e05-aef1-134a3e1649f4","created":"2024-01-01T00:00:00.000000Z","last_used":null,"max_age":null,"max_unused_period":null,"name":"","perm_create_domain":false,"perm_delete_domain":false,"perm_manage_tokens":false,"allowed_subnets":["0.0.0.0/0","::/0"],"auto_policy":true,"is_valid":true}' + headers: + Allow: + - GET, PUT, PATCH, DELETE, HEAD, OPTIONS + Cache-Control: + - no-cache + Connection: + - keep-alive + Content-Length: + - '307' + Content-Type: + - application/json + Date: + - Mon, 01 Jan 2024 00:00:00 GMT + Expires: + - Thu, 01 Jan 1970 00:00:01 GMT + Server: + - nginx + Strict-Transport-Security: + - max-age=31536000; includeSubDomains; preload + Vary: + - origin + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + Content-Length: + - '0' + authorization: + - Token XXXXXXXX + method: DELETE + uri: https://desec.io/api/v1/auth/tokens/b7960c27-d49e-4e05-aef1-134a3e1649f4/ + response: + body: + string: '' + headers: + Allow: + - GET, PUT, PATCH, DELETE, HEAD, OPTIONS + Cache-Control: + - no-cache + Connection: + - keep-alive + Content-Length: + - '0' + Date: + - Mon, 01 Jan 2024 00:00:00 GMT + Expires: + - Thu, 01 Jan 1970 00:00:01 GMT + Server: + - nginx + Strict-Transport-Security: + - max-age=31536000; includeSubDomains; preload + Vary: + - origin + status: + code: 204 + message: No Content +version: 1 diff --git a/tests/cassettes/test_token/test_modify_token[named].yaml b/tests/cassettes/test_token/test_modify_token[named].yaml index f784560..31be303 100644 --- a/tests/cassettes/test_token/test_modify_token[named].yaml +++ b/tests/cassettes/test_token/test_modify_token[named].yaml @@ -1,13 +1,14 @@ interactions: - request: - body: '{"name": "", "perm_manage_tokens": false}' + body: '{"name": "", "perm_manage_tokens": false, "perm_create_domain": false, + "perm_delete_domain": false, "auto_policy": false}' headers: Accept: - '*/*' Accept-Encoding: - gzip, deflate Content-Length: - - '41' + - '121' Content-Type: - application/json authorization: @@ -16,7 +17,7 @@ interactions: uri: https://desec.io/api/v1/auth/tokens/ response: body: - string: '{"id":"2d87f01e-32c5-4596-916d-e7b9705706e4","created":"2024-01-01T00:00:00.000000Z","last_used":null,"max_age":null,"max_unused_period":null,"name":"","perm_manage_tokens":false,"allowed_subnets":["0.0.0.0/0","::/0"],"is_valid":true,"token":"TzNpV562ZnTimH62qGdtMNDM72dm"}' + string: '{"id":"285a4fc4-6ae2-4e23-9508-97c1dab7bd0b","created":"2024-01-01T00:00:00.000000Z","last_used":null,"max_age":null,"max_unused_period":null,"name":"","perm_create_domain":false,"perm_delete_domain":false,"perm_manage_tokens":false,"allowed_subnets":["0.0.0.0/0","::/0"],"auto_policy":false,"is_valid":true,"token":"anYZQtWzfeetWL2UVn3DeF3DoN3L"}' headers: Allow: - GET, POST, HEAD, OPTIONS @@ -25,7 +26,7 @@ interactions: Connection: - keep-alive Content-Length: - - '273' + - '347' Content-Type: - application/json Date: @@ -55,10 +56,10 @@ interactions: authorization: - Token XXXXXXXX method: PATCH - uri: https://desec.io/api/v1/auth/tokens/2d87f01e-32c5-4596-916d-e7b9705706e4/ + uri: https://desec.io/api/v1/auth/tokens/285a4fc4-6ae2-4e23-9508-97c1dab7bd0b/ response: body: - string: '{"id":"2d87f01e-32c5-4596-916d-e7b9705706e4","created":"2024-01-01T00:00:00.000000Z","last_used":null,"max_age":null,"max_unused_period":null,"name":"test-suite","perm_manage_tokens":false,"allowed_subnets":["0.0.0.0/0","::/0"],"is_valid":true}' + string: '{"id":"285a4fc4-6ae2-4e23-9508-97c1dab7bd0b","created":"2024-01-01T00:00:00.000000Z","last_used":null,"max_age":null,"max_unused_period":null,"name":"test-suite","perm_create_domain":false,"perm_delete_domain":false,"perm_manage_tokens":false,"allowed_subnets":["0.0.0.0/0","::/0"],"auto_policy":false,"is_valid":true}' headers: Allow: - GET, PUT, PATCH, DELETE, HEAD, OPTIONS @@ -67,7 +68,7 @@ interactions: Connection: - keep-alive Content-Length: - - '244' + - '318' Content-Type: - application/json Date: @@ -95,7 +96,7 @@ interactions: authorization: - Token XXXXXXXX method: DELETE - uri: https://desec.io/api/v1/auth/tokens/2d87f01e-32c5-4596-916d-e7b9705706e4/ + uri: https://desec.io/api/v1/auth/tokens/285a4fc4-6ae2-4e23-9508-97c1dab7bd0b/ response: body: string: '' diff --git a/tests/cassettes/test_token/test_modify_token[no_auto_policy].yaml b/tests/cassettes/test_token/test_modify_token[no_auto_policy].yaml new file mode 100644 index 0000000..ef52694 --- /dev/null +++ b/tests/cassettes/test_token/test_modify_token[no_auto_policy].yaml @@ -0,0 +1,125 @@ +interactions: +- request: + body: '{"name": "", "perm_manage_tokens": false, "perm_create_domain": false, + "perm_delete_domain": false, "auto_policy": true}' + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + Content-Length: + - '120' + Content-Type: + - application/json + authorization: + - Token XXXXXXXX + method: POST + uri: https://desec.io/api/v1/auth/tokens/ + response: + body: + string: '{"id":"5988a39e-df7b-4c7b-881b-4c73f33acf45","created":"2024-01-01T00:00:00.000000Z","last_used":null,"max_age":null,"max_unused_period":null,"name":"","perm_create_domain":false,"perm_delete_domain":false,"perm_manage_tokens":false,"allowed_subnets":["0.0.0.0/0","::/0"],"auto_policy":true,"is_valid":true,"token":"eSbGPuTFACx64Z3tjEjFswNkdFkC"}' + headers: + Allow: + - GET, POST, HEAD, OPTIONS + Cache-Control: + - no-cache + Connection: + - keep-alive + Content-Length: + - '346' + Content-Type: + - application/json + Date: + - Mon, 01 Jan 2024 00:00:00 GMT + Expires: + - Thu, 01 Jan 1970 00:00:01 GMT + Server: + - nginx + Strict-Transport-Security: + - max-age=31536000; includeSubDomains; preload + Vary: + - origin + status: + code: 201 + message: Created +- request: + body: '{"auto_policy": false}' + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + Content-Length: + - '22' + Content-Type: + - application/json + authorization: + - Token XXXXXXXX + method: PATCH + uri: https://desec.io/api/v1/auth/tokens/5988a39e-df7b-4c7b-881b-4c73f33acf45/ + response: + body: + string: '{"id":"5988a39e-df7b-4c7b-881b-4c73f33acf45","created":"2024-01-01T00:00:00.000000Z","last_used":null,"max_age":null,"max_unused_period":null,"name":"","perm_create_domain":false,"perm_delete_domain":false,"perm_manage_tokens":false,"allowed_subnets":["0.0.0.0/0","::/0"],"auto_policy":false,"is_valid":true}' + headers: + Allow: + - GET, PUT, PATCH, DELETE, HEAD, OPTIONS + Cache-Control: + - no-cache + Connection: + - keep-alive + Content-Length: + - '308' + Content-Type: + - application/json + Date: + - Mon, 01 Jan 2024 00:00:00 GMT + Expires: + - Thu, 01 Jan 1970 00:00:01 GMT + Server: + - nginx + Strict-Transport-Security: + - max-age=31536000; includeSubDomains; preload + Vary: + - origin + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + Content-Length: + - '0' + authorization: + - Token XXXXXXXX + method: DELETE + uri: https://desec.io/api/v1/auth/tokens/5988a39e-df7b-4c7b-881b-4c73f33acf45/ + response: + body: + string: '' + headers: + Allow: + - GET, PUT, PATCH, DELETE, HEAD, OPTIONS + Cache-Control: + - no-cache + Connection: + - keep-alive + Content-Length: + - '0' + Date: + - Mon, 01 Jan 2024 00:00:00 GMT + Expires: + - Thu, 01 Jan 1970 00:00:01 GMT + Server: + - nginx + Strict-Transport-Security: + - max-age=31536000; includeSubDomains; preload + Vary: + - origin + status: + code: 204 + message: No Content +version: 1 diff --git a/tests/cassettes/test_token/test_modify_token[no_perm_create_domain].yaml b/tests/cassettes/test_token/test_modify_token[no_perm_create_domain].yaml new file mode 100644 index 0000000..ee4d561 --- /dev/null +++ b/tests/cassettes/test_token/test_modify_token[no_perm_create_domain].yaml @@ -0,0 +1,125 @@ +interactions: +- request: + body: '{"name": "", "perm_manage_tokens": false, "perm_create_domain": true, "perm_delete_domain": + false, "auto_policy": false}' + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + Content-Length: + - '120' + Content-Type: + - application/json + authorization: + - Token XXXXXXXX + method: POST + uri: https://desec.io/api/v1/auth/tokens/ + response: + body: + string: '{"id":"7c769b46-fede-43f7-953e-44a961423c07","created":"2024-01-01T00:00:00.000000Z","last_used":null,"max_age":null,"max_unused_period":null,"name":"","perm_create_domain":true,"perm_delete_domain":false,"perm_manage_tokens":false,"allowed_subnets":["0.0.0.0/0","::/0"],"auto_policy":false,"is_valid":true,"token":"3VAMnwfHxzpaQDg1S4B8J5YLijkB"}' + headers: + Allow: + - GET, POST, HEAD, OPTIONS + Cache-Control: + - no-cache + Connection: + - keep-alive + Content-Length: + - '346' + Content-Type: + - application/json + Date: + - Mon, 01 Jan 2024 00:00:00 GMT + Expires: + - Thu, 01 Jan 1970 00:00:01 GMT + Server: + - nginx + Strict-Transport-Security: + - max-age=31536000; includeSubDomains; preload + Vary: + - origin + status: + code: 201 + message: Created +- request: + body: '{"perm_create_domain": false}' + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + Content-Length: + - '29' + Content-Type: + - application/json + authorization: + - Token XXXXXXXX + method: PATCH + uri: https://desec.io/api/v1/auth/tokens/7c769b46-fede-43f7-953e-44a961423c07/ + response: + body: + string: '{"id":"7c769b46-fede-43f7-953e-44a961423c07","created":"2024-01-01T00:00:00.000000Z","last_used":null,"max_age":null,"max_unused_period":null,"name":"","perm_create_domain":false,"perm_delete_domain":false,"perm_manage_tokens":false,"allowed_subnets":["0.0.0.0/0","::/0"],"auto_policy":false,"is_valid":true}' + headers: + Allow: + - GET, PUT, PATCH, DELETE, HEAD, OPTIONS + Cache-Control: + - no-cache + Connection: + - keep-alive + Content-Length: + - '308' + Content-Type: + - application/json + Date: + - Mon, 01 Jan 2024 00:00:00 GMT + Expires: + - Thu, 01 Jan 1970 00:00:01 GMT + Server: + - nginx + Strict-Transport-Security: + - max-age=31536000; includeSubDomains; preload + Vary: + - origin + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + Content-Length: + - '0' + authorization: + - Token XXXXXXXX + method: DELETE + uri: https://desec.io/api/v1/auth/tokens/7c769b46-fede-43f7-953e-44a961423c07/ + response: + body: + string: '' + headers: + Allow: + - GET, PUT, PATCH, DELETE, HEAD, OPTIONS + Cache-Control: + - no-cache + Connection: + - keep-alive + Content-Length: + - '0' + Date: + - Mon, 01 Jan 2024 00:00:00 GMT + Expires: + - Thu, 01 Jan 1970 00:00:01 GMT + Server: + - nginx + Strict-Transport-Security: + - max-age=31536000; includeSubDomains; preload + Vary: + - origin + status: + code: 204 + message: No Content +version: 1 diff --git a/tests/cassettes/test_token/test_modify_token[no_perm_delete_domain].yaml b/tests/cassettes/test_token/test_modify_token[no_perm_delete_domain].yaml new file mode 100644 index 0000000..c7968a0 --- /dev/null +++ b/tests/cassettes/test_token/test_modify_token[no_perm_delete_domain].yaml @@ -0,0 +1,125 @@ +interactions: +- request: + body: '{"name": "", "perm_manage_tokens": false, "perm_create_domain": false, + "perm_delete_domain": true, "auto_policy": false}' + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + Content-Length: + - '120' + Content-Type: + - application/json + authorization: + - Token XXXXXXXX + method: POST + uri: https://desec.io/api/v1/auth/tokens/ + response: + body: + string: '{"id":"80d2793e-205a-433d-9448-3e98bbafc83a","created":"2024-01-01T00:00:00.000000Z","last_used":null,"max_age":null,"max_unused_period":null,"name":"","perm_create_domain":false,"perm_delete_domain":true,"perm_manage_tokens":false,"allowed_subnets":["0.0.0.0/0","::/0"],"auto_policy":false,"is_valid":true,"token":"D5TfAHFgbGUzH7WwiikioM6w84sy"}' + headers: + Allow: + - GET, POST, HEAD, OPTIONS + Cache-Control: + - no-cache + Connection: + - keep-alive + Content-Length: + - '346' + Content-Type: + - application/json + Date: + - Mon, 01 Jan 2024 00:00:00 GMT + Expires: + - Thu, 01 Jan 1970 00:00:01 GMT + Server: + - nginx + Strict-Transport-Security: + - max-age=31536000; includeSubDomains; preload + Vary: + - origin + status: + code: 201 + message: Created +- request: + body: '{"perm_delete_domain": false}' + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + Content-Length: + - '29' + Content-Type: + - application/json + authorization: + - Token XXXXXXXX + method: PATCH + uri: https://desec.io/api/v1/auth/tokens/80d2793e-205a-433d-9448-3e98bbafc83a/ + response: + body: + string: '{"id":"80d2793e-205a-433d-9448-3e98bbafc83a","created":"2024-01-01T00:00:00.000000Z","last_used":null,"max_age":null,"max_unused_period":null,"name":"","perm_create_domain":false,"perm_delete_domain":false,"perm_manage_tokens":false,"allowed_subnets":["0.0.0.0/0","::/0"],"auto_policy":false,"is_valid":true}' + headers: + Allow: + - GET, PUT, PATCH, DELETE, HEAD, OPTIONS + Cache-Control: + - no-cache + Connection: + - keep-alive + Content-Length: + - '308' + Content-Type: + - application/json + Date: + - Mon, 01 Jan 2024 00:00:00 GMT + Expires: + - Thu, 01 Jan 1970 00:00:01 GMT + Server: + - nginx + Strict-Transport-Security: + - max-age=31536000; includeSubDomains; preload + Vary: + - origin + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + Content-Length: + - '0' + authorization: + - Token XXXXXXXX + method: DELETE + uri: https://desec.io/api/v1/auth/tokens/80d2793e-205a-433d-9448-3e98bbafc83a/ + response: + body: + string: '' + headers: + Allow: + - GET, PUT, PATCH, DELETE, HEAD, OPTIONS + Cache-Control: + - no-cache + Connection: + - keep-alive + Content-Length: + - '0' + Date: + - Mon, 01 Jan 2024 00:00:00 GMT + Expires: + - Thu, 01 Jan 1970 00:00:01 GMT + Server: + - nginx + Strict-Transport-Security: + - max-age=31536000; includeSubDomains; preload + Vary: + - origin + status: + code: 204 + message: No Content +version: 1 diff --git a/tests/cassettes/test_token/test_modify_token[no_perm_manage_tokens].yaml b/tests/cassettes/test_token/test_modify_token[no_perm_manage_tokens].yaml index 0f08736..4c5e7a4 100644 --- a/tests/cassettes/test_token/test_modify_token[no_perm_manage_tokens].yaml +++ b/tests/cassettes/test_token/test_modify_token[no_perm_manage_tokens].yaml @@ -1,13 +1,14 @@ interactions: - request: - body: '{"name": "", "perm_manage_tokens": true}' + body: '{"name": "", "perm_manage_tokens": true, "perm_create_domain": false, "perm_delete_domain": + false, "auto_policy": false}' headers: Accept: - '*/*' Accept-Encoding: - gzip, deflate Content-Length: - - '40' + - '120' Content-Type: - application/json authorization: @@ -16,7 +17,7 @@ interactions: uri: https://desec.io/api/v1/auth/tokens/ response: body: - string: '{"id":"37fdc658-07dc-41cb-ae74-6502ceeb5063","created":"2024-01-01T00:00:00.000000Z","last_used":null,"max_age":null,"max_unused_period":null,"name":"","perm_manage_tokens":true,"allowed_subnets":["0.0.0.0/0","::/0"],"is_valid":true,"token":"n9ZKgyQyBLPHoNTajPZYRF7Gou4H"}' + string: '{"id":"72209203-afab-4df7-80f6-d5f8ad806f31","created":"2024-01-01T00:00:00.000000Z","last_used":null,"max_age":null,"max_unused_period":null,"name":"","perm_create_domain":false,"perm_delete_domain":false,"perm_manage_tokens":true,"allowed_subnets":["0.0.0.0/0","::/0"],"auto_policy":false,"is_valid":true,"token":"5BoLUQb7hyMgexPYmmVLAxHucUJB"}' headers: Allow: - GET, POST, HEAD, OPTIONS @@ -25,7 +26,7 @@ interactions: Connection: - keep-alive Content-Length: - - '272' + - '346' Content-Type: - application/json Date: @@ -55,10 +56,10 @@ interactions: authorization: - Token XXXXXXXX method: PATCH - uri: https://desec.io/api/v1/auth/tokens/37fdc658-07dc-41cb-ae74-6502ceeb5063/ + uri: https://desec.io/api/v1/auth/tokens/72209203-afab-4df7-80f6-d5f8ad806f31/ response: body: - string: '{"id":"37fdc658-07dc-41cb-ae74-6502ceeb5063","created":"2024-01-01T00:00:00.000000Z","last_used":null,"max_age":null,"max_unused_period":null,"name":"","perm_manage_tokens":false,"allowed_subnets":["0.0.0.0/0","::/0"],"is_valid":true}' + string: '{"id":"72209203-afab-4df7-80f6-d5f8ad806f31","created":"2024-01-01T00:00:00.000000Z","last_used":null,"max_age":null,"max_unused_period":null,"name":"","perm_create_domain":false,"perm_delete_domain":false,"perm_manage_tokens":false,"allowed_subnets":["0.0.0.0/0","::/0"],"auto_policy":false,"is_valid":true}' headers: Allow: - GET, PUT, PATCH, DELETE, HEAD, OPTIONS @@ -67,7 +68,7 @@ interactions: Connection: - keep-alive Content-Length: - - '234' + - '308' Content-Type: - application/json Date: @@ -95,7 +96,7 @@ interactions: authorization: - Token XXXXXXXX method: DELETE - uri: https://desec.io/api/v1/auth/tokens/37fdc658-07dc-41cb-ae74-6502ceeb5063/ + uri: https://desec.io/api/v1/auth/tokens/72209203-afab-4df7-80f6-d5f8ad806f31/ response: body: string: '' diff --git a/tests/cassettes/test_token/test_modify_token[perm_create_domain].yaml b/tests/cassettes/test_token/test_modify_token[perm_create_domain].yaml new file mode 100644 index 0000000..330a0b2 --- /dev/null +++ b/tests/cassettes/test_token/test_modify_token[perm_create_domain].yaml @@ -0,0 +1,125 @@ +interactions: +- request: + body: '{"name": "", "perm_manage_tokens": false, "perm_create_domain": false, + "perm_delete_domain": false, "auto_policy": false}' + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + Content-Length: + - '121' + Content-Type: + - application/json + authorization: + - Token XXXXXXXX + method: POST + uri: https://desec.io/api/v1/auth/tokens/ + response: + body: + string: '{"id":"37f44b49-b4fc-4767-843b-65b2449a82ba","created":"2024-01-01T00:00:00.000000Z","last_used":null,"max_age":null,"max_unused_period":null,"name":"","perm_create_domain":false,"perm_delete_domain":false,"perm_manage_tokens":false,"allowed_subnets":["0.0.0.0/0","::/0"],"auto_policy":false,"is_valid":true,"token":"bNxhTKaeV9QHAZXziDhFgcF692ES"}' + headers: + Allow: + - GET, POST, HEAD, OPTIONS + Cache-Control: + - no-cache + Connection: + - keep-alive + Content-Length: + - '347' + Content-Type: + - application/json + Date: + - Mon, 01 Jan 2024 00:00:00 GMT + Expires: + - Thu, 01 Jan 1970 00:00:01 GMT + Server: + - nginx + Strict-Transport-Security: + - max-age=31536000; includeSubDomains; preload + Vary: + - origin + status: + code: 201 + message: Created +- request: + body: '{"perm_create_domain": true}' + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + Content-Length: + - '28' + Content-Type: + - application/json + authorization: + - Token XXXXXXXX + method: PATCH + uri: https://desec.io/api/v1/auth/tokens/37f44b49-b4fc-4767-843b-65b2449a82ba/ + response: + body: + string: '{"id":"37f44b49-b4fc-4767-843b-65b2449a82ba","created":"2024-01-01T00:00:00.000000Z","last_used":null,"max_age":null,"max_unused_period":null,"name":"","perm_create_domain":true,"perm_delete_domain":false,"perm_manage_tokens":false,"allowed_subnets":["0.0.0.0/0","::/0"],"auto_policy":false,"is_valid":true}' + headers: + Allow: + - GET, PUT, PATCH, DELETE, HEAD, OPTIONS + Cache-Control: + - no-cache + Connection: + - keep-alive + Content-Length: + - '307' + Content-Type: + - application/json + Date: + - Mon, 01 Jan 2024 00:00:00 GMT + Expires: + - Thu, 01 Jan 1970 00:00:01 GMT + Server: + - nginx + Strict-Transport-Security: + - max-age=31536000; includeSubDomains; preload + Vary: + - origin + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + Content-Length: + - '0' + authorization: + - Token XXXXXXXX + method: DELETE + uri: https://desec.io/api/v1/auth/tokens/37f44b49-b4fc-4767-843b-65b2449a82ba/ + response: + body: + string: '' + headers: + Allow: + - GET, PUT, PATCH, DELETE, HEAD, OPTIONS + Cache-Control: + - no-cache + Connection: + - keep-alive + Content-Length: + - '0' + Date: + - Mon, 01 Jan 2024 00:00:00 GMT + Expires: + - Thu, 01 Jan 1970 00:00:01 GMT + Server: + - nginx + Strict-Transport-Security: + - max-age=31536000; includeSubDomains; preload + Vary: + - origin + status: + code: 204 + message: No Content +version: 1 diff --git a/tests/cassettes/test_token/test_modify_token[perm_delete_domain].yaml b/tests/cassettes/test_token/test_modify_token[perm_delete_domain].yaml new file mode 100644 index 0000000..f2784e3 --- /dev/null +++ b/tests/cassettes/test_token/test_modify_token[perm_delete_domain].yaml @@ -0,0 +1,125 @@ +interactions: +- request: + body: '{"name": "", "perm_manage_tokens": false, "perm_create_domain": false, + "perm_delete_domain": false, "auto_policy": false}' + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + Content-Length: + - '121' + Content-Type: + - application/json + authorization: + - Token XXXXXXXX + method: POST + uri: https://desec.io/api/v1/auth/tokens/ + response: + body: + string: '{"id":"d1eb464e-1d5e-4f5f-b042-0e477fca82f9","created":"2024-01-01T00:00:00.000000Z","last_used":null,"max_age":null,"max_unused_period":null,"name":"","perm_create_domain":false,"perm_delete_domain":false,"perm_manage_tokens":false,"allowed_subnets":["0.0.0.0/0","::/0"],"auto_policy":false,"is_valid":true,"token":"NkaPW9EM2beFfTnBSj7xeTYKDsKj"}' + headers: + Allow: + - GET, POST, HEAD, OPTIONS + Cache-Control: + - no-cache + Connection: + - keep-alive + Content-Length: + - '347' + Content-Type: + - application/json + Date: + - Mon, 01 Jan 2024 00:00:00 GMT + Expires: + - Thu, 01 Jan 1970 00:00:01 GMT + Server: + - nginx + Strict-Transport-Security: + - max-age=31536000; includeSubDomains; preload + Vary: + - origin + status: + code: 201 + message: Created +- request: + body: '{"perm_delete_domain": true}' + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + Content-Length: + - '28' + Content-Type: + - application/json + authorization: + - Token XXXXXXXX + method: PATCH + uri: https://desec.io/api/v1/auth/tokens/d1eb464e-1d5e-4f5f-b042-0e477fca82f9/ + response: + body: + string: '{"id":"d1eb464e-1d5e-4f5f-b042-0e477fca82f9","created":"2024-01-01T00:00:00.000000Z","last_used":null,"max_age":null,"max_unused_period":null,"name":"","perm_create_domain":false,"perm_delete_domain":true,"perm_manage_tokens":false,"allowed_subnets":["0.0.0.0/0","::/0"],"auto_policy":false,"is_valid":true}' + headers: + Allow: + - GET, PUT, PATCH, DELETE, HEAD, OPTIONS + Cache-Control: + - no-cache + Connection: + - keep-alive + Content-Length: + - '307' + Content-Type: + - application/json + Date: + - Mon, 01 Jan 2024 00:00:00 GMT + Expires: + - Thu, 01 Jan 1970 00:00:01 GMT + Server: + - nginx + Strict-Transport-Security: + - max-age=31536000; includeSubDomains; preload + Vary: + - origin + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + Content-Length: + - '0' + authorization: + - Token XXXXXXXX + method: DELETE + uri: https://desec.io/api/v1/auth/tokens/d1eb464e-1d5e-4f5f-b042-0e477fca82f9/ + response: + body: + string: '' + headers: + Allow: + - GET, PUT, PATCH, DELETE, HEAD, OPTIONS + Cache-Control: + - no-cache + Connection: + - keep-alive + Content-Length: + - '0' + Date: + - Mon, 01 Jan 2024 00:00:00 GMT + Expires: + - Thu, 01 Jan 1970 00:00:01 GMT + Server: + - nginx + Strict-Transport-Security: + - max-age=31536000; includeSubDomains; preload + Vary: + - origin + status: + code: 204 + message: No Content +version: 1 diff --git a/tests/cassettes/test_token/test_modify_token[perm_manage_tokens].yaml b/tests/cassettes/test_token/test_modify_token[perm_manage_tokens].yaml index 11dc0a8..154f511 100644 --- a/tests/cassettes/test_token/test_modify_token[perm_manage_tokens].yaml +++ b/tests/cassettes/test_token/test_modify_token[perm_manage_tokens].yaml @@ -1,13 +1,14 @@ interactions: - request: - body: '{"name": "", "perm_manage_tokens": false}' + body: '{"name": "", "perm_manage_tokens": false, "perm_create_domain": false, + "perm_delete_domain": false, "auto_policy": false}' headers: Accept: - '*/*' Accept-Encoding: - gzip, deflate Content-Length: - - '41' + - '121' Content-Type: - application/json authorization: @@ -16,7 +17,7 @@ interactions: uri: https://desec.io/api/v1/auth/tokens/ response: body: - string: '{"id":"b66d9d16-70cf-490b-a2dc-349e46ca327a","created":"2024-01-01T00:00:00.000000Z","last_used":null,"max_age":null,"max_unused_period":null,"name":"","perm_manage_tokens":false,"allowed_subnets":["0.0.0.0/0","::/0"],"is_valid":true,"token":"8i3ufoVKAEp3hX4xnJpKB4Aj44LH"}' + string: '{"id":"739a4f26-3a49-454a-9e28-d70606cdfb89","created":"2024-01-01T00:00:00.000000Z","last_used":null,"max_age":null,"max_unused_period":null,"name":"","perm_create_domain":false,"perm_delete_domain":false,"perm_manage_tokens":false,"allowed_subnets":["0.0.0.0/0","::/0"],"auto_policy":false,"is_valid":true,"token":"gMQMj8N75jC9BBfr2xU1ckb3hAan"}' headers: Allow: - GET, POST, HEAD, OPTIONS @@ -25,7 +26,7 @@ interactions: Connection: - keep-alive Content-Length: - - '273' + - '347' Content-Type: - application/json Date: @@ -55,10 +56,10 @@ interactions: authorization: - Token XXXXXXXX method: PATCH - uri: https://desec.io/api/v1/auth/tokens/b66d9d16-70cf-490b-a2dc-349e46ca327a/ + uri: https://desec.io/api/v1/auth/tokens/739a4f26-3a49-454a-9e28-d70606cdfb89/ response: body: - string: '{"id":"b66d9d16-70cf-490b-a2dc-349e46ca327a","created":"2024-01-01T00:00:00.000000Z","last_used":null,"max_age":null,"max_unused_period":null,"name":"","perm_manage_tokens":true,"allowed_subnets":["0.0.0.0/0","::/0"],"is_valid":true}' + string: '{"id":"739a4f26-3a49-454a-9e28-d70606cdfb89","created":"2024-01-01T00:00:00.000000Z","last_used":null,"max_age":null,"max_unused_period":null,"name":"","perm_create_domain":false,"perm_delete_domain":false,"perm_manage_tokens":true,"allowed_subnets":["0.0.0.0/0","::/0"],"auto_policy":false,"is_valid":true}' headers: Allow: - GET, PUT, PATCH, DELETE, HEAD, OPTIONS @@ -67,7 +68,7 @@ interactions: Connection: - keep-alive Content-Length: - - '233' + - '307' Content-Type: - application/json Date: @@ -95,7 +96,7 @@ interactions: authorization: - Token XXXXXXXX method: DELETE - uri: https://desec.io/api/v1/auth/tokens/b66d9d16-70cf-490b-a2dc-349e46ca327a/ + uri: https://desec.io/api/v1/auth/tokens/739a4f26-3a49-454a-9e28-d70606cdfb89/ response: body: string: '' diff --git a/tests/cassettes/test_token/test_modify_token[restricted_subnets].yaml b/tests/cassettes/test_token/test_modify_token[restricted_subnets].yaml index 111e94a..1640aa4 100644 --- a/tests/cassettes/test_token/test_modify_token[restricted_subnets].yaml +++ b/tests/cassettes/test_token/test_modify_token[restricted_subnets].yaml @@ -1,13 +1,14 @@ interactions: - request: - body: '{"name": "", "perm_manage_tokens": false}' + body: '{"name": "", "perm_manage_tokens": false, "perm_create_domain": false, + "perm_delete_domain": false, "auto_policy": false}' headers: Accept: - '*/*' Accept-Encoding: - gzip, deflate Content-Length: - - '41' + - '121' Content-Type: - application/json authorization: @@ -16,7 +17,7 @@ interactions: uri: https://desec.io/api/v1/auth/tokens/ response: body: - string: '{"id":"be71110d-21d8-4f30-abb0-b411ef030e51","created":"2024-01-01T00:00:00.000000Z","last_used":null,"max_age":null,"max_unused_period":null,"name":"","perm_manage_tokens":false,"allowed_subnets":["0.0.0.0/0","::/0"],"is_valid":true,"token":"6Zx9Cjgsodq37xTBqmvUinYFM93b"}' + string: '{"id":"eb63b24f-03fd-459a-8965-051f9e17da67","created":"2024-01-01T00:00:00.000000Z","last_used":null,"max_age":null,"max_unused_period":null,"name":"","perm_create_domain":false,"perm_delete_domain":false,"perm_manage_tokens":false,"allowed_subnets":["0.0.0.0/0","::/0"],"auto_policy":false,"is_valid":true,"token":"VfVhxSy7ZadCTReXDpH6vhMRdqHc"}' headers: Allow: - GET, POST, HEAD, OPTIONS @@ -25,7 +26,7 @@ interactions: Connection: - keep-alive Content-Length: - - '273' + - '347' Content-Type: - application/json Date: @@ -55,10 +56,10 @@ interactions: authorization: - Token XXXXXXXX method: PATCH - uri: https://desec.io/api/v1/auth/tokens/be71110d-21d8-4f30-abb0-b411ef030e51/ + uri: https://desec.io/api/v1/auth/tokens/eb63b24f-03fd-459a-8965-051f9e17da67/ response: body: - string: '{"id":"be71110d-21d8-4f30-abb0-b411ef030e51","created":"2024-01-01T00:00:00.000000Z","last_used":null,"max_age":null,"max_unused_period":null,"name":"","perm_manage_tokens":false,"allowed_subnets":["192.0.2.0/24","2001:db8::/32"],"is_valid":true}' + string: '{"id":"eb63b24f-03fd-459a-8965-051f9e17da67","created":"2024-01-01T00:00:00.000000Z","last_used":null,"max_age":null,"max_unused_period":null,"name":"","perm_create_domain":false,"perm_delete_domain":false,"perm_manage_tokens":false,"allowed_subnets":["192.0.2.0/24","2001:db8::/32"],"auto_policy":false,"is_valid":true}' headers: Allow: - GET, PUT, PATCH, DELETE, HEAD, OPTIONS @@ -67,7 +68,7 @@ interactions: Connection: - keep-alive Content-Length: - - '246' + - '320' Content-Type: - application/json Date: @@ -95,7 +96,7 @@ interactions: authorization: - Token XXXXXXXX method: DELETE - uri: https://desec.io/api/v1/auth/tokens/be71110d-21d8-4f30-abb0-b411ef030e51/ + uri: https://desec.io/api/v1/auth/tokens/eb63b24f-03fd-459a-8965-051f9e17da67/ response: body: string: '' diff --git a/tests/cassettes/test_token/test_modify_token[simple].yaml b/tests/cassettes/test_token/test_modify_token[simple].yaml index 2bff8a2..7afe796 100644 --- a/tests/cassettes/test_token/test_modify_token[simple].yaml +++ b/tests/cassettes/test_token/test_modify_token[simple].yaml @@ -1,13 +1,14 @@ interactions: - request: - body: '{"name": "", "perm_manage_tokens": false}' + body: '{"name": "", "perm_manage_tokens": false, "perm_create_domain": false, + "perm_delete_domain": false, "auto_policy": false}' headers: Accept: - '*/*' Accept-Encoding: - gzip, deflate Content-Length: - - '41' + - '121' Content-Type: - application/json authorization: @@ -16,7 +17,7 @@ interactions: uri: https://desec.io/api/v1/auth/tokens/ response: body: - string: '{"id":"da43c435-dbfc-469f-80a3-1425bb810558","created":"2024-01-01T00:00:00.000000Z","last_used":null,"max_age":null,"max_unused_period":null,"name":"","perm_manage_tokens":false,"allowed_subnets":["0.0.0.0/0","::/0"],"is_valid":true,"token":"pM2Q2kMFzPYK9ZJzAPDdqAno5X92"}' + string: '{"id":"2613bace-0feb-4f8b-8222-b027f45cfca3","created":"2024-01-01T00:00:00.000000Z","last_used":null,"max_age":null,"max_unused_period":null,"name":"","perm_create_domain":false,"perm_delete_domain":false,"perm_manage_tokens":false,"allowed_subnets":["0.0.0.0/0","::/0"],"auto_policy":false,"is_valid":true,"token":"Wy6aV9MRVJBUzaz5JiQU5woVmwNk"}' headers: Allow: - GET, POST, HEAD, OPTIONS @@ -25,7 +26,7 @@ interactions: Connection: - keep-alive Content-Length: - - '273' + - '347' Content-Type: - application/json Date: @@ -55,10 +56,10 @@ interactions: authorization: - Token XXXXXXXX method: PATCH - uri: https://desec.io/api/v1/auth/tokens/da43c435-dbfc-469f-80a3-1425bb810558/ + uri: https://desec.io/api/v1/auth/tokens/2613bace-0feb-4f8b-8222-b027f45cfca3/ response: body: - string: '{"id":"da43c435-dbfc-469f-80a3-1425bb810558","created":"2024-01-01T00:00:00.000000Z","last_used":null,"max_age":null,"max_unused_period":null,"name":"","perm_manage_tokens":false,"allowed_subnets":["0.0.0.0/0","::/0"],"is_valid":true}' + string: '{"id":"2613bace-0feb-4f8b-8222-b027f45cfca3","created":"2024-01-01T00:00:00.000000Z","last_used":null,"max_age":null,"max_unused_period":null,"name":"","perm_create_domain":false,"perm_delete_domain":false,"perm_manage_tokens":false,"allowed_subnets":["0.0.0.0/0","::/0"],"auto_policy":false,"is_valid":true}' headers: Allow: - GET, PUT, PATCH, DELETE, HEAD, OPTIONS @@ -67,7 +68,7 @@ interactions: Connection: - keep-alive Content-Length: - - '234' + - '308' Content-Type: - application/json Date: @@ -95,7 +96,7 @@ interactions: authorization: - Token XXXXXXXX method: DELETE - uri: https://desec.io/api/v1/auth/tokens/da43c435-dbfc-469f-80a3-1425bb810558/ + uri: https://desec.io/api/v1/auth/tokens/2613bace-0feb-4f8b-8222-b027f45cfca3/ response: body: string: '' diff --git a/tests/test_token.py b/tests/test_token.py index 70595fe..4618a05 100644 --- a/tests/test_token.py +++ b/tests/test_token.py @@ -21,16 +21,28 @@ def test_list_tokens(api_client): {"name": "test-suite"}, {"manage_tokens": True}, {"manage_tokens": False}, + {"create_domain": True}, + {"create_domain": False}, + {"delete_domain": True}, + {"delete_domain": False}, {"allowed_subnets": ["192.0.2.0/24", "2001:db8::/32"]}, {"allowed_subnets": None}, + {"auto_policy": True}, + {"auto_policy": False}, ], ids=[ "simple", "named", "perm_manage_tokens", "no_perm_manage_tokens", + "perm_create_domain", + "no_perm_create_domain", + "perm_delete_domain", + "no_perm_delete_domain", "restricted_subnets", "all_subnets", + "auto_policy", + "no_auto_policy", ], ) def test_create_token(request, api_client, new_token_params): @@ -59,6 +71,10 @@ def _cleanup_tokens(): for key, value in new_token_params.items(): if key == "manage_tokens": key = "perm_manage_tokens" + elif key == "create_domain": + key = "perm_create_domain" + elif key == "delete_domain": + key = "perm_delete_domain" elif key == "allowed_subnets" and value is None: value = ["0.0.0.0/0", "::/0"] assert token[key] == value @@ -72,14 +88,26 @@ def _cleanup_tokens(): {"name": "test-suite"}, {"manage_tokens": True}, {"manage_tokens": False}, + {"create_domain": True}, + {"create_domain": False}, + {"delete_domain": True}, + {"delete_domain": False}, {"allowed_subnets": ["192.0.2.0/24", "2001:db8::/32"]}, + {"auto_policy": True}, + {"auto_policy": False}, ], ids=[ "simple", "named", "perm_manage_tokens", "no_perm_manage_tokens", + "perm_create_domain", + "no_perm_create_domain", + "perm_delete_domain", + "no_perm_delete_domain", "restricted_subnets", + "auto_policy", + "no_auto_policy", ], ) def test_modify_token(api_client, new_token, changed_token_params): @@ -87,7 +115,12 @@ def test_modify_token(api_client, new_token, changed_token_params): Assert that the API returns a token according to the given parameters. """ - new_token_params = {"manage_tokens": not changed_token_params.get("manage_tokens", True)} + new_token_params = { + "manage_tokens": not changed_token_params.get("manage_tokens", True), + "create_domain": not changed_token_params.get("create_domain", True), + "delete_domain": not changed_token_params.get("delete_domain", True), + "auto_policy": not changed_token_params.get("auto_policy", True), + } token = new_token(**new_token_params) modified_token = api_client.modify_token(token["id"], **changed_token_params) @@ -97,12 +130,21 @@ def test_modify_token(api_client, new_token, changed_token_params): for key, value in changed_token_params.items(): if key == "manage_tokens": key = "perm_manage_tokens" + elif key == "create_domain": + key = "perm_create_domain" + elif key == "delete_domain": + key = "perm_delete_domain" assert modified_token[key] == value # Assert that fields that were not modified did not change. for key in modified_token: - if key not in [ - "perm_manage_tokens" if k == "manage_tokens" else k for k in changed_token_params - ]: + param = key + if key == "perm_manage_tokens": + param = "manage_tokens" + elif key == "perm_create_domain": + param = "create_domain" + elif key == "perm_delete_domain": + param = "delete_domain" + if param not in changed_token_params: assert token[key] == modified_token[key]