Skip to content

Commit 3ed0466

Browse files
authored
Creates negative test cases for ACLP Metrics & Alerts (#818)
* Creates negative test cases for ACLP Metrics & Alerts * Adds missing fixture files
1 parent 706e083 commit 3ed0466

File tree

6 files changed

+186
-0
lines changed

6 files changed

+186
-0
lines changed
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
---
2+
version: 1
3+
interactions:
4+
- request:
5+
body: ""
6+
form: {}
7+
headers:
8+
Accept:
9+
- application/json
10+
Content-Type:
11+
- application/json
12+
User-Agent:
13+
- linodego/dev https://github.com/linode/linodego
14+
url: https://api.linode.com/v4beta/monitor/dashboards/999999
15+
method: GET
16+
response:
17+
body: '{"errors": [{"reason": "Not found"}]}'
18+
headers:
19+
Access-Control-Allow-Headers:
20+
- Authorization, Origin, X-Requested-With, Content-Type, Accept, X-Filter
21+
Access-Control-Allow-Methods:
22+
- HEAD, GET, OPTIONS, POST, PUT, DELETE
23+
Access-Control-Allow-Origin:
24+
- '*'
25+
Akamai-Internal-Account:
26+
- '*'
27+
Cache-Control:
28+
- private, max-age=0, s-maxage=0, no-cache, no-store
29+
Connection:
30+
- keep-alive
31+
Content-Length:
32+
- "37"
33+
Content-Type:
34+
- application/json
35+
Server:
36+
- nginx/1.18.0
37+
Strict-Transport-Security:
38+
- max-age=31536000
39+
Vary:
40+
- Authorization, X-Filter
41+
X-Accepted-Oauth-Scopes:
42+
- monitor:read_only
43+
X-Frame-Options:
44+
- DENY
45+
X-Oauth-Scopes:
46+
- '*'
47+
X-Ratelimit-Limit:
48+
- "400"
49+
status: 404 NOT FOUND
50+
code: 404
51+
duration: ""
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
---
2+
version: 1
3+
interactions:
4+
- request:
5+
body: ""
6+
form: {}
7+
headers:
8+
Accept:
9+
- application/json
10+
Content-Type:
11+
- application/json
12+
User-Agent:
13+
- linodego/dev https://github.com/linode/linodego
14+
url: https://api.linode.com/v4beta/monitor/services/saas?page=1
15+
method: GET
16+
response:
17+
body: '{"errors": [{"reason": "Not found"}]}'
18+
headers:
19+
Access-Control-Allow-Headers:
20+
- Authorization, Origin, X-Requested-With, Content-Type, Accept, X-Filter
21+
Access-Control-Allow-Methods:
22+
- HEAD, GET, OPTIONS, POST, PUT, DELETE
23+
Access-Control-Allow-Origin:
24+
- '*'
25+
Akamai-Internal-Account:
26+
- '*'
27+
Cache-Control:
28+
- private, max-age=0, s-maxage=0, no-cache, no-store
29+
Connection:
30+
- keep-alive
31+
Content-Length:
32+
- "37"
33+
Content-Type:
34+
- application/json
35+
Server:
36+
- nginx/1.18.0
37+
Strict-Transport-Security:
38+
- max-age=31536000
39+
Vary:
40+
- Authorization, X-Filter
41+
X-Accepted-Oauth-Scopes:
42+
- monitor:read_only
43+
X-Frame-Options:
44+
- DENY
45+
X-Oauth-Scopes:
46+
- '*'
47+
X-Ratelimit-Limit:
48+
- "400"
49+
status: 404 NOT FOUND
50+
code: 404
51+
duration: ""
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
---
2+
version: 1
3+
interactions:
4+
- request:
5+
body: '{"entity_ids":[999999999]}'
6+
form: {}
7+
headers:
8+
Accept:
9+
- application/json
10+
Content-Type:
11+
- application/json
12+
User-Agent:
13+
- linodego/dev https://github.com/linode/linodego
14+
url: https://api.linode.com/v4beta/monitor/services/dbaas/token
15+
method: POST
16+
response:
17+
body: '{"errors": [{"reason": "The following entity_ids are not valid - [999999999]",
18+
"field": "entity_ids"}]}'
19+
headers:
20+
Access-Control-Allow-Headers:
21+
- Authorization, Origin, X-Requested-With, Content-Type, Accept, X-Filter
22+
Access-Control-Allow-Methods:
23+
- HEAD, GET, OPTIONS, POST, PUT, DELETE
24+
Access-Control-Allow-Origin:
25+
- '*'
26+
Akamai-Internal-Account:
27+
- '*'
28+
Connection:
29+
- keep-alive
30+
Content-Length:
31+
- "103"
32+
Content-Type:
33+
- application/json
34+
Server:
35+
- nginx/1.18.0
36+
Strict-Transport-Security:
37+
- max-age=31536000
38+
X-Accepted-Oauth-Scopes:
39+
- databases:read_only
40+
X-Frame-Options:
41+
- DENY
42+
X-Oauth-Scopes:
43+
- '*'
44+
X-Ratelimit-Limit:
45+
- "400"
46+
status: 403 FORBIDDEN
47+
code: 403
48+
duration: ""

