blob: 2ab437ebaeca41de18034789b81c4f245a21faf2 (
plain)
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
|
PROJECT_NAME := $(shell basename $(shell pwd))# {{{}}}
GIT_BRANCH := $(shell git rev-parse --abbrev-ref HEAD | sed 's/\//_/g')
IMAGE_TAG := $(PROJECT_NAME):$(GIT_BRANCH)
.PHONY: build check test run clean fmt lint doc vendor
.PHONY: build-image run-image health-check list-services test-image
setup:
mise install
mise exec go -- go install github.com/mattn/goreman@latest
mise exec rustup -- rustup component add clippy rustfmt
# Cargo targets
build:
@cargo build --offline
check:
@cargo check
test:
@cargo test
run: build
@cp target/debug/authzd bin/authzd
@goreman -set-ports=false -rpc-server=false -f ./Procfile -exit-on-error=true start
clean:
@cargo clean
fmt:
@cargo fmt
lint:
@cargo clippy
doc:
@cargo doc --open
vendor:
@cargo vendor
# Docker targets
build-image:
@docker build --tag $(IMAGE_TAG) .
build-image-clean:
@docker build --tag $(IMAGE_TAG) .
run-image: build-image
@docker run --rm -p 10000:10000 -p 9901:9901 --init -it $(IMAGE_TAG)
# HTTP and gRPC testing targets
health-check:
@curl -s http://localhost:10000/health || echo "Service not running"
envoy-admin:
@curl -s http://localhost:9901/stats/prometheus | head -20
list-services:
@grpcurl -plaintext localhost:50051 list
test-image: build-image
@echo "Starting container..."
@docker run -d --name authzd-test -p 10000:10000 -p 9901:9901 $(IMAGE_TAG)
@echo "Waiting for services to start..."
@sleep 5
@echo "Testing Envoy admin endpoint..."
@curl -s http://localhost:9901/stats/prometheus | grep -q "envoy_" && echo "✓ Envoy admin is accessible" || echo "✗ Envoy admin failed"
@echo "Testing health endpoint..."
@curl -s -o /dev/null -w "%{http_code}" http://localhost:10000/health | grep -q "200" && echo "✓ Health check passed" || echo "✗ Health check failed"
@echo "Testing authorization flow..."
@curl -s -H "Authorization: Bearer valid-token" http://localhost:10000/ -w "\n%{http_code}" | grep -q "200" && echo "✓ Auth with valid token passed" || echo "✗ Auth with valid token failed"
@curl -s http://localhost:10000/ -w "\n%{http_code}" | grep -q "401" && echo "✓ Auth without token correctly rejected" || echo "✗ Auth without token failed"
@echo "Cleaning up..."
@docker stop authzd-test && docker rm authzd-test
|