This repository has been archived by the owner on Apr 26, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathMakefile
76 lines (64 loc) · 2.22 KB
/
Makefile
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
.DEFAULT_GOAL := help
.SESSION_COOKIE_SPEC_FILE := session_cookie.json
.CERTIFICATE_DIR := .certificate
.NODE_MODULES_DIR := node_modules
PATH := $(.NODE_MODULES_DIR)/.bin:$(PATH)
SHELL := /bin/bash
.PHONY: help ## Display help section
help:
@echo ""
@echo " Available commands:"
@echo ""
@grep -E '^\.PHONY: [a-zA-Z_-]+ .*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = "(: |##)"}; {printf "\033[36m\t%-32s\033[0m %s\n", $$2, $$3}'
@echo ""
$(.NODE_MODULES_DIR):
@echo ""; echo 🌀 Install npm dependencies
@cd $(@D); npm i
$(.SESSION_COOKIE_SPEC_FILE): $(.NODE_MODULES_DIR)
@echo 🌀 Creating a new sidam session
@. .env; cypress run --spec cypress/integration/session_token_spec.js
.PHONY: session ## Creates a new sidam session
session:
@rm -f $(.SESSION_COOKIE_SPEC_FILE)
@$(MAKE) $(.SESSION_COOKIE_SPEC_FILE)
.PHONY: api-call ## Performs an api call and displays the returned payload
api-call: $(.SESSION_COOKIE_SPEC_FILE)
@if [ $(shell ./bin/session_expired) = true ]; then \
$(MAKE) session; \
fi
@. .env; curl \
-v \
-k \
-x proxyout.reform.hmcts.net:8080 \
-H "User-Agent:" \
-H "Authorization: Bearer $(shell ./bin/session_token)" \
-H "ServiceAuthorization: ccd_gw" \
-H "experimental: false" \
-H "Ocp-Apim-Subscription-Key: $(shell . .env; echo $${SUBSCRIPTION_KEY})" \
https://$$API_HOSTNAME/$$API_BASE_NAME/cases/$$CYPRESS_CASE_ID \
| jq
.PHONY: cypress
cypress:
@. .env; export HTTP_PROXY="proxyout.reform.hmcts.net:8080"; cypress open
$(.CERTIFICATE_DIR):
@echo ""; echo 🌀 Create self-signed certificate
@mkdir -p $@ && openssl req \
-newkey rsa:2048 \
-new \
-nodes \
-x509 \
-days 3650 \
-keyout $@/key.pem \
-out $@/cert.pem \
-subj "/C=UK/ST=Denial/L=London/O=Dis/CN=www.example.com"
.PHONY: certificate ## Creates a new self-signed certificate
certificate: $(.CERTIFICATE_DIR)
.PHONY: test ## Runs tests against APIM s2s policy
test: $(.NODE_MODULES_DIR) $(.CERTIFICATE_DIR)
@echo ""; echo 🌀 Run policy tests
@echo ""; . .env; echo 👩💻 testing against $${API_BASE_NAME}
@. .env; npm test
.PHONY: test-ci ## Runs tests against APIM s2s policy (CI mode)
test-ci: $(.NODE_MODULES_DIR) $(.CERTIFICATE_DIR)
@echo ""; echo 🌀 Run policy tests
@npm test