Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
e6d798d
chore(proto): Add proto submodule
tab Apr 1, 2025
a3bf268
feat(grpc) Add gRPC authentication interceptor and permission service
tab Apr 1, 2025
71fd9b2
feat(grpc) Add gRPC scope service
tab Apr 1, 2025
c66bf48
feat(grpc) Add gRPC role service
tab Apr 2, 2025
c9baa3e
feat(grpc) Add gRPC token service
tab Apr 2, 2025
400e652
feat(grpc) Add gRPC user service
tab Apr 2, 2025
eca58fb
fix(errors): Add new error constants for record CRUD operations
tab Apr 3, 2025
2113423
refactor(grpc): Update errors handling
tab Apr 4, 2025
b88d57d
chore(codecov): Update codecov ignore patterns
tab Apr 4, 2025
1249b35
refactor(config): Remove SECRET_KEY and use RSA keys for JWT signing
tab Apr 5, 2025
51940e3
chore(grpc) Use FindRoleDetailsById and FindUserDetailsById methods
tab Apr 5, 2025
45aa271
refactor(logger): JSON structured logging
tab Apr 8, 2025
3c98844
chore(env): Add gRPC address to .env.development
tab Apr 8, 2025
76c0c4b
docs(certificates): Add documentation for generating JWT signing keys…
tab Apr 8, 2025
468f8d6
refactor(backoffice): Remove backoffice controllers
tab Apr 8, 2025
bcf8538
feat(api): Remove backoffice API endpoints from OpenAPI specification
tab Apr 11, 2025
fe4b258
docs(README): Update README
tab Apr 12, 2025
ecbdc58
feat(ci): Add integration testing framework and workflow
tab Apr 12, 2025
614d80d
chore(certs): Use single quotes in OpenSSL command for generating CA …
tab Apr 20, 2025
b11f31f
chore(Makefile): Update environment variable handling for Loki reposi…
tab Apr 20, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions .env.development
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,14 @@ LOG_LEVEL=info
APP_NAME=loki
APP_ADDRESS=0.0.0.0:8080
CLIENT_URL=http://localhost:8080
GRPC_ADDRESS=0.0.0.0:50051

DATABASE_DSN=postgres://postgres:postgres@localhost:5432/loki-development?sslmode=disable

REDIS_URI=redis://localhost:6379/0

TELEMETRY_URI=localhost:4317

SECRET_KEY=jwt-secret-key

CERT_PATH=./certs

SMART_ID_API_URL=https://sid.demo.sk.ee/smart-id-rp/v2
Expand Down
2 changes: 0 additions & 2 deletions .env.test
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ DATABASE_DSN=postgres://postgres:postgres@localhost:5432/loki-test?sslmode=disab

REDIS_URI=redis://localhost:6379/1

SECRET_KEY=jwt-secret-key

CERT_PATH=./certs

SMART_ID_API_URL=https://sid.demo.sk.ee/smart-id-rp/v2
Expand Down
146 changes: 146 additions & 0 deletions .github/actions/integration/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,146 @@
LOKI_HOME ?= ""
LOKI_REPO ?= ${LOKI_HOME}/loki
LOKI_BACKOFFICE_REPO ?= ${LOKI_HOME}/loki-backoffice

LOKI_DB_NAME = loki-test
BACKOFFICE_DB_NAME = loki-backoffice-test
DB_USER = postgres
DB_PASSWORD = postgres
DB_HOST = localhost
DB_PORT = 5432

GOOSE_DRIVER = postgres
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
GOOSE_DRIVER = postgres
GOOSE_DRIVER ?= postgres

LOKI_GOOSE_MIGRATION_DIR = $(LOKI_REPO)/db/migrate
BACKOFFICE_GOOSE_MIGRATION_DIR = $(LOKI_BACKOFFICE_REPO)/db/migrate

NETWORK_NAME = loki-network

ifneq (,$(wildcard $(LOKI_REPO)/.env.test))
include $(LOKI_REPO)/.env.test
export $(shell sed 's/=.*//' $(LOKI_REPO)/.env.test)
endif

ifneq (,$(wildcard $(LOKI_BACKOFFICE_REPO)/.env.test))
include $(LOKI_BACKOFFICE_REPO)/.env.test
export $(shell sed 's/=.*//' $(LOKI_BACKOFFICE_REPO)/.env.test)
endif

.PHONY: setup
setup: db\:setup certs\:generate docker\:network docker\:start check\:services

.PHONY: db\:setup
db\:setup: db\:create db\:migrate

.PHONY: db\:create
db\:create:
@echo "Creating databases for integration tests..."
@echo "PostgreSQL: $(DB_HOST):$(DB_PORT)"
PGPASSWORD=$(DB_PASSWORD) psql -h $(DB_HOST) -U $(DB_USER) -c "DROP DATABASE IF EXISTS \"$(LOKI_DB_NAME)\";" postgres
PGPASSWORD=$(DB_PASSWORD) psql -h $(DB_HOST) -U $(DB_USER) -c "CREATE DATABASE \"$(LOKI_DB_NAME)\";" postgres
PGPASSWORD=$(DB_PASSWORD) psql -h $(DB_HOST) -U $(DB_USER) -c "DROP DATABASE IF EXISTS \"$(BACKOFFICE_DB_NAME)\";" postgres
PGPASSWORD=$(DB_PASSWORD) psql -h $(DB_HOST) -U $(DB_USER) -c "CREATE DATABASE \"$(BACKOFFICE_DB_NAME)\";" postgres
@echo "Databases created successfully"