test/integration/monitor_dashboards_test.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import (
55
"testing"
66

77
"github.com/linode/linodego"
8+
"github.com/stretchr/testify/assert"
89
"github.com/stretchr/testify/require"
910
)
1011

@@ -58,6 +59,15 @@ func TestMonitorDashboards_Get_smoke(t *testing.T) {
5859
}
5960
}
6061

62+
func TestMonitorDashboards_GetNotExistingDashboardID(t *testing.T) {
63+
client, teardown := createTestClient(t, "fixtures/TestMonitorInvalidDashboard_Get")
64+
defer teardown()
65+
66+
_, getErr := client.GetMonitorDashboard(context.Background(), 999999)
67+
require.Error(t, getErr)
68+
assert.Contains(t, getErr.Error(), "[404] Not found")
69+
}
70+
6171
func validateDashboards(
6272
t *testing.T,
6373
dashboards linodego.MonitorDashboard,

test/integration/monitor_services_test.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import (
55
"testing"
66

77
"github.com/linode/linodego"
8+
"github.com/stretchr/testify/assert"
89
"github.com/stretchr/testify/require"
910
)
1011

@@ -41,6 +42,15 @@ func TestMonitorServices_Get_smoke(t *testing.T) {
4142
}
4243
}
4344

45+
func TestMonitorServices_GetNotAllowedServiceType(t *testing.T) {
46+
client, teardown := createTestClient(t, "fixtures/TestMonitorNotAllowedServiceType_Get")
47+
defer teardown()
48+
49+
_, getErr := client.ListMonitorServiceByType(context.Background(), "saas", nil)
50+
require.Error(t, getErr)
51+
assert.Contains(t, getErr.Error(), "[404] Not found")
52+
}
53+
4454
func validateServiceTypes(
4555
t *testing.T,
4656
serviceType linodego.MonitorService,

test/integration/monitor_services_token_creation_test.go

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import (
55
"testing"
66

77
"github.com/linode/linodego"
8+
"github.com/stretchr/testify/assert"
89
"github.com/stretchr/testify/require"
910
)
1011

@@ -46,6 +47,21 @@ func TestMonitorServicesTokenCreation_Get_smoke(t *testing.T) {
4647
validateToken(t, *token)
4748
}
4849

50+
func TestMonitorServicesTokenCreation_TryCreateTokenWithInvalidEntityID(t *testing.T) {
51+
var entityIDs []any
52+
entityIDs = append(entityIDs, 999999999)
53+
54+
client, teardown := createTestClient(t, "fixtures/TestServiceTokenInvalidEntity_POST")
55+
defer teardown()
56+
createOptsWithInvalidID := linodego.MonitorTokenCreateOptions{
57+
EntityIDs: entityIDs,
58+
}
59+
_, createErr := client.CreateMonitorServiceTokenForServiceType(context.Background(), "dbaas", createOptsWithInvalidID)
60+
require.Error(t, createErr)
61+
assert.Contains(t, createErr.Error(), "[403]")
62+
assert.Contains(t, createErr.Error(), "The following entity_ids are not valid - [999999999]")
63+
}
64+
4965
func validateToken(
5066
t *testing.T,
5167
token linodego.MonitorServiceToken,

0 commit comments

Comments
 (0)