-
Notifications
You must be signed in to change notification settings - Fork 42
88 lines (83 loc) · 2.73 KB
/
graphql-test.yaml
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
name: GraphQL authorization tests
on:
schedule:
- cron: '45 16 * * *'
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
jobs:
test:
runs-on: ubuntu-latest
steps:
- name: Check without bearer token
id: query-no-token
uses: CamiloGarciaLaRotta/[email protected]
with:
url: https://graphql.preprod.crownlabs.polito.it/
# No Bearer token
graphql: |
{
tenant: itPolitoCrownlabsV1alpha1Tenant(name: "s112233") {
spec {
email
firstName
lastName
}
}
}
- name: Print the response status
run: |
echo "[i] Query output status ${{ steps.query-no-token.outputs.status }}"
[[ ${{ steps.query-no-token.outputs.status }} -eq 400 ]] || exit 1
shell: bash
- name: Send the Slack notification
uses: 8398a7/action-slack@v3
with:
status: ${{ job.status }}
author_name: CrownLabs CI
custom_payload: |
{
attachments: [{
color: 'danger',
text: `${process.env.AS_WORKFLOW}\n${process.env.AS_JOB} GraphQL authorization test with no bearer token failed`,
}]
}
env:
GITHUB_TOKEN: ${{ secrets.CI_TOKEN }}
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK }}
if: failure()
- name: Check bad Bearer token
id: query-bad-token
uses: CamiloGarciaLaRotta/[email protected]
with:
headers: '{"Authorization": "Bearer CrownlabsTeam" }'
graphql: |
{
tenant: itPolitoCrownlabsV1alpha1Tenant(name: "s112233") {
spec {
email
firstName
lastName
}
}
}
- name: Print the response status
run: |
echo "[i] Query output status ${{ steps.query-bad-token.outputs.status }}"
[[ ${{ steps.query-bad-token.outputs.status }} -eq 401 ]] || exit 1
shell: bash
- name: Send the Slack notification
uses: 8398a7/action-slack@v3
with:
status: ${{ job.status }}
author_name: CrownLabs CI
custom_payload: |
{
attachments: [{
color: 'danger',
text: `${process.env.AS_WORKFLOW}\n${process.env.AS_JOB} GraphQL authorization test with bad bearer token failed`,
}]
}
env:
GITHUB_TOKEN: ${{ secrets.CI_TOKEN }}
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK }}
if: failure()