Skip to content

Commit 44689b7

Browse files
committed
test(keymanager): add tests and cassettes for algorithm parameter
1 parent f4084d5 commit 44689b7

File tree

2 files changed

+310
-0
lines changed

2 files changed

+310
-0
lines changed

internal/services/keymanager/key_resource_test.go

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,3 +158,65 @@ func TestAccKeyManagerKey_WithRotationPolicy(t *testing.T) {
158158
},
159159
})
160160
}
161+
162+
func TestAccKeyManagerKey_WithCustomAlgorithm(t *testing.T) {
163+
tt := acctest.NewTestTools(t)
164+
defer tt.Cleanup()
165+
166+
resource.ParallelTest(t, resource.TestCase{
167+
PreCheck: func() { acctest.PreCheck(t) },
168+
ProtoV6ProviderFactories: tt.ProviderFactories,
169+
CheckDestroy: IsKeyManagerKeyDestroyed(tt),
170+
Steps: []resource.TestStep{
171+
{
172+
Config: `
173+
resource "scaleway_key_manager_key" "rsa_4096" {
174+
name = "tf-test-kms-key-rsa4096"
175+
region = "fr-par"
176+
usage = "asymmetric_encryption"
177+
algorithm = "rsa_oaep_4096_sha256"
178+
description = "Test key with RSA-4096 algorithm"
179+
unprotected = true
180+
}
181+
`,
182+
Check: resource.ComposeTestCheckFunc(
183+
resource.TestCheckResourceAttr("scaleway_key_manager_key.rsa_4096", "name", "tf-test-kms-key-rsa4096"),
184+
resource.TestCheckResourceAttr("scaleway_key_manager_key.rsa_4096", "usage", "asymmetric_encryption"),
185+
resource.TestCheckResourceAttr("scaleway_key_manager_key.rsa_4096", "algorithm", "rsa_oaep_4096_sha256"),
186+
resource.TestCheckResourceAttr("scaleway_key_manager_key.rsa_4096", "description", "Test key with RSA-4096 algorithm"),
187+
),
188+
},
189+
},
190+
})
191+
}
192+
193+
func TestAccKeyManagerKey_DefaultAlgorithm(t *testing.T) {
194+
tt := acctest.NewTestTools(t)
195+
defer tt.Cleanup()
196+
197+
resource.ParallelTest(t, resource.TestCase{
198+
PreCheck: func() { acctest.PreCheck(t) },
199+
ProtoV6ProviderFactories: tt.ProviderFactories,
200+
CheckDestroy: IsKeyManagerKeyDestroyed(tt),
201+
Steps: []resource.TestStep{
202+
{
203+
Config: `
204+
resource "scaleway_key_manager_key" "default_alg" {
205+
name = "tf-test-kms-key-default-alg"
206+
region = "fr-par"
207+
usage = "asymmetric_encryption"
208+
description = "Test key with default algorithm"
209+
unprotected = true
210+
}
211+
`,
212+
Check: resource.ComposeTestCheckFunc(
213+
resource.TestCheckResourceAttr("scaleway_key_manager_key.default_alg", "name", "tf-test-kms-key-default-alg"),
214+
resource.TestCheckResourceAttr("scaleway_key_manager_key.default_alg", "usage", "asymmetric_encryption"),
215+
// Verify default algorithm is set (RSA-OAEP-3072-SHA256)
216+
resource.TestCheckResourceAttr("scaleway_key_manager_key.default_alg", "algorithm", "rsa_oaep_3072_sha256"),
217+
resource.TestCheckResourceAttr("scaleway_key_manager_key.default_alg", "description", "Test key with default algorithm"),
218+
),
219+
},
220+
},
221+
})
222+
}
Lines changed: 248 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,248 @@
1+
---
2+
version: 2
3+
interactions:
4+
- id: 0
5+
request:
6+
proto: HTTP/1.1
7+
proto_major: 1
8+
proto_minor: 1
9+
content_length: 252
10+
transfer_encoding: []
11+
trailer: {}
12+
host: api.scaleway.com
13+
remote_addr: ""
14+
request_uri: ""
15+
body: '{"project_id":"105bdce1-64c0-48ab-899d-868455867ecf","name":"tf-test-kms-key-default-alg","usage":{"asymmetric_encryption":"rsa_oaep_3072_sha256"},"description":"Test key with default algorithm","tags":null,"unprotected":true,"origin":"unknown_origin"}'
16+
form: {}
17+
headers:
18+
Content-Type:
19+
- application/json
20+
User-Agent:
21+
- scaleway-sdk-go/v1.0.0-beta.7+dev (go1.25.0; darwin; arm64) terraform-provider/develop terraform/terraform-tests
22+
url: https://api.scaleway.com/key-manager/v1alpha1/regions/fr-par/keys
23+
method: POST
24+
response:
25+
proto: HTTP/2.0
26+
proto_major: 2
27+
proto_minor: 0
28+
transfer_encoding: []
29+
trailer: {}
30+
content_length: 558
31+
uncompressed: false
32+
body: '{"created_at":"2025-10-13T13:07:50.991520Z","deletion_requested_at":null,"description":"Test key with default algorithm","id":"baf818b5-31fd-4c47-a46a-b7c94235f846","locked":false,"name":"tf-test-kms-key-default-alg","origin":"scaleway_kms","project_id":"105bdce1-64c0-48ab-899d-868455867ecf","protected":false,"region":"fr-par","rotated_at":"2025-10-13T13:07:51.237551Z","rotation_count":1,"rotation_policy":null,"state":"enabled","tags":[],"updated_at":"2025-10-13T13:07:51.237551Z","usage":{"asymmetric_encryption":"rsa_oaep_3072_sha256"}}'
33+
headers:
34+
Content-Length:
35+
- "558"
36+
Content-Security-Policy:
37+
- default-src 'none'; frame-ancestors 'none'
38+
Content-Type:
39+
- application/json
40+
Date:
41+
- Mon, 13 Oct 2025 13:07:51 GMT
42+
Server:
43+
- Scaleway API Gateway (fr-par-1;edge01)
44+
Strict-Transport-Security:
45+
- max-age=63072000
46+
X-Content-Type-Options:
47+
- nosniff
48+
X-Frame-Options:
49+
- DENY
50+
X-Request-Id:
51+
- bcb9f4c9-05da-42ae-8e7d-c5d88f22227b
52+
status: 200 OK
53+
code: 200
54+
duration: 689.005709ms
55+
- id: 1
56+
request:
57+
proto: HTTP/1.1
58+
proto_major: 1
59+
proto_minor: 1
60+
content_length: 0
61+
transfer_encoding: []
62+
trailer: {}
63+
host: api.scaleway.com
64+
remote_addr: ""
65+
request_uri: ""
66+
body: ""
67+
form: {}
68+
headers:
69+
User-Agent:
70+
- scaleway-sdk-go/v1.0.0-beta.7+dev (go1.25.0; darwin; arm64) terraform-provider/develop terraform/terraform-tests
71+
url: https://api.scaleway.com/key-manager/v1alpha1/regions/fr-par/keys/baf818b5-31fd-4c47-a46a-b7c94235f846
72+
method: GET
73+
response:
74+
proto: HTTP/2.0
75+
proto_major: 2
76+
proto_minor: 0
77+
transfer_encoding: []
78+
trailer: {}
79+
content_length: 558
80+
uncompressed: false
81+
body: '{"created_at":"2025-10-13T13:07:50.991520Z","deletion_requested_at":null,"description":"Test key with default algorithm","id":"baf818b5-31fd-4c47-a46a-b7c94235f846","locked":false,"name":"tf-test-kms-key-default-alg","origin":"scaleway_kms","project_id":"105bdce1-64c0-48ab-899d-868455867ecf","protected":false,"region":"fr-par","rotated_at":"2025-10-13T13:07:51.237551Z","rotation_count":1,"rotation_policy":null,"state":"enabled","tags":[],"updated_at":"2025-10-13T13:07:51.237551Z","usage":{"asymmetric_encryption":"rsa_oaep_3072_sha256"}}'
82+
headers:
83+
Content-Length:
84+
- "558"
85+
Content-Security-Policy:
86+
- default-src 'none'; frame-ancestors 'none'
87+
Content-Type:
88+
- application/json
89+
Date:
90+
- Mon, 13 Oct 2025 13:07:51 GMT
91+
Server:
92+
- Scaleway API Gateway (fr-par-1;edge01)
93+
Strict-Transport-Security:
94+
- max-age=63072000
95+
X-Content-Type-Options:
96+
- nosniff
97+
X-Frame-Options:
98+
- DENY
99+
X-Request-Id:
100+
- fc423909-73b9-429c-ab7d-c4e6be6d34c1
101+
status: 200 OK
102+
code: 200
103+
duration: 114.879833ms
104+
- id: 2
105+
request:
106+
proto: HTTP/1.1
107+
proto_major: 1
108+
proto_minor: 1
109+
content_length: 0
110+
transfer_encoding: []
111+
trailer: {}
112+
host: api.scaleway.com
113+
remote_addr: ""
114+
request_uri: ""
115+
body: ""
116+
form: {}
117+
headers:
118+
User-Agent:
119+
- scaleway-sdk-go/v1.0.0-beta.7+dev (go1.25.0; darwin; arm64) terraform-provider/develop terraform/terraform-tests
120+
url: https://api.scaleway.com/key-manager/v1alpha1/regions/fr-par/keys/baf818b5-31fd-4c47-a46a-b7c94235f846
121+
method: GET
122+
response:
123+
proto: HTTP/2.0
124+
proto_major: 2
125+
proto_minor: 0
126+
transfer_encoding: []
127+
trailer: {}
128+
content_length: 558
129+
uncompressed: false
130+
body: '{"created_at":"2025-10-13T13:07:50.991520Z","deletion_requested_at":null,"description":"Test key with default algorithm","id":"baf818b5-31fd-4c47-a46a-b7c94235f846","locked":false,"name":"tf-test-kms-key-default-alg","origin":"scaleway_kms","project_id":"105bdce1-64c0-48ab-899d-868455867ecf","protected":false,"region":"fr-par","rotated_at":"2025-10-13T13:07:51.237551Z","rotation_count":1,"rotation_policy":null,"state":"enabled","tags":[],"updated_at":"2025-10-13T13:07:51.237551Z","usage":{"asymmetric_encryption":"rsa_oaep_3072_sha256"}}'
131+
headers:
132+
Content-Length:
133+
- "558"
134+
Content-Security-Policy:
135+
- default-src 'none'; frame-ancestors 'none'
136+
Content-Type:
137+
- application/json
138+
Date:
139+
- Mon, 13 Oct 2025 13:07:52 GMT
140+
Server:
141+
- Scaleway API Gateway (fr-par-1;edge01)
142+
Strict-Transport-Security:
143+
- max-age=63072000
144+
X-Content-Type-Options:
145+
- nosniff
146+
X-Frame-Options:
147+
- DENY
148+
X-Request-Id:
149+
- 70fe484e-eacc-4ca8-8d94-8dc2f32b6619
150+
status: 200 OK
151+
code: 200
152+
duration: 80.017334ms
153+
- id: 3
154+
request:
155+
proto: HTTP/1.1
156+
proto_major: 1
157+
proto_minor: 1
158+
content_length: 0
159+
transfer_encoding: []
160+
trailer: {}
161+
host: api.scaleway.com
162+
remote_addr: ""
163+
request_uri: ""
164+
body: ""
165+
form: {}
166+
headers:
167+
User-Agent:
168+
- scaleway-sdk-go/v1.0.0-beta.7+dev (go1.25.0; darwin; arm64) terraform-provider/develop terraform/terraform-tests
169+
url: https://api.scaleway.com/key-manager/v1alpha1/regions/fr-par/keys/baf818b5-31fd-4c47-a46a-b7c94235f846
170+
method: DELETE
171+
response:
172+
proto: HTTP/2.0
173+
proto_major: 2
174+
proto_minor: 0
175+
transfer_encoding: []
176+
trailer: {}
177+
content_length: 0
178+
uncompressed: false
179+
body: ""
180+
headers:
181+
Content-Security-Policy:
182+
- default-src 'none'; frame-ancestors 'none'
183+
Content-Type:
184+
- application/json
185+
Date:
186+
- Mon, 13 Oct 2025 13:07:53 GMT
187+
Server:
188+
- Scaleway API Gateway (fr-par-1;edge01)
189+
Strict-Transport-Security:
190+
- max-age=63072000
191+
X-Content-Type-Options:
192+
- nosniff
193+
X-Frame-Options:
194+
- DENY
195+
X-Request-Id:
196+
- de543f3b-0dbc-41f0-97da-b5ae01530ad8
197+
status: 204 No Content
198+
code: 204
199+
duration: 116.667042ms
200+
- id: 4
201+
request:
202+
proto: HTTP/1.1
203+
proto_major: 1
204+
proto_minor: 1
205+
content_length: 0
206+
transfer_encoding: []
207+
trailer: {}
208+
host: api.scaleway.com
209+
remote_addr: ""
210+
request_uri: ""
211+
body: ""
212+
form: {}
213+
headers:
214+
User-Agent:
215+
- scaleway-sdk-go/v1.0.0-beta.7+dev (go1.25.0; darwin; arm64) terraform-provider/develop terraform/terraform-tests
216+
url: https://api.scaleway.com/key-manager/v1alpha1/regions/fr-par/keys/baf818b5-31fd-4c47-a46a-b7c94235f846
217+
method: GET
218+
response:
219+
proto: HTTP/2.0
220+
proto_major: 2
221+
proto_minor: 0
222+
transfer_encoding: []
223+
trailer: {}
224+
content_length: 598
225+
uncompressed: false
226+
body: '{"created_at":"2025-10-13T13:07:50.991520Z","deletion_requested_at":"2025-10-13T13:07:53.439157Z","description":"Test key with default algorithm","id":"baf818b5-31fd-4c47-a46a-b7c94235f846","locked":false,"name":"tf-test-kms-key-default-alg","origin":"scaleway_kms","project_id":"105bdce1-64c0-48ab-899d-868455867ecf","protected":false,"region":"fr-par","rotated_at":"2025-10-13T13:07:51.237551Z","rotation_count":1,"rotation_policy":null,"state":"scheduled_for_deletion","tags":[],"updated_at":"2025-10-13T13:07:51.237551Z","usage":{"asymmetric_encryption":"rsa_oaep_3072_sha256"}}'
227+
headers:
228+
Content-Length:
229+
- "598"
230+
Content-Security-Policy:
231+
- default-src 'none'; frame-ancestors 'none'
232+
Content-Type:
233+
- application/json
234+
Date:
235+
- Mon, 13 Oct 2025 13:07:53 GMT
236+
Server:
237+
- Scaleway API Gateway (fr-par-1;edge01)
238+
Strict-Transport-Security:
239+
- max-age=63072000
240+
X-Content-Type-Options:
241+
- nosniff
242+
X-Frame-Options:
243+
- DENY
244+
X-Request-Id:
245+
- 08bc6c01-e929-405d-a08d-a7481cf014ef
246+
status: 200 OK
247+
code: 200
248+
duration: 25.58425ms

0 commit comments

Comments
 (0)