Skip to content

Commit 2ea12a9

Browse files
chore(iam): fix api-key listings tests (#5447)
1 parent 2d7cecf commit 2ea12a9

7 files changed

+151
-441
lines changed

internal/namespaces/iam/v1alpha1/custom_iam_test.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@ import (
1010
iamSdk "github.com/scaleway/scaleway-sdk-go/api/iam/v1alpha1"
1111
)
1212

13+
const (
14+
TestMemberID = "e7a35342-d125-42e3-a0d8-f2f378abd1de" // ID for the test-cli-iam-membership-api-key Member
15+
)
16+
1317
func Test_iamAPIKeyGet(t *testing.T) {
1418
if isNightly := os.Getenv("SLACK_WEBHOOK_NIGHTLY"); isNightly != "" {
1519
t.Skip()
@@ -77,7 +81,7 @@ func Test_iamAPIKeyGet(t *testing.T) {
7781
BeforeFunc: core.BeforeFuncCombine(
7882
core.ExecStoreBeforeCmdWithResulter(
7983
"member",
80-
"scw iam user list type=member",
84+
"scw iam user list type=member user-ids.0="+TestMemberID,
8185
userResulter,
8286
),
8387
core.ExecStoreBeforeCmdWithResulter(
@@ -112,7 +116,7 @@ func Test_iamAPIKeyGet(t *testing.T) {
112116
BeforeFunc: core.BeforeFuncCombine(
113117
core.ExecStoreBeforeCmdWithResulter(
114118
"application",
115-
"scw iam application list",
119+
"scw iam application list name=test-cli-iam-application-api-key",
116120
appResulter,
117121
),
118122
core.ExecStoreBeforeCmdWithResulter(

internal/namespaces/iam/v1alpha1/testdata/test-iam-api-key-get-get-application-api-key.cassette.yaml

Lines changed: 38 additions & 106 deletions
Original file line numberDiff line numberDiff line change
@@ -2,204 +2,136 @@
22
version: 1
33
interactions:
44
- request:
5-
body: '{"applications":[{"id":"fecc73d6-cb99-4fd5-8f3f-95870cb57228", "name":"test-cli-iam-application",
6-
"description":"", "created_at":"2025-10-23T13:15:19.801492Z", "updated_at":"2025-10-23T13:15:19.801492Z",
7-
"organization_id":"57a1e028-d7d3-4a4e-80cf-52cef8fd0d3e", "editable":true, "deletable":true,
8-
"managed":false, "nb_api_keys":1, "tags":[]}], "total_count":1}'
5+
body: '{"applications":[{"id":"ee684d01-4555-4b8e-afd7-ac7755e1e50e","name":"test-cli-iam-application-api-key","description":"API
6+
key used solely for nightly IAM API keys listing tests.","created_at":"2026-04-02T09:52:54.585231Z","updated_at":"2026-04-02T10:45:42.441201Z","organization_id":"5ebc0159-7cb7-406c-9521-9347d1987fb2","editable":true,"deletable":true,"managed":false,"nb_api_keys":1,"tags":[]}],"total_count":1}'
97
form: {}
108
headers:
119
User-Agent:
12-
- scaleway-sdk-go/v1.0.0-beta.7+dev (go1.25.3; linux; amd64) cli-e2e-test
13-
url: https://api.scaleway.com/iam/v1alpha1/applications?order_by=created_at_asc&organization_id=11111111-1111-1111-1111-111111111111&page=1
10+
- scaleway-sdk-go/v1.0.0-beta.7+dev (go1.26.1; linux; amd64) cli-e2e-test
11+
url: https://api.scaleway.com/iam/v1alpha1/applications?name=test-cli-iam-application-api-key&order_by=created_at_asc&organization_id=11111111-1111-1111-1111-111111111111&page=1
1412
method: GET
1513
response:
16-
body: '{"applications":[{"id":"fecc73d6-cb99-4fd5-8f3f-95870cb57228", "name":"test-cli-iam-application",
17-
"description":"", "created_at":"2025-10-23T13:15:19.801492Z", "updated_at":"2025-10-23T13:15:19.801492Z",
18-
"organization_id":"57a1e028-d7d3-4a4e-80cf-52cef8fd0d3e", "editable":true, "deletable":true,
19-
"managed":false, "nb_api_keys":1, "tags":[]}], "total_count":1}'
14+
body: '{"applications":[{"id":"ee684d01-4555-4b8e-afd7-ac7755e1e50e","name":"test-cli-iam-application-api-key","description":"API
15+
key used solely for nightly IAM API keys listing tests.","created_at":"2026-04-02T09:52:54.585231Z","updated_at":"2026-04-02T10:45:42.441201Z","organization_id":"5ebc0159-7cb7-406c-9521-9347d1987fb2","editable":true,"deletable":true,"managed":false,"nb_api_keys":1,"tags":[]}],"total_count":1}'
2016
headers:
2117
Content-Length:
22-
- "360"
18+
- "416"
2319
Content-Security-Policy:
2420
- default-src 'none'; frame-ancestors 'none'
2521
Content-Type:
2622
- application/json
2723
Date:
28-
- Thu, 23 Oct 2025 13:27:06 GMT
24+
- Thu, 02 Apr 2026 10:48:06 GMT
2925
Server:
30-
- Scaleway API Gateway (fr-par-1;edge02)
26+
- Scaleway API Gateway (fr-par-1;edge03)
3127
Strict-Transport-Security:
3228
- max-age=63072000
3329
X-Content-Type-Options:
3430
- nosniff
3531
X-Frame-Options:
3632
- DENY
3733
X-Request-Id:
38-
- 421c23af-6822-449e-ac72-0500ff23d0e7
34+
- ff3345f6-694d-4ff8-a089-8d4fcaa7ba11
3935
status: 200 OK
4036
code: 200
4137
duration: ""
4238
- request:
43-
body: '{"api_keys":[{"access_key":"SCWW3T9S86AVRK3Z0WM9", "secret_key":null, "description":"test-cli-iam-application-api-key",
44-
"created_at":"2025-10-23T13:15:42.574651Z", "updated_at":"2025-10-23T13:15:42.574651Z",
45-
"expires_at":"2026-10-23T13:15:42.501Z", "default_project_id":"57a1e028-d7d3-4a4e-80cf-52cef8fd0d3e",
46-
"editable":true, "deletable":true, "managed":false, "creation_ip":"51.159.73.145",
47-
"application_id":"fecc73d6-cb99-4fd5-8f3f-95870cb57228"}], "total_count":1}'
39+
body: '{"api_keys":[{"access_key":"SCWZ2CNKDJ217YMA8XFD","secret_key":null,"description":"API
40+
key used solely for nightly IAM API keys listing tests.","created_at":"2026-04-02T10:46:26.282392Z","updated_at":"2026-04-02T10:46:56.166254Z","expires_at":null,"default_project_id":"5ebc0159-7cb7-406c-9521-9347d1987fb2","editable":true,"deletable":true,"managed":false,"creation_ip":"51.159.73.9","application_id":"ee684d01-4555-4b8e-afd7-ac7755e1e50e"}],"total_count":1}'
4841
form: {}
4942
headers:
5043
User-Agent:
51-
- scaleway-sdk-go/v1.0.0-beta.7+dev (go1.25.3; linux; amd64) cli-e2e-test
52-
url: https://api.scaleway.com/iam/v1alpha1/api-keys?bearer_id=fecc73d6-cb99-4fd5-8f3f-95870cb57228&bearer_type=unknown_bearer_type&order_by=created_at_asc&organization_id=11111111-1111-1111-1111-111111111111&page=1
44+
- scaleway-sdk-go/v1.0.0-beta.7+dev (go1.26.1; linux; amd64) cli-e2e-test
45+
url: https://api.scaleway.com/iam/v1alpha1/api-keys?bearer_id=ee684d01-4555-4b8e-afd7-ac7755e1e50e&bearer_type=unknown_bearer_type&order_by=created_at_asc&organization_id=11111111-1111-1111-1111-111111111111&page=1
5346
method: GET
5447
response:
55-
body: '{"api_keys":[{"access_key":"SCWW3T9S86AVRK3Z0WM9", "secret_key":null, "description":"test-cli-iam-application-api-key",
56-
"created_at":"2025-10-23T13:15:42.574651Z", "updated_at":"2025-10-23T13:15:42.574651Z",
57-
"expires_at":"2026-10-23T13:15:42.501Z", "default_project_id":"57a1e028-d7d3-4a4e-80cf-52cef8fd0d3e",
58-
"editable":true, "deletable":true, "managed":false, "creation_ip":"51.159.73.145",
59-
"application_id":"fecc73d6-cb99-4fd5-8f3f-95870cb57228"}], "total_count":1}'
48+
body: '{"api_keys":[{"access_key":"SCWZ2CNKDJ217YMA8XFD","secret_key":null,"description":"API
49+
key used solely for nightly IAM API keys listing tests.","created_at":"2026-04-02T10:46:26.282392Z","updated_at":"2026-04-02T10:46:56.166254Z","expires_at":null,"default_project_id":"5ebc0159-7cb7-406c-9521-9347d1987fb2","editable":true,"deletable":true,"managed":false,"creation_ip":"51.159.73.9","application_id":"ee684d01-4555-4b8e-afd7-ac7755e1e50e"}],"total_count":1}'
6050
headers:
6151
Content-Length:
62-
- "468"
52+
- "459"
6353
Content-Security-Policy:
6454
- default-src 'none'; frame-ancestors 'none'
6555
Content-Type:
6656
- application/json
6757
Date:
68-
- Thu, 23 Oct 2025 13:27:06 GMT
58+
- Thu, 02 Apr 2026 10:48:06 GMT
6959
Server:
70-
- Scaleway API Gateway (fr-par-1;edge02)
60+
- Scaleway API Gateway (fr-par-1;edge03)
7161
Strict-Transport-Security:
7262
- max-age=63072000
7363
X-Content-Type-Options:
7464
- nosniff
7565
X-Frame-Options:
7666
- DENY
7767
X-Request-Id:
78-
- 444f9dcf-6600-4551-ade5-97d5aa6e14eb
68+
- cb6d9822-8801-4e5e-b3a7-2483c881f020
7969
status: 200 OK
8070
code: 200
8171
duration: ""
8272
- request:
83-
body: '{"access_key":"SCWW3T9S86AVRK3Z0WM9", "secret_key":null, "description":"test-cli-iam-application-api-key",
84-
"created_at":"2025-10-23T13:15:42.574651Z", "updated_at":"2025-10-23T13:15:42.574651Z",
85-
"expires_at":"2026-10-23T13:15:42.501Z", "default_project_id":"57a1e028-d7d3-4a4e-80cf-52cef8fd0d3e",
86-
"editable":true, "deletable":true, "managed":false, "creation_ip":"51.159.73.145",
87-
"application_id":"fecc73d6-cb99-4fd5-8f3f-95870cb57228"}'
73+
body: '{"access_key":"SCWZ2CNKDJ217YMA8XFD","secret_key":null,"description":"API
74+
key used solely for nightly IAM API keys listing tests.","created_at":"2026-04-02T10:46:26.282392Z","updated_at":"2026-04-02T10:46:56.166254Z","expires_at":null,"default_project_id":"5ebc0159-7cb7-406c-9521-9347d1987fb2","editable":true,"deletable":true,"managed":false,"creation_ip":"51.159.73.9","application_id":"ee684d01-4555-4b8e-afd7-ac7755e1e50e"}'
8875
form: {}
8976
headers:
9077
User-Agent:
91-
- scaleway-sdk-go/v1.0.0-beta.7+dev (go1.25.3; linux; amd64) cli-e2e-test
92-
url: https://api.scaleway.com/iam/v1alpha1/api-keys/SCWW3T9S86AVRK3Z0WM9
78+
- scaleway-sdk-go/v1.0.0-beta.7+dev (go1.26.1; linux; amd64) cli-e2e-test
79+
url: https://api.scaleway.com/iam/v1alpha1/api-keys/SCWZ2CNKDJ217YMA8XFD
9380
method: GET
9481
response:
95-
body: '{"access_key":"SCWW3T9S86AVRK3Z0WM9", "secret_key":null, "description":"test-cli-iam-application-api-key",
96-
"created_at":"2025-10-23T13:15:42.574651Z", "updated_at":"2025-10-23T13:15:42.574651Z",
97-
"expires_at":"2026-10-23T13:15:42.501Z", "default_project_id":"57a1e028-d7d3-4a4e-80cf-52cef8fd0d3e",
98-
"editable":true, "deletable":true, "managed":false, "creation_ip":"51.159.73.145",
99-
"application_id":"fecc73d6-cb99-4fd5-8f3f-95870cb57228"}'
82+
body: '{"access_key":"SCWZ2CNKDJ217YMA8XFD","secret_key":null,"description":"API
83+
key used solely for nightly IAM API keys listing tests.","created_at":"2026-04-02T10:46:26.282392Z","updated_at":"2026-04-02T10:46:56.166254Z","expires_at":null,"default_project_id":"5ebc0159-7cb7-406c-9521-9347d1987fb2","editable":true,"deletable":true,"managed":false,"creation_ip":"51.159.73.9","application_id":"ee684d01-4555-4b8e-afd7-ac7755e1e50e"}'
10084
headers:
10185
Content-Length:
102-
- "436"
86+
- "428"
10387
Content-Security-Policy:
10488
- default-src 'none'; frame-ancestors 'none'
10589
Content-Type:
10690
- application/json
10791
Date:
108-
- Thu, 23 Oct 2025 13:27:06 GMT
92+
- Thu, 02 Apr 2026 10:48:06 GMT
10993
Server:
110-
- Scaleway API Gateway (fr-par-1;edge02)
94+
- Scaleway API Gateway (fr-par-1;edge03)
11195
Strict-Transport-Security:
11296
- max-age=63072000
11397
X-Content-Type-Options:
11498
- nosniff
11599
X-Frame-Options:
116100
- DENY
117101
X-Request-Id:
118-
- ff2e06cc-b974-4f31-8e1b-0c25d03022cc
102+
- 03e5bc4b-9ee8-47b0-9305-6054ed239f2f
119103
status: 200 OK
120104
code: 200
121105
duration: ""
122106
- request:
123-
body: '{"policies":[{"id":"e8a8bacc-d77a-4bdd-8b37-e63409000e62", "name":"Copy
124-
of Copy of Group - Editors", "description":"", "organization_id":"57a1e028-d7d3-4a4e-80cf-52cef8fd0d3e",
125-
"created_at":"2025-10-23T13:26:26.274486Z", "updated_at":"2025-10-23T13:26:26.274486Z",
126-
"editable":true, "deletable":true, "managed":false, "nb_rules":2, "nb_scopes":2,
127-
"nb_permission_sets":4, "tags":[], "application_id":"fecc73d6-cb99-4fd5-8f3f-95870cb57228"}],
128-
"total_count":1}'
107+
body: '{"policies":[],"total_count":0}'
129108
form: {}
130109
headers:
131110
User-Agent:
132-
- scaleway-sdk-go/v1.0.0-beta.7+dev (go1.25.3; linux; amd64) cli-e2e-test
133-
url: https://api.scaleway.com/iam/v1alpha1/policies?application_ids=fecc73d6-cb99-4fd5-8f3f-95870cb57228&order_by=policy_name_asc&organization_id=11111111-1111-1111-1111-111111111111&page=1
111+
- scaleway-sdk-go/v1.0.0-beta.7+dev (go1.26.1; linux; amd64) cli-e2e-test
112+
url: https://api.scaleway.com/iam/v1alpha1/policies?application_ids=ee684d01-4555-4b8e-afd7-ac7755e1e50e&order_by=policy_name_asc&organization_id=11111111-1111-1111-1111-111111111111&page=1
134113
method: GET
135114
response:
136-
body: '{"policies":[{"id":"e8a8bacc-d77a-4bdd-8b37-e63409000e62", "name":"Copy
137-
of Copy of Group - Editors", "description":"", "organization_id":"57a1e028-d7d3-4a4e-80cf-52cef8fd0d3e",
138-
"created_at":"2025-10-23T13:26:26.274486Z", "updated_at":"2025-10-23T13:26:26.274486Z",
139-
"editable":true, "deletable":true, "managed":false, "nb_rules":2, "nb_scopes":2,
140-
"nb_permission_sets":4, "tags":[], "application_id":"fecc73d6-cb99-4fd5-8f3f-95870cb57228"}],
141-
"total_count":1}'
115+
body: '{"policies":[],"total_count":0}'
142116
headers:
143117
Content-Length:
144-
- "456"
118+
- "31"
145119
Content-Security-Policy:
146120
- default-src 'none'; frame-ancestors 'none'
147121
Content-Type:
148122
- application/json
149123
Date:
150-
- Thu, 23 Oct 2025 13:27:06 GMT
124+
- Thu, 02 Apr 2026 10:48:07 GMT
151125
Server:
152-
- Scaleway API Gateway (fr-par-1;edge02)
126+
- Scaleway API Gateway (fr-par-1;edge03)
153127
Strict-Transport-Security:
154128
- max-age=63072000
155129
X-Content-Type-Options:
156130
- nosniff
157131
X-Frame-Options:
158132
- DENY
159133
X-Request-Id:
160-
- d1cc0476-3929-4cf7-a9f6-a0470ef5d2eb
161-
status: 200 OK
162-
code: 200
163-
duration: ""
164-
- request:
165-
body: '{"rules":[{"id":"b9dfe4b7-e455-4cd7-8ae1-6c122f4fbb56", "permission_set_names":["OrganizationReadOnly",
166-
"ProjectManager", "SupportTicketReadOnly"], "permission_sets_scope_type":"organization",
167-
"condition":"", "organization_id":"57a1e028-d7d3-4a4e-80cf-52cef8fd0d3e"}, {"id":"7679bf9e-bc63-4bde-be0f-f63e42ad2948",
168-
"permission_set_names":["AllProductsFullAccess"], "permission_sets_scope_type":"projects",
169-
"condition":"", "organization_id":"57a1e028-d7d3-4a4e-80cf-52cef8fd0d3e"}],
170-
"total_count":2}'
171-
form: {}
172-
headers:
173-
User-Agent:
174-
- scaleway-sdk-go/v1.0.0-beta.7+dev (go1.25.3; linux; amd64) cli-e2e-test
175-
url: https://api.scaleway.com/iam/v1alpha1/rules?policy_id=e8a8bacc-d77a-4bdd-8b37-e63409000e62
176-
method: GET
177-
response:
178-
body: '{"rules":[{"id":"b9dfe4b7-e455-4cd7-8ae1-6c122f4fbb56", "permission_set_names":["OrganizationReadOnly",
179-
"ProjectManager", "SupportTicketReadOnly"], "permission_sets_scope_type":"organization",
180-
"condition":"", "organization_id":"57a1e028-d7d3-4a4e-80cf-52cef8fd0d3e"}, {"id":"7679bf9e-bc63-4bde-be0f-f63e42ad2948",
181-
"permission_set_names":["AllProductsFullAccess"], "permission_sets_scope_type":"projects",
182-
"condition":"", "organization_id":"57a1e028-d7d3-4a4e-80cf-52cef8fd0d3e"}],
183-
"total_count":2}'
184-
headers:
185-
Content-Length:
186-
- "497"
187-
Content-Security-Policy:
188-
- default-src 'none'; frame-ancestors 'none'
189-
Content-Type:
190-
- application/json
191-
Date:
192-
- Thu, 23 Oct 2025 13:27:06 GMT
193-
Server:
194-
- Scaleway API Gateway (fr-par-1;edge02)
195-
Strict-Transport-Security:
196-
- max-age=63072000
197-
X-Content-Type-Options:
198-
- nosniff
199-
X-Frame-Options:
200-
- DENY
201-
X-Request-Id:
202-
- dd8947d0-82d7-4836-b36c-bc28a6ed6188
134+
- 9dd10322-77c7-4297-b765-f11fa466986a
203135
status: 200 OK
204136
code: 200
205137
duration: ""

