Makefile for quick and dirty testing.
This commit is contained in:
@@ -0,0 +1,30 @@
|
|||||||
|
# Variables
|
||||||
|
HOST=http://localhost:3333
|
||||||
|
COOKIE_FILE=cookies.txt
|
||||||
|
|
||||||
|
run:
|
||||||
|
go run cmd/main.go
|
||||||
|
|
||||||
|
# 1. Register a user
|
||||||
|
register:
|
||||||
|
curl -v POST $(HOST)/register \
|
||||||
|
-d "email=jason@debian.org" \
|
||||||
|
-d "password=pass123"
|
||||||
|
|
||||||
|
# 2. Login and SAVE the cookie to a file
|
||||||
|
login:
|
||||||
|
curl -v POST $(HOST)/login \
|
||||||
|
-d "email=jason@debian.org" \
|
||||||
|
-d "password=pass123" \
|
||||||
|
-c $(COOKIE_FILE)
|
||||||
|
|
||||||
|
# 3. Access a protected route using the saved cookie
|
||||||
|
test-auth:
|
||||||
|
curl GET $(HOST)/users \
|
||||||
|
-b $(COOKIE_FILE)
|
||||||
|
|
||||||
|
# 4. Cleanup
|
||||||
|
clean-cookies:
|
||||||
|
rm -f $(COOKIE_FILE)
|
||||||
|
|
||||||
|
.PHONY: run register login test-auth clean-cookies
|
||||||
Reference in New Issue
Block a user