.PHONY: db\:migrate
db\:migrate:
@echo "Running migrations..."
@if [ -d "$(LOKI_GOOSE_MIGRATION_DIR)" ]; then \
echo "Running loki migrations..."; \
GOOSE_DRIVER=$(GOOSE_DRIVER) GOOSE_DBSTRING="host=$(DB_HOST) port=$(DB_PORT) user=$(DB_USER) password=$(DB_PASSWORD) dbname=$(LOKI_DB_NAME) sslmode=disable" goose -dir $(LOKI_GOOSE_MIGRATION_DIR) up || echo "Note: Some loki migrations might fail if tables already exist from schema"; \
else \
echo "Warning: Loki migrations directory not found at $(LOKI_GOOSE_MIGRATION_DIR)"; \
fi

@if [ -d "$(BACKOFFICE_GOOSE_MIGRATION_DIR)" ]; then \
echo "Running loki-backoffice migrations..."; \
GOOSE_DRIVER=$(GOOSE_DRIVER) GOOSE_DBSTRING="host=$(DB_HOST) port=$(DB_PORT) user=$(DB_USER) password=$(DB_PASSWORD) dbname=$(BACKOFFICE_DB_NAME) sslmode=disable" goose -dir $(BACKOFFICE_GOOSE_MIGRATION_DIR) up || echo "Note: Some loki-backoffice migrations might fail if tables already exist from schema"; \
else \
echo "Warning: Loki-backoffice migrations directory not found at $(BACKOFFICE_GOOSE_MIGRATION_DIR)"; \
fi
@echo "Migrations completed"

.PHONY: certs\:generate
certs\:generate:
@echo "Generating JWT keys and mTLS certificates..."
./generate-certs.sh "$(LOKI_REPO)" "$(LOKI_BACKOFFICE_REPO)"
@echo "Certificate generation completed successfully"

.PHONY: docker\:network
docker\:network:
@echo "Creating Docker network..."
docker network inspect $(NETWORK_NAME) >/dev/null 2>&1 || docker network create $(NETWORK_NAME)
@echo "Docker network ready"

.PHONY: docker\:start
docker\:start:
@echo "Starting services..."
cp loki-compose.override.yaml $(LOKI_REPO)/compose.override.yaml
cp loki-backoffice-compose.override.yaml $(LOKI_BACKOFFICE_REPO)/compose.override.yaml

cd $(LOKI_REPO) && docker compose up -d
cd $(LOKI_BACKOFFICE_REPO) && docker compose up -d

@echo "Services started"

.PHONY: check\:services
check\:services:
@echo "Waiting for services to be ready..."
@echo "Displaying initial container logs to help with debugging..."
@echo "Loki logs:" && docker logs loki
@echo "Loki-backoffice logs:" && docker logs loki-backoffice

@echo "Testing connection to services..."
@for i in $$(seq 1 5); do \
echo "Attempt $$i/5:"; \
if curl -s --max-time 5 http://localhost:8080/live 2>&1 | grep -q "alive"; then \
echo "✅ Loki service is up"; \
LOKI_UP=1; \
else \
echo "❌ Loki service not responding yet"; \
LOKI_UP=0; \
docker logs --tail 20 loki; \
fi; \
if curl -s --max-time 5 http://localhost:8081/live 2>&1 | grep -q "alive"; then \
echo "✅ Loki-backoffice service is up"; \
BACKOFFICE_UP=1; \
else \
echo "❌ Loki-backoffice service not responding yet"; \
BACKOFFICE_UP=0; \
docker logs --tail 20 loki-backoffice; \
fi; \
if [ "$$LOKI_UP" = "1" ] && [ "$$BACKOFFICE_UP" = "1" ]; then \
break; \
fi; \
if [ $$i -eq 5 ]; then \
echo "⚠️ Timed out waiting for services"; \
echo "Full Loki logs:"; \
docker logs loki; \
echo "Full Loki-backoffice logs:"; \
docker logs loki-backoffice; \
exit 1; \
fi; \
echo "Waiting for services to start (attempt $$i/5)... retrying in 3 seconds"; \
sleep 3; \
done

@echo "All services are ready!"

.PHONY: run
run:
@echo "Running integration tests..."
lua run.lua

.PHONY: cleanup
cleanup:
@echo "Cleaning up..."
cd $(LOKI_REPO) && docker compose down || true
cd $(LOKI_BACKOFFICE_REPO) && docker compose down || true

rm -f $(LOKI_REPO)/compose.override.yaml
rm -f $(LOKI_BACKOFFICE_REPO)/compose.override.yaml

docker network rm $(NETWORK_NAME) || true
@echo "Cleanup complete"

.PHONY: all
all: setup run cleanup
59 changes: 59 additions & 0 deletions .github/actions/integration/auth.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
local framework = require("framework")
local auth = {}

local token_cache = {
admin = nil,
manager = nil,
user = nil
}

function auth.get_admin_token()
if token_cache.admin then
print("Using cached admin token")
return token_cache.admin
end

local token = framework.authenticate_with_smart_id("EE", "40504040001")
if not token then
error("Failed to get admin token")
end

token_cache.admin = token
return token
end

function auth.get_manager_token()
if token_cache.manager then
print("Using cached manager token")
return token_cache.manager
end

local token = framework.authenticate_with_smart_id("BE", "00010299944")
if not token then
error("Failed to get manager token")
end

token_cache.manager = token
return token
end

function auth.get_user_token()
if token_cache.user then
print("Using cached user token")
return token_cache.user
end

local token = framework.authenticate_with_smart_id("EE", "30303039914")
if not token then
error("Failed to get user token")
end

token_cache.user = token
return token
end

function auth.get_invalid_token()
return "invalid-token"
end

return auth
Loading