internal/namespaces/iam/v1alpha1/testdata/test-iam-api-key-get-get-application-api-key.golden

Lines changed: 12 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -4,43 +4,34 @@ Entity Type:
44
application
55

66
Api Key:
7-
AccessKey SCWW3T9S86AVRK3Z0WM9
8-
ApplicationID fecc73d6-cb99-4fd5-8f3f-95870cb57228
9-
Description test-cli-iam-application-api-key
7+
AccessKey SCWZ2CNKDJ217YMA8XFD
8+
ApplicationID ee684d01-4555-4b8e-afd7-ac7755e1e50e
9+
Description API key used solely for nightly IAM API keys listing tests.
1010
CreatedAt few seconds ago
1111
UpdatedAt few seconds ago
12-
ExpiresAt few seconds ago
13-
DefaultProjectID 57a1e028-d7d3-4a4e-80cf-52cef8fd0d3e
12+
DefaultProjectID 5ebc0159-7cb7-406c-9521-9347d1987fb2
1413
Editable true
1514
Deletable true
1615
Managed false
17-
CreationIP 51.159.73.145
16+
CreationIP 51.159.73.9
1817

1918
Policies:
20-
Copy of Copy of Group - Editors (e8a8bacc-d77a-4bdd-8b37-e63409000e62) AllProductsFullAccess OrganizationReadOnly ProjectManager SupportTicketReadOnly
2119
🟩🟩🟩 JSON STDOUT 🟩🟩🟩
2220
{
2321
"APIKey": {
24-
"access_key": "SCWW3T9S86AVRK3Z0WM9",
22+
"access_key": "SCWZ2CNKDJ217YMA8XFD",
2523
"secret_key": null,
26-
"application_id": "fecc73d6-cb99-4fd5-8f3f-95870cb57228",
27-
"description": "test-cli-iam-application-api-key",
24+
"application_id": "ee684d01-4555-4b8e-afd7-ac7755e1e50e",
25+
"description": "API key used solely for nightly IAM API keys listing tests.",
2826
"created_at": "1970-01-01T00:00:00.0Z",
2927
"updated_at": "1970-01-01T00:00:00.0Z",
30-
"expires_at": "1970-01-01T00:00:00.0Z",
31-
"default_project_id": "57a1e028-d7d3-4a4e-80cf-52cef8fd0d3e",
28+
"expires_at": null,
29+
"default_project_id": "5ebc0159-7cb7-406c-9521-9347d1987fb2",
3230
"editable": true,
3331
"deletable": true,
3432
"managed": false,
35-
"creation_ip": "51.159.73.145"
33+
"creation_ip": "51.159.73.9"
3634
},
3735
"entity_type": "application",
38-
"policies": {
39-
"Copy of Copy of Group - Editors (e8a8bacc-d77a-4bdd-8b37-e63409000e62)": [
40-
"AllProductsFullAccess",
41-
"OrganizationReadOnly",
42-
"ProjectManager",
43-
"SupportTicketReadOnly"
44-
]
45-
}
36+
"policies": {}
4637
}

0 commit comments

Comments
 (0)