-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathaudit.bats
42 lines (30 loc) · 1.13 KB
/
audit.bats
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
#!/usr/bin/env bats
load "helpers"
setup_file() {
start_server
login_superadmin
}
teardown_file() {
stop_server
}
@test "audit: check audit logs" {
exec_admin_graphql 'audit-logs' '{"first": 1}'
exec_admin_graphql 'audit-logs' '{"first": 1}'
exec_admin_graphql 'audit-logs' '{"first": 1}'
edges_length=$(graphql_output '.data.audit.edges | length')
[[ "$edges_length" -eq 1 ]] || exit 1
action=$(graphql_output '.data.audit.edges[-1].node.action')
[[ "$action" == "app:audit:list" ]] || exit 1
exec_admin_graphql 'audit-logs' '{"first": 2}'
edges_length=$(graphql_output '.data.audit.edges | length')
[[ "$edges_length" -eq 2 ]] || exit 1
action=$(graphql_output '.data.audit.edges[-1].node.action')
[[ "$action" == "app:audit:list" ]] || exit 1
end_cursor=$(graphql_output '.data.audit.pageInfo.endCursor')
[[ -n "$end_cursor" ]] || exit 1 # Ensure endCursor is not empty
echo "end_cursor: $end_cursor"
exec_admin_graphql 'audit-logs' "{\"first\": 2, \"after\": \"$end_cursor\"}"
echo "$output"
edges_length=$(graphql_output '.data.audit.edges | length')
[[ "$edges_length" -eq 2 ]] || exit 1
}