summaryrefslogtreecommitdiff
path: root/Makefile
blob: c550ba6274fc7b06133739afc02bfe662cb5fa5b (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
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
.PHONY: build-image run-image health-check list-services test-grpc

# Cargo targets
build:
	@cargo build

check:
	@cargo check

test:
	@cargo test

run:
	@cargo run

clean:
	@cargo clean

fmt:
	@cargo fmt

lint:
	@cargo clippy -- -D warnings

doc:
	@cargo doc --open

# Docker targets
build-image:
	@docker build --no-cache --tag $(IMAGE_TAG) .

run-image: build-image
	@docker run --rm -p 50051:50051 -it $(IMAGE_TAG)

# gRPC testing targets
health-check:
	@grpcurl -plaintext localhost:50051 grpc.health.v1.Health/Check

list-services:
	@grpcurl -plaintext localhost:50051 list

test-grpc:
	@echo "Testing authorization service with valid token..."
	@grpcurl -plaintext \
		-d '{"attributes":{"request":{"http":{"headers":{"authorization":"Bearer valid-token"}}}}}' \
		localhost:50051 \
		envoy.service.auth.v3.Authorization/Check
	@echo ""
	@echo "Testing authorization service without token..."
	@grpcurl -plaintext \
		-d '{"attributes":{"request":{"http":{"headers":{}}}}}' \
		localhost:50051 \
		envoy.service.auth.v3.Authorization/Check