-
Notifications
You must be signed in to change notification settings - Fork 243
/
audit_test.go
95 lines (88 loc) · 2.85 KB
/
audit_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
package pagerduty
import (
"context"
"net/http"
"testing"
)
func TestAudit_List(t *testing.T) {
setup()
defer teardown()
mux.HandleFunc("/audit/records", func(w http.ResponseWriter, r *http.Request) {
testMethod(t, r, http.MethodGet)
_, _ = w.Write([]byte(`{"records":[{"id":"PDRECORDID4_UPDATED_USERS_NOTIFICATION_RULE","execution_time":"2020-06-04T15:30:16.272Z","execution_context":{"request_id":"222lDEOIH-534-4ljhLHJjh222","remote_address":"201.19.20.19"},"actors":[{"id":"PDUSER","summary":"John Snow","type":"user_reference"}],"method":{"type":"api_token","truncated_token":"2adm"},"root_resource":{"id":"PDUSER","type":"user_reference","summary":"John Snow"},"action":"update","details":{"resource":{"id":"PXOGWUS","type":"assignment_notification_rule_reference","summary":"0 minutes: channel P1IAAPZ"},"fields":[{"name":"start_delay_in_minutes","before_value":"0","value":"2"}],"references":[{"name":"contact_method","removed":[{"id":"POE6L88","type":"push_notification_contact_method_reference","summary":"Pixel 3"}],"added":[{"id":"P4GTUMK","type":"sms_contact_method_reference","summary":"Mobile"}]}]}}],"next_cursor":null,"limit":10}`))
})
client := defaultTestClient(server.URL, "foo")
recordOpts := ListAuditRecordsOptions{
Limit: 10,
Cursor: "",
}
resp, err := client.ListAuditRecords(context.Background(), recordOpts)
if err != nil {
t.Fatal(err)
}
want := ListAuditRecordsResponse{
Records: []AuditRecord{
{
ID: "PDRECORDID4_UPDATED_USERS_NOTIFICATION_RULE",
ExecutionTime: "2020-06-04T15:30:16.272Z",
ExecutionContext: ExecutionContext{
RequestID: "222lDEOIH-534-4ljhLHJjh222",
RemoteAddress: "201.19.20.19",
},
Actors: []APIObject{
{
ID: "PDUSER",
Summary: "John Snow",
Type: "user_reference",
},
},
Method: Method{
Type: "api_token",
TruncatedToken: "2adm",
},
RootResource: APIObject{
ID: "PDUSER",
Summary: "John Snow",
Type: "user_reference",
},
Action: "update",
Details: Details{
Resource: APIObject{
ID: "PXOGWUS",
Type: "assignment_notification_rule_reference",
Summary: "0 minutes: channel P1IAAPZ",
},
Fields: []Field{
{
Name: "start_delay_in_minutes",
BeforeValue: "0",
Value: "2",
},
},
References: []Reference{
{
Name: "contact_method",
Removed: []APIObject{
{
ID: "POE6L88",
Type: "push_notification_contact_method_reference",
Summary: "Pixel 3",
},
},
Added: []APIObject{
{
ID: "P4GTUMK",
Type: "sms_contact_method_reference",
Summary: "Mobile",
},
},
},
},
},
},
},
NextCursor: nil,
Limit: 10,
}
testEqual(t, want, resp)
}