Compare commits
9 Commits
61f3a532eb
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
| f503e45be1 | |||
| 588576b82f | |||
| 07d3ea44ea | |||
| 5d80a68b44 | |||
| 6a9061a3de | |||
| 6d1d079f06 | |||
| 416fefdb6b | |||
| deab475eab | |||
| 1dc7c4fd87 |
2
.env
Normal file
2
.env
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
REDIS_PASSWORD=ELdhsgqJt5QZUSWKU5vY3D9CXa1a0teIceeHqvCtoPkrDJ0Lge7XIe8187gFjd0qZLv9zwhGr62MqY
|
||||||
|
HYDRA_PASSWORD=CHANGE-ME-INSECURE-PASSWORD
|
||||||
165
.github/workflows/test.yml
vendored
Normal file
165
.github/workflows/test.yml
vendored
Normal file
@ -0,0 +1,165 @@
|
|||||||
|
name: Tests
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches: [ main, develop ]
|
||||||
|
paths:
|
||||||
|
- 'back/**'
|
||||||
|
pull_request:
|
||||||
|
branches: [ main, develop ]
|
||||||
|
paths:
|
||||||
|
- 'back/**'
|
||||||
|
|
||||||
|
defaults:
|
||||||
|
run:
|
||||||
|
working-directory: ./back
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
test:
|
||||||
|
name: Test
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
|
services:
|
||||||
|
postgres:
|
||||||
|
image: postgres:15
|
||||||
|
env:
|
||||||
|
POSTGRES_USER: test_user
|
||||||
|
POSTGRES_PASSWORD: test_password
|
||||||
|
POSTGRES_DB: logidex_test
|
||||||
|
options: >-
|
||||||
|
--health-cmd pg_isready
|
||||||
|
--health-interval 10s
|
||||||
|
--health-timeout 5s
|
||||||
|
--health-retries 5
|
||||||
|
ports:
|
||||||
|
- 5432:5432
|
||||||
|
|
||||||
|
redis:
|
||||||
|
image: redis:7-alpine
|
||||||
|
options: >-
|
||||||
|
--health-cmd "redis-cli ping"
|
||||||
|
--health-interval 10s
|
||||||
|
--health-timeout 5s
|
||||||
|
--health-retries 5
|
||||||
|
ports:
|
||||||
|
- 6379:6379
|
||||||
|
|
||||||
|
strategy:
|
||||||
|
matrix:
|
||||||
|
go-version: [1.24]
|
||||||
|
test-type: [unit, integration]
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: Checkout code
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: Set up Go
|
||||||
|
uses: actions/setup-go@v4
|
||||||
|
with:
|
||||||
|
go-version: ${{ matrix.go-version }}
|
||||||
|
|
||||||
|
- name: Cache Go modules
|
||||||
|
uses: actions/cache@v3
|
||||||
|
with:
|
||||||
|
path: ~/go/pkg/mod
|
||||||
|
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
|
||||||
|
restore-keys: |
|
||||||
|
${{ runner.os }}-go-
|
||||||
|
|
||||||
|
- name: Install dependencies
|
||||||
|
run: go mod download
|
||||||
|
|
||||||
|
- name: Verify dependencies
|
||||||
|
run: go mod verify
|
||||||
|
|
||||||
|
- name: Run linters
|
||||||
|
run: |
|
||||||
|
go vet ./...
|
||||||
|
go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest
|
||||||
|
golangci-lint run
|
||||||
|
|
||||||
|
- name: Run unit tests
|
||||||
|
if: matrix.test-type == 'unit'
|
||||||
|
run: |
|
||||||
|
make test-unit
|
||||||
|
|
||||||
|
- name: Run integration tests
|
||||||
|
if: matrix.test-type == 'integration'
|
||||||
|
env:
|
||||||
|
TEST_DB_HOST: localhost
|
||||||
|
TEST_DB_PORT: 5432
|
||||||
|
TEST_DB_NAME: logidex_test
|
||||||
|
TEST_DB_USER: test_user
|
||||||
|
TEST_DB_PASSWORD: test_password
|
||||||
|
TEST_REDIS_HOST: localhost
|
||||||
|
TEST_REDIS_PORT: 6379
|
||||||
|
run: |
|
||||||
|
make test-integration
|
||||||
|
|
||||||
|
- name: Run tests with coverage
|
||||||
|
run: |
|
||||||
|
make test-coverage-html
|
||||||
|
|
||||||
|
- name: Upload coverage reports
|
||||||
|
uses: codecov/codecov-action@v3
|
||||||
|
with:
|
||||||
|
file: ./coverage.out
|
||||||
|
flags: unittests
|
||||||
|
name: codecov-umbrella
|
||||||
|
|
||||||
|
- name: Check coverage threshold
|
||||||
|
run: |
|
||||||
|
make test-coverage-check
|
||||||
|
|
||||||
|
- name: Run race condition tests
|
||||||
|
run: |
|
||||||
|
make test-race
|
||||||
|
|
||||||
|
benchmark:
|
||||||
|
name: Benchmark
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: Checkout code
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: Set up Go
|
||||||
|
uses: actions/setup-go@v4
|
||||||
|
with:
|
||||||
|
go-version: 1.24
|
||||||
|
|
||||||
|
- name: Run benchmarks
|
||||||
|
run: |
|
||||||
|
make test-bench | tee benchmark.txt
|
||||||
|
|
||||||
|
- name: Store benchmark results
|
||||||
|
uses: actions/upload-artifact@v3
|
||||||
|
with:
|
||||||
|
name: benchmark-results
|
||||||
|
path: benchmark.txt
|
||||||
|
|
||||||
|
security:
|
||||||
|
name: Security Scan
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: Checkout code
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: Set up Go
|
||||||
|
uses: actions/setup-go@v4
|
||||||
|
with:
|
||||||
|
go-version: 1.24
|
||||||
|
|
||||||
|
- name: Install gosec
|
||||||
|
run: go install github.com/securecodewarrior/gosec/v2/cmd/gosec@latest
|
||||||
|
|
||||||
|
- name: Run security scan
|
||||||
|
run: gosec ./...
|
||||||
|
|
||||||
|
- name: Install govulncheck
|
||||||
|
run: go install golang.org/x/vuln/cmd/govulncheck@latest
|
||||||
|
|
||||||
|
- name: Run vulnerability check
|
||||||
|
run: govulncheck ./...
|
||||||
1
.gitignore
vendored
1
.gitignore
vendored
@ -1 +1,2 @@
|
|||||||
.idea
|
.idea
|
||||||
|
combined.yaml
|
||||||
30
Dockerfile
30
Dockerfile
@ -0,0 +1,30 @@
|
|||||||
|
# ---------- Build Stage ----------
|
||||||
|
FROM golang:1.24 AS builder
|
||||||
|
|
||||||
|
# Set working directory
|
||||||
|
WORKDIR /app
|
||||||
|
|
||||||
|
# Copy Go module files and download dependencies
|
||||||
|
COPY go.mod go.sum ./
|
||||||
|
RUN go mod download
|
||||||
|
|
||||||
|
# Copy source code
|
||||||
|
COPY . .
|
||||||
|
|
||||||
|
# Build the Go binary
|
||||||
|
RUN CGO_ENABLED=0 GOOS=linux go build -o main ./cmd/api/main.go
|
||||||
|
|
||||||
|
# ---------- Final Image ----------
|
||||||
|
FROM alpine:latest
|
||||||
|
|
||||||
|
# Set working directory in final image
|
||||||
|
WORKDIR /app
|
||||||
|
|
||||||
|
# Copy only the binary from builder
|
||||||
|
COPY --from=builder /app/main .
|
||||||
|
|
||||||
|
# Expose the port your app listens on
|
||||||
|
EXPOSE 8080
|
||||||
|
|
||||||
|
# Set default command
|
||||||
|
CMD ["./main"]
|
||||||
|
|||||||
166
Makefile
Normal file
166
Makefile
Normal file
@ -0,0 +1,166 @@
|
|||||||
|
# Go Test Makefile
|
||||||
|
|
||||||
|
.PHONY: test test-unit test-integration test-coverage test-race test-verbose test-short clean-test lint fmt build
|
||||||
|
|
||||||
|
# Default target
|
||||||
|
all: test
|
||||||
|
|
||||||
|
# Run all tests
|
||||||
|
test:
|
||||||
|
go test ./...
|
||||||
|
|
||||||
|
# Run only unit tests (excluding integration tests)
|
||||||
|
test-unit:
|
||||||
|
go test -short ./...
|
||||||
|
|
||||||
|
# Run integration tests
|
||||||
|
test-integration:
|
||||||
|
go test -run TestIntegration ./test/integration/...
|
||||||
|
|
||||||
|
# Run tests with coverage
|
||||||
|
test-coverage:
|
||||||
|
go test -cover ./...
|
||||||
|
|
||||||
|
# Generate detailed coverage report
|
||||||
|
test-coverage-html:
|
||||||
|
go test -coverprofile=coverage.out ./...
|
||||||
|
go tool cover -html=coverage.out -o coverage.html
|
||||||
|
@echo "Coverage report generated: coverage.html"
|
||||||
|
|
||||||
|
# Run tests with race detection
|
||||||
|
test-race:
|
||||||
|
go test -race ./...
|
||||||
|
|
||||||
|
# Run tests in verbose mode
|
||||||
|
test-verbose:
|
||||||
|
go test -v ./...
|
||||||
|
|
||||||
|
# Run tests with short timeout (for CI/CD)
|
||||||
|
test-short:
|
||||||
|
go test -short -timeout=60s ./...
|
||||||
|
|
||||||
|
# Run specific test
|
||||||
|
test-specific:
|
||||||
|
@read -p "Enter test name pattern: " pattern; \
|
||||||
|
go test -run $$pattern ./...
|
||||||
|
|
||||||
|
# Run benchmark tests
|
||||||
|
test-bench:
|
||||||
|
go test -bench=. ./...
|
||||||
|
|
||||||
|
# Run tests for specific package
|
||||||
|
test-pkg:
|
||||||
|
@read -p "Enter package path: " pkg; \
|
||||||
|
go test ./$$pkg
|
||||||
|
|
||||||
|
# Clean test cache and temporary files
|
||||||
|
clean-test:
|
||||||
|
go clean -testcache
|
||||||
|
rm -f coverage.out coverage.html
|
||||||
|
|
||||||
|
# Lint code
|
||||||
|
lint:
|
||||||
|
go vet ./...
|
||||||
|
@if command -v golangci-lint >/dev/null 2>&1; then \
|
||||||
|
golangci-lint run; \
|
||||||
|
else \
|
||||||
|
echo "golangci-lint not installed. Installing..."; \
|
||||||
|
go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest; \
|
||||||
|
golangci-lint run; \
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Format code
|
||||||
|
fmt:
|
||||||
|
go fmt ./...
|
||||||
|
|
||||||
|
# Build the application
|
||||||
|
build:
|
||||||
|
go build ./...
|
||||||
|
|
||||||
|
# Run tests in watch mode (requires entr)
|
||||||
|
test-watch:
|
||||||
|
@if command -v entr >/dev/null 2>&1; then \
|
||||||
|
find . -name "*.go" | entr -c go test ./...; \
|
||||||
|
else \
|
||||||
|
echo "entr not installed. Please install it to use watch mode."; \
|
||||||
|
echo "On macOS: brew install entr"; \
|
||||||
|
echo "On Ubuntu: apt-get install entr"; \
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Generate test mocks (if using mockgen)
|
||||||
|
generate-mocks:
|
||||||
|
@if command -v mockgen >/dev/null 2>&1; then \
|
||||||
|
go generate ./...; \
|
||||||
|
else \
|
||||||
|
echo "mockgen not installed. Installing..."; \
|
||||||
|
go install github.com/golang/mock/mockgen@latest; \
|
||||||
|
go generate ./...; \
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Setup test environment
|
||||||
|
setup-test:
|
||||||
|
go mod tidy
|
||||||
|
go mod download
|
||||||
|
|
||||||
|
# Run tests with JSON output for CI/CD
|
||||||
|
test-json:
|
||||||
|
go test -json ./... > test-results.json
|
||||||
|
|
||||||
|
# Check test coverage threshold
|
||||||
|
test-coverage-check:
|
||||||
|
@coverage=$$(go test -cover ./... | grep "coverage:" | awk '{print $$3}' | sed 's/%//' | awk '{sum+=$$1; count++} END {print sum/count}'); \
|
||||||
|
threshold=80; \
|
||||||
|
if [ "$$(echo "$$coverage >= $$threshold" | bc -l)" -eq 1 ]; then \
|
||||||
|
echo "Coverage $$coverage% meets threshold of $$threshold%"; \
|
||||||
|
else \
|
||||||
|
echo "Coverage $$coverage% below threshold of $$threshold%"; \
|
||||||
|
exit 1; \
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Run tests with profiling
|
||||||
|
test-profile:
|
||||||
|
go test -cpuprofile=cpu.prof -memprofile=mem.prof ./...
|
||||||
|
@echo "Profile files generated: cpu.prof, mem.prof"
|
||||||
|
@echo "View CPU profile: go tool pprof cpu.prof"
|
||||||
|
@echo "View Memory profile: go tool pprof mem.prof"
|
||||||
|
|
||||||
|
# Test specific layers
|
||||||
|
test-domain:
|
||||||
|
go test ./internal/api/*/domain/...
|
||||||
|
|
||||||
|
test-repo:
|
||||||
|
go test ./internal/api/*/repo/...
|
||||||
|
|
||||||
|
test-service:
|
||||||
|
go test ./internal/api/*/service/...
|
||||||
|
|
||||||
|
test-handler:
|
||||||
|
go test ./internal/api/*/handler/...
|
||||||
|
|
||||||
|
test-utils:
|
||||||
|
go test ./internal/phoneutil/... ./test/testutil/...
|
||||||
|
|
||||||
|
# Help target
|
||||||
|
help:
|
||||||
|
@echo "Available targets:"
|
||||||
|
@echo " test - Run all tests"
|
||||||
|
@echo " test-unit - Run unit tests only"
|
||||||
|
@echo " test-integration - Run integration tests"
|
||||||
|
@echo " test-coverage - Run tests with coverage"
|
||||||
|
@echo " test-coverage-html- Generate HTML coverage report"
|
||||||
|
@echo " test-race - Run tests with race detection"
|
||||||
|
@echo " test-verbose - Run tests in verbose mode"
|
||||||
|
@echo " test-short - Run tests with short timeout"
|
||||||
|
@echo " test-bench - Run benchmark tests"
|
||||||
|
@echo " test-watch - Run tests in watch mode"
|
||||||
|
@echo " clean-test - Clean test cache and files"
|
||||||
|
@echo " lint - Run linters"
|
||||||
|
@echo " fmt - Format code"
|
||||||
|
@echo " build - Build application"
|
||||||
|
@echo " setup-test - Setup test environment"
|
||||||
|
@echo " test-domain - Test domain layer only"
|
||||||
|
@echo " test-service - Test service layer only"
|
||||||
|
@echo " test-handler - Test handler layer only"
|
||||||
|
@echo " test-repo - Test repository layer only"
|
||||||
|
@echo " test-utils - Test utility packages"
|
||||||
|
@echo " help - Show this help message"
|
||||||
180
api/auth/api.yaml
Normal file
180
api/auth/api.yaml
Normal file
@ -0,0 +1,180 @@
|
|||||||
|
openapi: 3.0.0
|
||||||
|
info:
|
||||||
|
title: Authentication API
|
||||||
|
version: 1.0.0
|
||||||
|
servers:
|
||||||
|
- url: https://id.logidex.ru/api/auth
|
||||||
|
paths:
|
||||||
|
/auth/otp/request:
|
||||||
|
post:
|
||||||
|
tags:
|
||||||
|
- auth
|
||||||
|
summary: Request OTP
|
||||||
|
requestBody:
|
||||||
|
required: true
|
||||||
|
content:
|
||||||
|
application/json:
|
||||||
|
schema:
|
||||||
|
$ref: '#/components/schemas/RequestOTPRequest'
|
||||||
|
|
||||||
|
responses:
|
||||||
|
'200':
|
||||||
|
description: OTP requested successfully
|
||||||
|
content:
|
||||||
|
application/json:
|
||||||
|
schema:
|
||||||
|
$ref: '#/components/schemas/RequestOTPResponse'
|
||||||
|
'400':
|
||||||
|
description: Bad request
|
||||||
|
content:
|
||||||
|
application/json:
|
||||||
|
schema:
|
||||||
|
$ref: '#/components/schemas/RequestOTPResponse'
|
||||||
|
/auth/otp/verify:
|
||||||
|
|
||||||
|
post:
|
||||||
|
tags:
|
||||||
|
- auth
|
||||||
|
summary: Verify OTP
|
||||||
|
requestBody:
|
||||||
|
required: true
|
||||||
|
content:
|
||||||
|
application/json:
|
||||||
|
schema:
|
||||||
|
$ref: '#/components/schemas/VerifyOTPRequest'
|
||||||
|
responses:
|
||||||
|
'200':
|
||||||
|
description: OTP verified successfully
|
||||||
|
content:
|
||||||
|
application/json:
|
||||||
|
schema:
|
||||||
|
$ref: '#/components/schemas/VerifyOTPResponse'
|
||||||
|
'400':
|
||||||
|
description: Bad request
|
||||||
|
content:
|
||||||
|
application/json:
|
||||||
|
schema:
|
||||||
|
$ref: '#/components/schemas/VerifyOTPResponse'
|
||||||
|
/auth/consent/accept:
|
||||||
|
post:
|
||||||
|
tags:
|
||||||
|
- auth
|
||||||
|
summary: Accept consent
|
||||||
|
requestBody:
|
||||||
|
required: true
|
||||||
|
content:
|
||||||
|
application/json:
|
||||||
|
schema:
|
||||||
|
$ref: '#/components/schemas/AcceptConsentRequest'
|
||||||
|
responses:
|
||||||
|
'200':
|
||||||
|
description: Consent accepted successfully
|
||||||
|
content:
|
||||||
|
application/json:
|
||||||
|
schema:
|
||||||
|
$ref: '#/components/schemas/AcceptConsentResponse'
|
||||||
|
'400':
|
||||||
|
description: Bad request
|
||||||
|
content:
|
||||||
|
application/json:
|
||||||
|
schema:
|
||||||
|
$ref: '#/components/schemas/AcceptConsentResponse'
|
||||||
|
components:
|
||||||
|
schemas:
|
||||||
|
RequestOTPRequest:
|
||||||
|
type: object
|
||||||
|
properties:
|
||||||
|
phone_number:
|
||||||
|
type: string
|
||||||
|
description: Phone number to send OTP to
|
||||||
|
example: "+79999999999"
|
||||||
|
maxLength: 15
|
||||||
|
required:
|
||||||
|
- phone_number
|
||||||
|
RequestOTPResponse:
|
||||||
|
type: object
|
||||||
|
properties:
|
||||||
|
message:
|
||||||
|
type: string
|
||||||
|
description: Confirmation message
|
||||||
|
example: "OTP sent successfully"
|
||||||
|
ok:
|
||||||
|
type: boolean
|
||||||
|
description: Status of the request
|
||||||
|
example: true
|
||||||
|
required:
|
||||||
|
- message
|
||||||
|
- ok
|
||||||
|
VerifyOTPRequest:
|
||||||
|
type: object
|
||||||
|
properties:
|
||||||
|
phone_number:
|
||||||
|
type: string
|
||||||
|
description: Phone number to verify OTP for
|
||||||
|
example: "+79999999999"
|
||||||
|
maxLength: 15
|
||||||
|
otp:
|
||||||
|
type: string
|
||||||
|
description: One-time password to verify
|
||||||
|
example: "123456"
|
||||||
|
maxLength: 6
|
||||||
|
login_challenge:
|
||||||
|
type: string
|
||||||
|
description: Login challenge for verification
|
||||||
|
example: "challenge123"
|
||||||
|
required:
|
||||||
|
- phone_number
|
||||||
|
- otp
|
||||||
|
- login_challenge
|
||||||
|
VerifyOTPResponse:
|
||||||
|
type: object
|
||||||
|
properties:
|
||||||
|
redirect_url:
|
||||||
|
type: string
|
||||||
|
description: URL to redirect to after successful verification
|
||||||
|
example: "https://example.com/redirect"
|
||||||
|
ok:
|
||||||
|
type: boolean
|
||||||
|
description: Status of the verification
|
||||||
|
example: true
|
||||||
|
message:
|
||||||
|
type: string
|
||||||
|
description: Confirmation message
|
||||||
|
example: "OTP verified successfully"
|
||||||
|
required:
|
||||||
|
- redirect_url
|
||||||
|
- ok
|
||||||
|
- message
|
||||||
|
AcceptConsentRequest:
|
||||||
|
type: object
|
||||||
|
properties:
|
||||||
|
consent_challenge:
|
||||||
|
type: string
|
||||||
|
description: The consent challenge to accept
|
||||||
|
example: "challenge123"
|
||||||
|
phone_number:
|
||||||
|
type: string
|
||||||
|
description: Phone number associated with the consent
|
||||||
|
example: "+79999999999"
|
||||||
|
maxLength: 15
|
||||||
|
required:
|
||||||
|
- consent_challenge
|
||||||
|
- phone_number
|
||||||
|
AcceptConsentResponse:
|
||||||
|
type: object
|
||||||
|
properties:
|
||||||
|
redirect_url:
|
||||||
|
type: string
|
||||||
|
description: URL to redirect to after accepting consent
|
||||||
|
example: "https://example.com/consent-accepted"
|
||||||
|
ok:
|
||||||
|
type: boolean
|
||||||
|
description: Status of the consent acceptance
|
||||||
|
example: true
|
||||||
|
message:
|
||||||
|
type: string
|
||||||
|
example: "Consent accepted"
|
||||||
|
required:
|
||||||
|
- message
|
||||||
|
- ok
|
||||||
|
- redirect_url
|
||||||
6
api/auth/cfg.yaml
Normal file
6
api/auth/cfg.yaml
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
package: handler
|
||||||
|
generate:
|
||||||
|
fiber-server: true
|
||||||
|
strict-server: true
|
||||||
|
models: true
|
||||||
|
output: gen.go
|
||||||
87
api/user/api.yaml
Normal file
87
api/user/api.yaml
Normal file
@ -0,0 +1,87 @@
|
|||||||
|
openapi: 3.0.0
|
||||||
|
info:
|
||||||
|
title: User CRUD API
|
||||||
|
version: 1.0.0
|
||||||
|
servers:
|
||||||
|
- url: https://api.example.com/v1
|
||||||
|
paths:
|
||||||
|
/users/{userId}:
|
||||||
|
get:
|
||||||
|
tags:
|
||||||
|
- users
|
||||||
|
operationId: getUserById
|
||||||
|
summary: Get a user by ID
|
||||||
|
parameters:
|
||||||
|
- name: userId
|
||||||
|
in: path
|
||||||
|
required: true
|
||||||
|
schema:
|
||||||
|
type: string
|
||||||
|
responses:
|
||||||
|
'200':
|
||||||
|
description: User details
|
||||||
|
content:
|
||||||
|
application/json:
|
||||||
|
schema:
|
||||||
|
type: object
|
||||||
|
properties:
|
||||||
|
user:
|
||||||
|
$ref: '#/components/schemas/User'
|
||||||
|
required:
|
||||||
|
- user
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
'404':
|
||||||
|
description: User not found
|
||||||
|
content:
|
||||||
|
application/json:
|
||||||
|
schema:
|
||||||
|
type: object
|
||||||
|
properties:
|
||||||
|
message:
|
||||||
|
type: string
|
||||||
|
example: "User not found"
|
||||||
|
required:
|
||||||
|
- message
|
||||||
|
/users:
|
||||||
|
post:
|
||||||
|
tags:
|
||||||
|
- users
|
||||||
|
operationId: createUser
|
||||||
|
summary: "Create a new user with phone number"
|
||||||
|
requestBody:
|
||||||
|
required: true
|
||||||
|
content:
|
||||||
|
application/json:
|
||||||
|
schema:
|
||||||
|
$ref: '#/components/schemas/UserCreate'
|
||||||
|
responses:
|
||||||
|
'200':
|
||||||
|
description: User created successfully
|
||||||
|
content:
|
||||||
|
application/json:
|
||||||
|
schema:
|
||||||
|
$ref: '#/components/schemas/User'
|
||||||
|
components:
|
||||||
|
schemas:
|
||||||
|
User:
|
||||||
|
type: object
|
||||||
|
properties:
|
||||||
|
uuid:
|
||||||
|
type: string
|
||||||
|
example: "123"
|
||||||
|
phone_number:
|
||||||
|
type: string
|
||||||
|
example: "johndoe"
|
||||||
|
required:
|
||||||
|
- uuid
|
||||||
|
- phone_number
|
||||||
|
UserCreate:
|
||||||
|
type: object
|
||||||
|
properties:
|
||||||
|
phone_number:
|
||||||
|
type: string
|
||||||
|
|
||||||
|
required:
|
||||||
|
- phone_number
|
||||||
@ -1,138 +0,0 @@
|
|||||||
openapi: 3.0.0
|
|
||||||
info:
|
|
||||||
title: User CRUD API
|
|
||||||
version: 1.0.0
|
|
||||||
servers:
|
|
||||||
- url: https://api.example.com/v1
|
|
||||||
paths:
|
|
||||||
/users:
|
|
||||||
get:
|
|
||||||
summary: Get all users
|
|
||||||
responses:
|
|
||||||
'200':
|
|
||||||
description: A list of users
|
|
||||||
content:
|
|
||||||
application/json:
|
|
||||||
schema:
|
|
||||||
type: array
|
|
||||||
items:
|
|
||||||
$ref: '#/components/schemas/User'
|
|
||||||
post:
|
|
||||||
summary: Create a new user
|
|
||||||
requestBody:
|
|
||||||
required: true
|
|
||||||
content:
|
|
||||||
application/json:
|
|
||||||
schema:
|
|
||||||
$ref: '#/components/schemas/UserCreate'
|
|
||||||
responses:
|
|
||||||
'201':
|
|
||||||
description: User created
|
|
||||||
content:
|
|
||||||
application/json:
|
|
||||||
schema:
|
|
||||||
$ref: '#/components/schemas/User'
|
|
||||||
/users/{userId}:
|
|
||||||
get:
|
|
||||||
summary: Get a user by ID
|
|
||||||
parameters:
|
|
||||||
- name: userId
|
|
||||||
in: path
|
|
||||||
required: true
|
|
||||||
schema:
|
|
||||||
type: string
|
|
||||||
responses:
|
|
||||||
'200':
|
|
||||||
description: User details
|
|
||||||
content:
|
|
||||||
application/json:
|
|
||||||
schema:
|
|
||||||
$ref: '#/components/schemas/User'
|
|
||||||
'404':
|
|
||||||
description: User not found
|
|
||||||
put:
|
|
||||||
summary: Update a user by ID
|
|
||||||
parameters:
|
|
||||||
- name: userId
|
|
||||||
in: path
|
|
||||||
required: true
|
|
||||||
schema:
|
|
||||||
type: string
|
|
||||||
requestBody:
|
|
||||||
required: true
|
|
||||||
content:
|
|
||||||
application/json:
|
|
||||||
schema:
|
|
||||||
$ref: '#/components/schemas/UserUpdate'
|
|
||||||
responses:
|
|
||||||
'200':
|
|
||||||
description: User updated
|
|
||||||
content:
|
|
||||||
application/json:
|
|
||||||
schema:
|
|
||||||
$ref: '#/components/schemas/User'
|
|
||||||
'404':
|
|
||||||
description: User not found
|
|
||||||
delete:
|
|
||||||
summary: Delete a user by ID
|
|
||||||
parameters:
|
|
||||||
- name: userId
|
|
||||||
in: path
|
|
||||||
required: true
|
|
||||||
schema:
|
|
||||||
type: string
|
|
||||||
responses:
|
|
||||||
'204':
|
|
||||||
description: User deleted successfully
|
|
||||||
'404':
|
|
||||||
description: User not found
|
|
||||||
|
|
||||||
components:
|
|
||||||
schemas:
|
|
||||||
User:
|
|
||||||
type: object
|
|
||||||
properties:
|
|
||||||
id:
|
|
||||||
type: string
|
|
||||||
example: "123"
|
|
||||||
username:
|
|
||||||
type: string
|
|
||||||
example: "johndoe"
|
|
||||||
email:
|
|
||||||
type: string
|
|
||||||
format: email
|
|
||||||
example: "johndoe@example.com"
|
|
||||||
required:
|
|
||||||
- id
|
|
||||||
- username
|
|
||||||
- email
|
|
||||||
UserCreate:
|
|
||||||
type: object
|
|
||||||
properties:
|
|
||||||
username:
|
|
||||||
type: string
|
|
||||||
example: "johndoe"
|
|
||||||
email:
|
|
||||||
type: string
|
|
||||||
format: email
|
|
||||||
example: "johndoe@example.com"
|
|
||||||
password:
|
|
||||||
type: string
|
|
||||||
format: password
|
|
||||||
required:
|
|
||||||
- username
|
|
||||||
- email
|
|
||||||
- password
|
|
||||||
UserUpdate:
|
|
||||||
type: object
|
|
||||||
properties:
|
|
||||||
username:
|
|
||||||
type: string
|
|
||||||
example: "john_doe_updated"
|
|
||||||
email:
|
|
||||||
type: string
|
|
||||||
format: email
|
|
||||||
example: "johnupdated@example.com"
|
|
||||||
required:
|
|
||||||
- username
|
|
||||||
- email
|
|
||||||
@ -1,18 +1,29 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"git.logidex.ru/fakz9/logidex-id/internal/api/auth"
|
||||||
todo_api "git.logidex.ru/fakz9/logidex-id/internal/api/todo/handler"
|
"git.logidex.ru/fakz9/logidex-id/internal/api/user"
|
||||||
user_api "git.logidex.ru/fakz9/logidex-id/internal/api/user/handler"
|
"git.logidex.ru/fakz9/logidex-id/internal/config"
|
||||||
"github.com/gofiber/fiber/v2"
|
"git.logidex.ru/fakz9/logidex-id/internal/db"
|
||||||
|
"git.logidex.ru/fakz9/logidex-id/internal/hydra_client"
|
||||||
|
"git.logidex.ru/fakz9/logidex-id/internal/redis"
|
||||||
|
"git.logidex.ru/fakz9/logidex-id/internal/server"
|
||||||
|
"go.uber.org/fx"
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
app := fiber.New()
|
fx.New(
|
||||||
|
// Core dependencies
|
||||||
|
fx.Provide(
|
||||||
|
config.NewConfig,
|
||||||
|
redis.NewRedisClient,
|
||||||
|
hydra_client.NewHydraClient,
|
||||||
|
),
|
||||||
|
|
||||||
todo_api.RegisterApp(app)
|
// Modules
|
||||||
user_api.RegisterApp(app)
|
db.Module,
|
||||||
|
server.Module,
|
||||||
app.Listen(":8080")
|
user.Module,
|
||||||
fmt.Println("test")
|
auth.Module,
|
||||||
|
).Run()
|
||||||
}
|
}
|
||||||
|
|||||||
1
combine.sh
Executable file
1
combine.sh
Executable file
@ -0,0 +1 @@
|
|||||||
|
swagger-cli bundle openapi.yaml --outfile combined.yaml --type yaml
|
||||||
18
config.yaml
Normal file
18
config.yaml
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
app:
|
||||||
|
port: 8080
|
||||||
|
|
||||||
|
redis:
|
||||||
|
host: localhost
|
||||||
|
port: 6379
|
||||||
|
db: 0
|
||||||
|
|
||||||
|
hydra:
|
||||||
|
host: https://oauth2.logidex.ru/admin
|
||||||
|
|
||||||
|
db:
|
||||||
|
host: localhost
|
||||||
|
port: 5432
|
||||||
|
user: postgres
|
||||||
|
password: postgres
|
||||||
|
dbname: logidex-id
|
||||||
|
|
||||||
@ -1,3 +0,0 @@
|
|||||||
package LogDex_ID
|
|
||||||
|
|
||||||
//go:generate go run github.com/oapi-codegen/oapi-codegen/v2/cmd/oapi-codegen -config cfg.yaml api.yaml
|
|
||||||
34
go.mod
34
go.mod
@ -2,6 +2,21 @@ module git.logidex.ru/fakz9/logidex-id
|
|||||||
|
|
||||||
go 1.24
|
go 1.24
|
||||||
|
|
||||||
|
require (
|
||||||
|
github.com/gofiber/fiber/v2 v2.52.9
|
||||||
|
github.com/google/uuid v1.6.0
|
||||||
|
github.com/jackc/pgx/v5 v5.7.5
|
||||||
|
github.com/jinzhu/copier v0.4.0
|
||||||
|
github.com/joho/godotenv v1.5.1
|
||||||
|
github.com/nyaruka/phonenumbers v1.6.4
|
||||||
|
github.com/oapi-codegen/runtime v1.1.2
|
||||||
|
github.com/ory/hydra-client-go v1.11.8
|
||||||
|
github.com/redis/rueidis v1.0.63
|
||||||
|
github.com/spf13/viper v1.20.1
|
||||||
|
github.com/stretchr/testify v1.10.0
|
||||||
|
go.uber.org/fx v1.24.0
|
||||||
|
)
|
||||||
|
|
||||||
require (
|
require (
|
||||||
cel.dev/expr v0.19.1 // indirect
|
cel.dev/expr v0.19.1 // indirect
|
||||||
filippo.io/edwards25519 v1.1.0 // indirect
|
filippo.io/edwards25519 v1.1.0 // indirect
|
||||||
@ -13,20 +28,18 @@ require (
|
|||||||
github.com/dprotaso/go-yit v0.0.0-20220510233725-9ba8df137936 // indirect
|
github.com/dprotaso/go-yit v0.0.0-20220510233725-9ba8df137936 // indirect
|
||||||
github.com/dustin/go-humanize v1.0.1 // indirect
|
github.com/dustin/go-humanize v1.0.1 // indirect
|
||||||
github.com/fatih/structtag v1.2.0 // indirect
|
github.com/fatih/structtag v1.2.0 // indirect
|
||||||
|
github.com/fsnotify/fsnotify v1.8.0 // indirect
|
||||||
github.com/getkin/kin-openapi v0.132.0 // indirect
|
github.com/getkin/kin-openapi v0.132.0 // indirect
|
||||||
github.com/go-openapi/jsonpointer v0.21.0 // indirect
|
github.com/go-openapi/jsonpointer v0.21.0 // indirect
|
||||||
github.com/go-openapi/swag v0.23.0 // indirect
|
github.com/go-openapi/swag v0.23.0 // indirect
|
||||||
github.com/go-sql-driver/mysql v1.9.2 // indirect
|
github.com/go-sql-driver/mysql v1.9.2 // indirect
|
||||||
github.com/gofiber/fiber/v2 v2.52.9 // indirect
|
github.com/go-viper/mapstructure/v2 v2.3.0 // indirect
|
||||||
github.com/google/cel-go v0.24.1 // indirect
|
github.com/google/cel-go v0.24.1 // indirect
|
||||||
github.com/google/uuid v1.6.0 // indirect
|
|
||||||
github.com/inconshreveable/mousetrap v1.1.0 // indirect
|
github.com/inconshreveable/mousetrap v1.1.0 // indirect
|
||||||
github.com/jackc/pgpassfile v1.0.0 // indirect
|
github.com/jackc/pgpassfile v1.0.0 // indirect
|
||||||
github.com/jackc/pgservicefile v0.0.0-20240606120523-5a60cdf6a761 // indirect
|
github.com/jackc/pgservicefile v0.0.0-20240606120523-5a60cdf6a761 // indirect
|
||||||
github.com/jackc/pgx/v5 v5.7.5 // indirect
|
|
||||||
github.com/jackc/puddle/v2 v2.2.2 // indirect
|
github.com/jackc/puddle/v2 v2.2.2 // indirect
|
||||||
github.com/jinzhu/inflection v1.0.0 // indirect
|
github.com/jinzhu/inflection v1.0.0 // indirect
|
||||||
github.com/joho/godotenv v1.5.1 // indirect
|
|
||||||
github.com/josharian/intern v1.0.0 // indirect
|
github.com/josharian/intern v1.0.0 // indirect
|
||||||
github.com/klauspost/compress v1.17.9 // indirect
|
github.com/klauspost/compress v1.17.9 // indirect
|
||||||
github.com/mailru/easyjson v0.7.7 // indirect
|
github.com/mailru/easyjson v0.7.7 // indirect
|
||||||
@ -36,25 +49,32 @@ require (
|
|||||||
github.com/mohae/deepcopy v0.0.0-20170929034955-c48cc78d4826 // indirect
|
github.com/mohae/deepcopy v0.0.0-20170929034955-c48cc78d4826 // indirect
|
||||||
github.com/ncruces/go-strftime v0.1.9 // indirect
|
github.com/ncruces/go-strftime v0.1.9 // indirect
|
||||||
github.com/oapi-codegen/oapi-codegen/v2 v2.5.0 // indirect
|
github.com/oapi-codegen/oapi-codegen/v2 v2.5.0 // indirect
|
||||||
github.com/oapi-codegen/runtime v1.1.2 // indirect
|
|
||||||
github.com/oasdiff/yaml v0.0.0-20250309154309-f31be36b4037 // indirect
|
github.com/oasdiff/yaml v0.0.0-20250309154309-f31be36b4037 // indirect
|
||||||
github.com/oasdiff/yaml3 v0.0.0-20250309153720-d2182401db90 // indirect
|
github.com/oasdiff/yaml3 v0.0.0-20250309153720-d2182401db90 // indirect
|
||||||
|
github.com/onsi/ginkgo v1.16.5 // indirect
|
||||||
|
github.com/pelletier/go-toml/v2 v2.2.3 // indirect
|
||||||
github.com/perimeterx/marshmallow v1.1.5 // indirect
|
github.com/perimeterx/marshmallow v1.1.5 // indirect
|
||||||
github.com/pganalyze/pg_query_go/v6 v6.1.0 // indirect
|
github.com/pganalyze/pg_query_go/v6 v6.1.0 // indirect
|
||||||
github.com/pingcap/errors v0.11.5-0.20240311024730-e056997136bb // indirect
|
github.com/pingcap/errors v0.11.5-0.20240311024730-e056997136bb // indirect
|
||||||
github.com/pingcap/failpoint v0.0.0-20240528011301-b51a646c7c86 // indirect
|
github.com/pingcap/failpoint v0.0.0-20240528011301-b51a646c7c86 // indirect
|
||||||
github.com/pingcap/log v1.1.0 // indirect
|
github.com/pingcap/log v1.1.0 // indirect
|
||||||
github.com/pingcap/tidb/pkg/parser v0.0.0-20250324122243-d51e00e5bbf0 // indirect
|
github.com/pingcap/tidb/pkg/parser v0.0.0-20250324122243-d51e00e5bbf0 // indirect
|
||||||
|
github.com/pmezard/go-difflib v1.0.0 // indirect
|
||||||
github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec // indirect
|
github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec // indirect
|
||||||
github.com/rivo/uniseg v0.2.0 // indirect
|
github.com/rivo/uniseg v0.2.0 // indirect
|
||||||
github.com/riza-io/grpc-go v0.2.0 // indirect
|
github.com/riza-io/grpc-go v0.2.0 // indirect
|
||||||
github.com/samber/lo v1.51.0 // indirect
|
github.com/sagikazarmark/locafero v0.7.0 // indirect
|
||||||
|
github.com/sourcegraph/conc v0.3.0 // indirect
|
||||||
github.com/speakeasy-api/jsonpath v0.6.0 // indirect
|
github.com/speakeasy-api/jsonpath v0.6.0 // indirect
|
||||||
github.com/speakeasy-api/openapi-overlay v0.10.2 // indirect
|
github.com/speakeasy-api/openapi-overlay v0.10.2 // indirect
|
||||||
|
github.com/spf13/afero v1.12.0 // indirect
|
||||||
|
github.com/spf13/cast v1.7.1 // indirect
|
||||||
github.com/spf13/cobra v1.9.1 // indirect
|
github.com/spf13/cobra v1.9.1 // indirect
|
||||||
github.com/spf13/pflag v1.0.6 // indirect
|
github.com/spf13/pflag v1.0.6 // indirect
|
||||||
github.com/sqlc-dev/sqlc v1.29.0 // indirect
|
github.com/sqlc-dev/sqlc v1.29.0 // indirect
|
||||||
github.com/stoewer/go-strcase v1.2.0 // indirect
|
github.com/stoewer/go-strcase v1.2.0 // indirect
|
||||||
|
github.com/stretchr/objx v0.5.2 // indirect
|
||||||
|
github.com/subosito/gotenv v1.6.0 // indirect
|
||||||
github.com/tetratelabs/wazero v1.9.0 // indirect
|
github.com/tetratelabs/wazero v1.9.0 // indirect
|
||||||
github.com/valyala/bytebufferpool v1.0.0 // indirect
|
github.com/valyala/bytebufferpool v1.0.0 // indirect
|
||||||
github.com/valyala/fasthttp v1.51.0 // indirect
|
github.com/valyala/fasthttp v1.51.0 // indirect
|
||||||
@ -63,12 +83,14 @@ require (
|
|||||||
github.com/wasilibs/go-pgquery v0.0.0-20250409022910-10ac41983c07 // indirect
|
github.com/wasilibs/go-pgquery v0.0.0-20250409022910-10ac41983c07 // indirect
|
||||||
github.com/wasilibs/wazero-helpers v0.0.0-20240620070341-3dff1577cd52 // indirect
|
github.com/wasilibs/wazero-helpers v0.0.0-20240620070341-3dff1577cd52 // indirect
|
||||||
go.uber.org/atomic v1.11.0 // indirect
|
go.uber.org/atomic v1.11.0 // indirect
|
||||||
|
go.uber.org/dig v1.19.0 // indirect
|
||||||
go.uber.org/multierr v1.11.0 // indirect
|
go.uber.org/multierr v1.11.0 // indirect
|
||||||
go.uber.org/zap v1.27.0 // indirect
|
go.uber.org/zap v1.27.0 // indirect
|
||||||
golang.org/x/crypto v0.40.0 // indirect
|
golang.org/x/crypto v0.40.0 // indirect
|
||||||
golang.org/x/exp v0.0.0-20250305212735-054e65f0b394 // indirect
|
golang.org/x/exp v0.0.0-20250305212735-054e65f0b394 // indirect
|
||||||
golang.org/x/mod v0.25.0 // indirect
|
golang.org/x/mod v0.25.0 // indirect
|
||||||
golang.org/x/net v0.41.0 // indirect
|
golang.org/x/net v0.41.0 // indirect
|
||||||
|
golang.org/x/oauth2 v0.25.0 // indirect
|
||||||
golang.org/x/sync v0.16.0 // indirect
|
golang.org/x/sync v0.16.0 // indirect
|
||||||
golang.org/x/sys v0.34.0 // indirect
|
golang.org/x/sys v0.34.0 // indirect
|
||||||
golang.org/x/text v0.27.0 // indirect
|
golang.org/x/text v0.27.0 // indirect
|
||||||
|
|||||||
406
go.sum
406
go.sum
@ -1,8 +1,42 @@
|
|||||||
cel.dev/expr v0.19.1 h1:NciYrtDRIR0lNCnH1LFJegdjspNx9fI59O7TWcua/W4=
|
cel.dev/expr v0.19.1 h1:NciYrtDRIR0lNCnH1LFJegdjspNx9fI59O7TWcua/W4=
|
||||||
cel.dev/expr v0.19.1/go.mod h1:MrpN08Q+lEBs+bGYdLxxHkZoUSsCp0nSKTs0nTymJgw=
|
cel.dev/expr v0.19.1/go.mod h1:MrpN08Q+lEBs+bGYdLxxHkZoUSsCp0nSKTs0nTymJgw=
|
||||||
|
cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
|
||||||
|
cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
|
||||||
|
cloud.google.com/go v0.38.0/go.mod h1:990N+gfupTy94rShfmMCWGDn0LpTmnzTp2qbd1dvSRU=
|
||||||
|
cloud.google.com/go v0.44.1/go.mod h1:iSa0KzasP4Uvy3f1mN/7PiObzGgflwredwwASm/v6AU=
|
||||||
|
cloud.google.com/go v0.44.2/go.mod h1:60680Gw3Yr4ikxnPRS/oxxkBccT6SA1yMk63TGekxKY=
|
||||||
|
cloud.google.com/go v0.45.1/go.mod h1:RpBamKRgapWJb87xiFSdk4g1CME7QZg3uwTez+TSTjc=
|
||||||
|
cloud.google.com/go v0.46.3/go.mod h1:a6bKKbmY7er1mI7TEI4lsAkts/mkhTSZK8w33B4RAg0=
|
||||||
|
cloud.google.com/go v0.50.0/go.mod h1:r9sluTvynVuxRIOHXQEHMFffphuXHOMZMycpNR5e6To=
|
||||||
|
cloud.google.com/go v0.52.0/go.mod h1:pXajvRH/6o3+F9jDHZWQ5PbGhn+o8w9qiu/CffaVdO4=
|
||||||
|
cloud.google.com/go v0.53.0/go.mod h1:fp/UouUEsRkN6ryDKNW/Upv/JBKnv6WDthjR6+vze6M=
|
||||||
|
cloud.google.com/go v0.54.0/go.mod h1:1rq2OEkV3YMf6n/9ZvGWI3GWw0VoqH/1x2nd8Is/bPc=
|
||||||
|
cloud.google.com/go v0.56.0/go.mod h1:jr7tqZxxKOVYizybht9+26Z/gUq7tiRzu+ACVAMbKVk=
|
||||||
|
cloud.google.com/go v0.57.0/go.mod h1:oXiQ6Rzq3RAkkY7N6t3TcE6jE+CIBBbA36lwQ1JyzZs=
|
||||||
|
cloud.google.com/go v0.62.0/go.mod h1:jmCYTdRCQuc1PHIIJ/maLInMho30T/Y0M4hTdTShOYc=
|
||||||
|
cloud.google.com/go v0.65.0/go.mod h1:O5N8zS7uWy9vkA9vayVHs65eM1ubvY4h553ofrNHObY=
|
||||||
|
cloud.google.com/go/bigquery v1.0.1/go.mod h1:i/xbL2UlR5RvWAURpBYZTtm/cXjCha9lbfbpx4poX+o=
|
||||||
|
cloud.google.com/go/bigquery v1.3.0/go.mod h1:PjpwJnslEMmckchkHFfq+HTD2DmtT67aNFKH1/VBDHE=
|
||||||
|
cloud.google.com/go/bigquery v1.4.0/go.mod h1:S8dzgnTigyfTmLBfrtrhyYhwRxG72rYxvftPBK2Dvzc=
|
||||||
|
cloud.google.com/go/bigquery v1.5.0/go.mod h1:snEHRnqQbz117VIFhE8bmtwIDY80NLUZUMb4Nv6dBIg=
|
||||||
|
cloud.google.com/go/bigquery v1.7.0/go.mod h1://okPTzCYNXSlb24MZs83e2Do+h+VXtc4gLoIoXIAPc=
|
||||||
|
cloud.google.com/go/bigquery v1.8.0/go.mod h1:J5hqkt3O0uAFnINi6JXValWIb1v0goeZM77hZzJN/fQ=
|
||||||
|
cloud.google.com/go/datastore v1.0.0/go.mod h1:LXYbyblFSglQ5pkeyhO+Qmw7ukd3C+pD7TKLgZqpHYE=
|
||||||
|
cloud.google.com/go/datastore v1.1.0/go.mod h1:umbIZjpQpHh4hmRpGhH4tLFup+FVzqBi1b3c64qFpCk=
|
||||||
|
cloud.google.com/go/pubsub v1.0.1/go.mod h1:R0Gpsv3s54REJCy4fxDixWD93lHJMoZTyQ2kNxGRt3I=
|
||||||
|
cloud.google.com/go/pubsub v1.1.0/go.mod h1:EwwdRX2sKPjnvnqCa270oGRyludottCI76h+R3AArQw=
|
||||||
|
cloud.google.com/go/pubsub v1.2.0/go.mod h1:jhfEVHT8odbXTkndysNHCcx0awwzvfOlguIAii9o8iA=
|
||||||
|
cloud.google.com/go/pubsub v1.3.1/go.mod h1:i+ucay31+CNRpDW4Lu78I4xXG+O1r/MAHgjpRVR+TSU=
|
||||||
|
cloud.google.com/go/storage v1.0.0/go.mod h1:IhtSnM/ZTZV8YYJWCY8RULGVqBDmpoyjwiyrjsg+URw=
|
||||||
|
cloud.google.com/go/storage v1.5.0/go.mod h1:tpKbwo567HUNpVclU5sGELwQWBDZ8gh0ZeosJ0Rtdos=
|
||||||
|
cloud.google.com/go/storage v1.6.0/go.mod h1:N7U0C8pVQ/+NIKOBQyamJIeKQKkZ+mxpohlUTyfDhBk=
|
||||||
|
cloud.google.com/go/storage v1.8.0/go.mod h1:Wv1Oy7z6Yz3DshWRJFhqM/UCfaWIRTdp0RXyy7KQOVs=
|
||||||
|
cloud.google.com/go/storage v1.10.0/go.mod h1:FLPqc6j+Ki4BU591ie1oL6qBQGu2Bl/tZ9ullr3+Kg0=
|
||||||
|
dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU=
|
||||||
filippo.io/edwards25519 v1.1.0 h1:FNf4tywRC1HmFuKW5xopWpigGjJKiJSV0Cqo0cJWDaA=
|
filippo.io/edwards25519 v1.1.0 h1:FNf4tywRC1HmFuKW5xopWpigGjJKiJSV0Cqo0cJWDaA=
|
||||||
filippo.io/edwards25519 v1.1.0/go.mod h1:BxyFTGdWcka3PhytdK4V28tE5sGfRvvvRV7EaN4VDT4=
|
filippo.io/edwards25519 v1.1.0/go.mod h1:BxyFTGdWcka3PhytdK4V28tE5sGfRvvvRV7EaN4VDT4=
|
||||||
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
|
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
|
||||||
|
github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo=
|
||||||
github.com/RaveNoX/go-jsoncommentstrip v1.0.0/go.mod h1:78ihd09MekBnJnxpICcwzCMzGrKSKYe4AqU6PDYYpjk=
|
github.com/RaveNoX/go-jsoncommentstrip v1.0.0/go.mod h1:78ihd09MekBnJnxpICcwzCMzGrKSKYe4AqU6PDYYpjk=
|
||||||
github.com/andybalholm/brotli v1.1.0 h1:eLKJA0d02Lf0mVpIDgYnqXcUn0GqVmEFny3VuID1U3M=
|
github.com/andybalholm/brotli v1.1.0 h1:eLKJA0d02Lf0mVpIDgYnqXcUn0GqVmEFny3VuID1U3M=
|
||||||
github.com/andybalholm/brotli v1.1.0/go.mod h1:sms7XGricyQI9K10gOSf56VKKWS4oLer58Q+mhRPtnY=
|
github.com/andybalholm/brotli v1.1.0/go.mod h1:sms7XGricyQI9K10gOSf56VKKWS4oLer58Q+mhRPtnY=
|
||||||
@ -12,9 +46,12 @@ github.com/apapsch/go-jsonmerge/v2 v2.0.0 h1:axGnT1gRIfimI7gJifB699GoE/oq+F2MU7D
|
|||||||
github.com/apapsch/go-jsonmerge/v2 v2.0.0/go.mod h1:lvDnEdqiQrp0O42VQGgmlKpxL1AP2+08jFMw88y4klk=
|
github.com/apapsch/go-jsonmerge/v2 v2.0.0/go.mod h1:lvDnEdqiQrp0O42VQGgmlKpxL1AP2+08jFMw88y4klk=
|
||||||
github.com/benbjohnson/clock v1.1.0/go.mod h1:J11/hYXuz8f4ySSvYwY0FKfm+ezbsZBKZxNJlLklBHA=
|
github.com/benbjohnson/clock v1.1.0/go.mod h1:J11/hYXuz8f4ySSvYwY0FKfm+ezbsZBKZxNJlLklBHA=
|
||||||
github.com/bmatcuk/doublestar v1.1.1/go.mod h1:UD6OnuiIn0yFxxA2le/rnRU1G4RaI4UvFv1sNto9p6w=
|
github.com/bmatcuk/doublestar v1.1.1/go.mod h1:UD6OnuiIn0yFxxA2le/rnRU1G4RaI4UvFv1sNto9p6w=
|
||||||
|
github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU=
|
||||||
github.com/chzyer/logex v1.1.10/go.mod h1:+Ywpsq7O8HXn0nuIou7OrIPyXbp3wmkHB+jjWRnGsAI=
|
github.com/chzyer/logex v1.1.10/go.mod h1:+Ywpsq7O8HXn0nuIou7OrIPyXbp3wmkHB+jjWRnGsAI=
|
||||||
github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e/go.mod h1:nSuG5e5PlCu98SY8svDHJxuZscDgtXS6KTTbou5AhLI=
|
github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e/go.mod h1:nSuG5e5PlCu98SY8svDHJxuZscDgtXS6KTTbou5AhLI=
|
||||||
github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1/go.mod h1:Q3SI9o4m/ZMnBNeIyt5eFwwo7qiLfzFZmjNmxjkiQlU=
|
github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1/go.mod h1:Q3SI9o4m/ZMnBNeIyt5eFwwo7qiLfzFZmjNmxjkiQlU=
|
||||||
|
github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw=
|
||||||
|
github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGXZJjfX53e64911xZQV5JYwmTeXPW+k8Sc=
|
||||||
github.com/cpuguy83/go-md2man/v2 v2.0.6/go.mod h1:oOW0eioCTA6cOiMLiUPZOpcVxMig6NIQQ7OS05n1F4g=
|
github.com/cpuguy83/go-md2man/v2 v2.0.6/go.mod h1:oOW0eioCTA6cOiMLiUPZOpcVxMig6NIQQ7OS05n1F4g=
|
||||||
github.com/cubicdaiya/gonp v1.0.4 h1:ky2uIAJh81WiLcGKBVD5R7KsM/36W6IqqTy6Bo6rGws=
|
github.com/cubicdaiya/gonp v1.0.4 h1:ky2uIAJh81WiLcGKBVD5R7KsM/36W6IqqTy6Bo6rGws=
|
||||||
github.com/cubicdaiya/gonp v1.0.4/go.mod h1:iWGuP/7+JVTn02OWhRemVbMmG1DOUnmrGTYYACpOI0I=
|
github.com/cubicdaiya/gonp v1.0.4/go.mod h1:iWGuP/7+JVTn02OWhRemVbMmG1DOUnmrGTYYACpOI0I=
|
||||||
@ -26,12 +63,27 @@ github.com/dprotaso/go-yit v0.0.0-20220510233725-9ba8df137936 h1:PRxIJD8XjimM5aT
|
|||||||
github.com/dprotaso/go-yit v0.0.0-20220510233725-9ba8df137936/go.mod h1:ttYvX5qlB+mlV1okblJqcSMtR4c52UKxDiX9GRBS8+Q=
|
github.com/dprotaso/go-yit v0.0.0-20220510233725-9ba8df137936/go.mod h1:ttYvX5qlB+mlV1okblJqcSMtR4c52UKxDiX9GRBS8+Q=
|
||||||
github.com/dustin/go-humanize v1.0.1 h1:GzkhY7T5VNhEkwH0PVJgjz+fX1rhBrR7pRT3mDkpeCY=
|
github.com/dustin/go-humanize v1.0.1 h1:GzkhY7T5VNhEkwH0PVJgjz+fX1rhBrR7pRT3mDkpeCY=
|
||||||
github.com/dustin/go-humanize v1.0.1/go.mod h1:Mu1zIs6XwVuF/gI1OepvI0qD18qycQx+mFykh5fBlto=
|
github.com/dustin/go-humanize v1.0.1/go.mod h1:Mu1zIs6XwVuF/gI1OepvI0qD18qycQx+mFykh5fBlto=
|
||||||
|
github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4=
|
||||||
|
github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4=
|
||||||
|
github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1mIlRU8Am5FuJP05cCM98=
|
||||||
|
github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c=
|
||||||
github.com/fatih/structtag v1.2.0 h1:/OdNE99OxoI/PqaW/SuSK9uxxT3f/tcSZgon/ssNSx4=
|
github.com/fatih/structtag v1.2.0 h1:/OdNE99OxoI/PqaW/SuSK9uxxT3f/tcSZgon/ssNSx4=
|
||||||
github.com/fatih/structtag v1.2.0/go.mod h1:mBJUNpUnHmRKrKlQQlmCrh5PuhftFbNv8Ys4/aAZl94=
|
github.com/fatih/structtag v1.2.0/go.mod h1:mBJUNpUnHmRKrKlQQlmCrh5PuhftFbNv8Ys4/aAZl94=
|
||||||
|
github.com/frankban/quicktest v1.14.6 h1:7Xjx+VpznH+oBnejlPUj8oUpdxnVs4f8XU8WnHkI4W8=
|
||||||
|
github.com/frankban/quicktest v1.14.6/go.mod h1:4ptaffx2x8+WTWXmUCuVU6aPUX1/Mz7zb5vbUoiM6w0=
|
||||||
github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo=
|
github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo=
|
||||||
github.com/fsnotify/fsnotify v1.4.9/go.mod h1:znqG4EE+3YCdAaPaxE2ZRY/06pZUdp0tY4IgpuI1SZQ=
|
github.com/fsnotify/fsnotify v1.4.9/go.mod h1:znqG4EE+3YCdAaPaxE2ZRY/06pZUdp0tY4IgpuI1SZQ=
|
||||||
|
github.com/fsnotify/fsnotify v1.8.0 h1:dAwr6QBTBZIkG8roQaJjGof0pp0EeF+tNV7YBP3F/8M=
|
||||||
|
github.com/fsnotify/fsnotify v1.8.0/go.mod h1:8jBTzvmWwFyi3Pb8djgCCO5IBqzKJ/Jwo8TRcHyHii0=
|
||||||
github.com/getkin/kin-openapi v0.132.0 h1:3ISeLMsQzcb5v26yeJrBcdTCEQTag36ZjaGk7MIRUwk=
|
github.com/getkin/kin-openapi v0.132.0 h1:3ISeLMsQzcb5v26yeJrBcdTCEQTag36ZjaGk7MIRUwk=
|
||||||
github.com/getkin/kin-openapi v0.132.0/go.mod h1:3OlG51PCYNsPByuiMB0t4fjnNlIDnaEDsjiKUV8nL58=
|
github.com/getkin/kin-openapi v0.132.0/go.mod h1:3OlG51PCYNsPByuiMB0t4fjnNlIDnaEDsjiKUV8nL58=
|
||||||
|
github.com/go-gl/glfw v0.0.0-20190409004039-e6da0acd62b1/go.mod h1:vR7hzQXu2zJy9AVAgeJqvqgH9Q5CA+iKCZ2gyEVpxRU=
|
||||||
|
github.com/go-gl/glfw/v3.3/glfw v0.0.0-20191125211704-12ad95a8df72/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8=
|
||||||
|
github.com/go-gl/glfw/v3.3/glfw v0.0.0-20200222043503-6f7a984d4dc4/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8=
|
||||||
|
github.com/go-logr/logr v1.4.2 h1:6pFjapn8bFcIbiKo3XT4j/BhANplGihG6tvd+8rYgrY=
|
||||||
|
github.com/go-logr/logr v1.4.2/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY=
|
||||||
|
github.com/go-logr/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag=
|
||||||
|
github.com/go-logr/stdr v1.2.2/go.mod h1:mMo/vtBO5dYbehREoey6XUKy/eSumjCCveDpRre4VKE=
|
||||||
github.com/go-openapi/jsonpointer v0.21.0 h1:YgdVicSA9vH5RiHs9TZW5oyafXZFc6+2Vc1rr/O9oNQ=
|
github.com/go-openapi/jsonpointer v0.21.0 h1:YgdVicSA9vH5RiHs9TZW5oyafXZFc6+2Vc1rr/O9oNQ=
|
||||||
github.com/go-openapi/jsonpointer v0.21.0/go.mod h1:IUyH9l/+uyhIYQ/PXVA41Rexl+kOkAPDdXEYns6fzUY=
|
github.com/go-openapi/jsonpointer v0.21.0/go.mod h1:IUyH9l/+uyhIYQ/PXVA41Rexl+kOkAPDdXEYns6fzUY=
|
||||||
github.com/go-openapi/swag v0.23.0 h1:vsEVJDUo2hPJ2tu0/Xc+4noaxyEffXNIs3cOULZ+GrE=
|
github.com/go-openapi/swag v0.23.0 h1:vsEVJDUo2hPJ2tu0/Xc+4noaxyEffXNIs3cOULZ+GrE=
|
||||||
@ -39,27 +91,77 @@ github.com/go-openapi/swag v0.23.0/go.mod h1:esZ8ITTYEsH1V2trKHjAN8Ai7xHb8RV+YSZ
|
|||||||
github.com/go-sql-driver/mysql v1.9.2 h1:4cNKDYQ1I84SXslGddlsrMhc8k4LeDVj6Ad6WRjiHuU=
|
github.com/go-sql-driver/mysql v1.9.2 h1:4cNKDYQ1I84SXslGddlsrMhc8k4LeDVj6Ad6WRjiHuU=
|
||||||
github.com/go-sql-driver/mysql v1.9.2/go.mod h1:qn46aNg1333BRMNU69Lq93t8du/dwxI64Gl8i5p1WMU=
|
github.com/go-sql-driver/mysql v1.9.2/go.mod h1:qn46aNg1333BRMNU69Lq93t8du/dwxI64Gl8i5p1WMU=
|
||||||
github.com/go-task/slim-sprig v0.0.0-20210107165309-348f09dbbbc0/go.mod h1:fyg7847qk6SyHyPtNmDHnmrv/HOrqktSC+C9fM+CJOE=
|
github.com/go-task/slim-sprig v0.0.0-20210107165309-348f09dbbbc0/go.mod h1:fyg7847qk6SyHyPtNmDHnmrv/HOrqktSC+C9fM+CJOE=
|
||||||
|
github.com/go-test/deep v1.0.8 h1:TDsG77qcSprGbC6vTN8OuXp5g+J+b5Pcguhf7Zt61VM=
|
||||||
|
github.com/go-test/deep v1.0.8/go.mod h1:5C2ZWiW0ErCdrYzpqxLbTX7MG14M9iiw8DgHncVwcsE=
|
||||||
|
github.com/go-viper/mapstructure/v2 v2.2.1 h1:ZAaOCxANMuZx5RCeg0mBdEZk7DZasvvZIxtHqx8aGss=
|
||||||
|
github.com/go-viper/mapstructure/v2 v2.2.1/go.mod h1:oJDH3BJKyqBA2TXFhDsKDGDTlndYOZ6rGS0BRZIxGhM=
|
||||||
|
github.com/go-viper/mapstructure/v2 v2.3.0 h1:27XbWsHIqhbdR5TIC911OfYvgSaW93HM+dX7970Q7jk=
|
||||||
|
github.com/go-viper/mapstructure/v2 v2.3.0/go.mod h1:oJDH3BJKyqBA2TXFhDsKDGDTlndYOZ6rGS0BRZIxGhM=
|
||||||
github.com/gofiber/fiber/v2 v2.52.9 h1:YjKl5DOiyP3j0mO61u3NTmK7or8GzzWzCFzkboyP5cw=
|
github.com/gofiber/fiber/v2 v2.52.9 h1:YjKl5DOiyP3j0mO61u3NTmK7or8GzzWzCFzkboyP5cw=
|
||||||
github.com/gofiber/fiber/v2 v2.52.9/go.mod h1:YEcBbO/FB+5M1IZNBP9FO3J9281zgPAreiI1oqg8nDw=
|
github.com/gofiber/fiber/v2 v2.52.9/go.mod h1:YEcBbO/FB+5M1IZNBP9FO3J9281zgPAreiI1oqg8nDw=
|
||||||
|
github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q=
|
||||||
|
github.com/golang/groupcache v0.0.0-20190702054246-869f871628b6/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc=
|
||||||
|
github.com/golang/groupcache v0.0.0-20191227052852-215e87163ea7/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc=
|
||||||
|
github.com/golang/groupcache v0.0.0-20200121045136-8c9f03a8e57e/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc=
|
||||||
|
github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A=
|
||||||
|
github.com/golang/mock v1.2.0/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A=
|
||||||
|
github.com/golang/mock v1.3.1/go.mod h1:sBzyDLLjw3U8JLTeZvSv8jJB+tU5PVekmnlKIyFUx0Y=
|
||||||
|
github.com/golang/mock v1.4.0/go.mod h1:UOMv5ysSaYNkG+OFQykRIcU/QvvxJf3p21QfJ2Bt3cw=
|
||||||
|
github.com/golang/mock v1.4.1/go.mod h1:UOMv5ysSaYNkG+OFQykRIcU/QvvxJf3p21QfJ2Bt3cw=
|
||||||
|
github.com/golang/mock v1.4.3/go.mod h1:UOMv5ysSaYNkG+OFQykRIcU/QvvxJf3p21QfJ2Bt3cw=
|
||||||
|
github.com/golang/mock v1.4.4/go.mod h1:l3mdAwkq5BuhzHwde/uurv3sEJeZMXNpwsxVWU71h+4=
|
||||||
github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
|
github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
|
||||||
|
github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
|
||||||
|
github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
|
||||||
|
github.com/golang/protobuf v1.3.3/go.mod h1:vzj43D7+SQXF/4pzW/hwtAqwc6iTitCiVSaWz5lYuqw=
|
||||||
|
github.com/golang/protobuf v1.3.4/go.mod h1:vzj43D7+SQXF/4pzW/hwtAqwc6iTitCiVSaWz5lYuqw=
|
||||||
|
github.com/golang/protobuf v1.3.5/go.mod h1:6O5/vntMXwX2lRkT1hjjk0nAC1IDOTvTlVgjlRvqsdk=
|
||||||
github.com/golang/protobuf v1.4.0-rc.1/go.mod h1:ceaxUfeHdC40wWswd/P6IGgMaK3YpKi5j83Wpe3EHw8=
|
github.com/golang/protobuf v1.4.0-rc.1/go.mod h1:ceaxUfeHdC40wWswd/P6IGgMaK3YpKi5j83Wpe3EHw8=
|
||||||
github.com/golang/protobuf v1.4.0-rc.1.0.20200221234624-67d41d38c208/go.mod h1:xKAWHe0F5eneWXFV3EuXVDTCmh+JuBKY0li0aMyXATA=
|
github.com/golang/protobuf v1.4.0-rc.1.0.20200221234624-67d41d38c208/go.mod h1:xKAWHe0F5eneWXFV3EuXVDTCmh+JuBKY0li0aMyXATA=
|
||||||
github.com/golang/protobuf v1.4.0-rc.2/go.mod h1:LlEzMj4AhA7rCAGe4KMBDvJI+AwstrUpVNzEA03Pprs=
|
github.com/golang/protobuf v1.4.0-rc.2/go.mod h1:LlEzMj4AhA7rCAGe4KMBDvJI+AwstrUpVNzEA03Pprs=
|
||||||
github.com/golang/protobuf v1.4.0-rc.4.0.20200313231945-b860323f09d0/go.mod h1:WU3c8KckQ9AFe+yFwt9sWVRKCVIyN9cPHBJSNnbL67w=
|
github.com/golang/protobuf v1.4.0-rc.4.0.20200313231945-b860323f09d0/go.mod h1:WU3c8KckQ9AFe+yFwt9sWVRKCVIyN9cPHBJSNnbL67w=
|
||||||
github.com/golang/protobuf v1.4.0/go.mod h1:jodUvKwWbYaEsadDk5Fwe5c77LiNKVO9IDvqG2KuDX0=
|
github.com/golang/protobuf v1.4.0/go.mod h1:jodUvKwWbYaEsadDk5Fwe5c77LiNKVO9IDvqG2KuDX0=
|
||||||
|
github.com/golang/protobuf v1.4.1/go.mod h1:U8fpvMrcmy5pZrNK1lt4xCsGvpyWQ/VVv6QDs8UjoX8=
|
||||||
github.com/golang/protobuf v1.4.2/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI=
|
github.com/golang/protobuf v1.4.2/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI=
|
||||||
github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk=
|
github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk=
|
||||||
github.com/golang/protobuf v1.5.2/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY=
|
github.com/golang/protobuf v1.5.2/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY=
|
||||||
|
github.com/golang/protobuf v1.5.4 h1:i7eJL8qZTpSEXOPTxNKhASYpMn+8e5Q6AdndVa1dWek=
|
||||||
|
github.com/golang/protobuf v1.5.4/go.mod h1:lnTiLA8Wa4RWRcIUkrtSVa5nRhsEGBg48fD6rSs7xps=
|
||||||
|
github.com/google/btree v0.0.0-20180813153112-4030bb1f1f0c/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ=
|
||||||
|
github.com/google/btree v1.0.0/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ=
|
||||||
github.com/google/cel-go v0.24.1 h1:jsBCtxG8mM5wiUJDSGUqU0K7Mtr3w7Eyv00rw4DiZxI=
|
github.com/google/cel-go v0.24.1 h1:jsBCtxG8mM5wiUJDSGUqU0K7Mtr3w7Eyv00rw4DiZxI=
|
||||||
github.com/google/cel-go v0.24.1/go.mod h1:Hdf9TqOaTNSFQA1ybQaRqATVoK7m/zcf7IMhGXP5zI8=
|
github.com/google/cel-go v0.24.1/go.mod h1:Hdf9TqOaTNSFQA1ybQaRqATVoK7m/zcf7IMhGXP5zI8=
|
||||||
|
github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M=
|
||||||
github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
|
github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
|
||||||
github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
|
github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
|
||||||
github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
||||||
|
github.com/google/go-cmp v0.4.1/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
||||||
|
github.com/google/go-cmp v0.5.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
||||||
|
github.com/google/go-cmp v0.5.1/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
||||||
github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
||||||
|
github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8=
|
||||||
|
github.com/google/go-cmp v0.7.0/go.mod h1:pXiqmnSA92OHEEa9HXL2W4E7lf9JzCmGVUdgjX3N/iU=
|
||||||
|
github.com/google/martian v2.1.0+incompatible/go.mod h1:9I4somxYTbIHy5NJKHRl3wXiIaQGbYVAs8BPL6v8lEs=
|
||||||
|
github.com/google/martian/v3 v3.0.0/go.mod h1:y5Zk1BBys9G+gd6Jrk0W3cC1+ELVxBWuIGO+w/tUAp0=
|
||||||
|
github.com/google/pprof v0.0.0-20181206194817-3ea8567a2e57/go.mod h1:zfwlbNMJ+OItoe0UupaVj+oy1omPYYDuagoSzA8v9mc=
|
||||||
|
github.com/google/pprof v0.0.0-20190515194954-54271f7e092f/go.mod h1:zfwlbNMJ+OItoe0UupaVj+oy1omPYYDuagoSzA8v9mc=
|
||||||
|
github.com/google/pprof v0.0.0-20191218002539-d4f498aebedc/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM=
|
||||||
|
github.com/google/pprof v0.0.0-20200212024743-f11f1df84d12/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM=
|
||||||
|
github.com/google/pprof v0.0.0-20200229191704-1ebb73c60ed3/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM=
|
||||||
|
github.com/google/pprof v0.0.0-20200430221834-fc25d7d30c6d/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM=
|
||||||
|
github.com/google/pprof v0.0.0-20200708004538-1a94d8640e99/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM=
|
||||||
github.com/google/pprof v0.0.0-20210407192527-94a9f03dee38/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE=
|
github.com/google/pprof v0.0.0-20210407192527-94a9f03dee38/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE=
|
||||||
|
github.com/google/pprof v0.0.0-20250317173921-a4b03ec1a45e h1:ijClszYn+mADRFY17kjQEVQ1XRhq2/JR1M3sGqeJoxs=
|
||||||
|
github.com/google/pprof v0.0.0-20250317173921-a4b03ec1a45e/go.mod h1:boTsfXsheKC2y+lKOCMpSfarhxDeIzfZG1jqGcPl3cA=
|
||||||
|
github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI=
|
||||||
github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
|
github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
|
||||||
github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
|
github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
|
||||||
|
github.com/googleapis/gax-go/v2 v2.0.4/go.mod h1:0Wqv26UfaUD9n4G6kQubkQ+KchISgw+vpHVxEJEs9eg=
|
||||||
|
github.com/googleapis/gax-go/v2 v2.0.5/go.mod h1:DWXyrwAJ9X0FpwwEdw+IPEYBICEFu5mhpdKc/us6bOk=
|
||||||
|
github.com/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8=
|
||||||
|
github.com/hashicorp/golang-lru v0.5.1/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8=
|
||||||
github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU=
|
github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU=
|
||||||
|
github.com/ianlancetaylor/demangle v0.0.0-20181102032728-5e5cf60278f6/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc=
|
||||||
github.com/ianlancetaylor/demangle v0.0.0-20200824232613-28f6c0f3b639/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc=
|
github.com/ianlancetaylor/demangle v0.0.0-20200824232613-28f6c0f3b639/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc=
|
||||||
github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2s0bqwp9tc8=
|
github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2s0bqwp9tc8=
|
||||||
github.com/inconshreveable/mousetrap v1.1.0/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw=
|
github.com/inconshreveable/mousetrap v1.1.0/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw=
|
||||||
@ -71,18 +173,27 @@ github.com/jackc/pgx/v5 v5.7.5 h1:JHGfMnQY+IEtGM63d+NGMjoRpysB2JBwDr5fsngwmJs=
|
|||||||
github.com/jackc/pgx/v5 v5.7.5/go.mod h1:aruU7o91Tc2q2cFp5h4uP3f6ztExVpyVv88Xl/8Vl8M=
|
github.com/jackc/pgx/v5 v5.7.5/go.mod h1:aruU7o91Tc2q2cFp5h4uP3f6ztExVpyVv88Xl/8Vl8M=
|
||||||
github.com/jackc/puddle/v2 v2.2.2 h1:PR8nw+E/1w0GLuRFSmiioY6UooMp6KJv0/61nB7icHo=
|
github.com/jackc/puddle/v2 v2.2.2 h1:PR8nw+E/1w0GLuRFSmiioY6UooMp6KJv0/61nB7icHo=
|
||||||
github.com/jackc/puddle/v2 v2.2.2/go.mod h1:vriiEXHvEE654aYKXXjOvZM39qJ0q+azkZFrfEOc3H4=
|
github.com/jackc/puddle/v2 v2.2.2/go.mod h1:vriiEXHvEE654aYKXXjOvZM39qJ0q+azkZFrfEOc3H4=
|
||||||
|
github.com/jinzhu/copier v0.4.0 h1:w3ciUoD19shMCRargcpm0cm91ytaBhDvuRpz1ODO/U8=
|
||||||
|
github.com/jinzhu/copier v0.4.0/go.mod h1:DfbEm0FYsaqBcKcFuvmOZb218JkPGtvSHsKg8S8hyyg=
|
||||||
github.com/jinzhu/inflection v1.0.0 h1:K317FqzuhWc8YvSVlFMCCUb36O/S9MCKRDI7QkRKD/E=
|
github.com/jinzhu/inflection v1.0.0 h1:K317FqzuhWc8YvSVlFMCCUb36O/S9MCKRDI7QkRKD/E=
|
||||||
github.com/jinzhu/inflection v1.0.0/go.mod h1:h+uFLlag+Qp1Va5pdKtLDYj+kHp5pxUVkryuEj+Srlc=
|
github.com/jinzhu/inflection v1.0.0/go.mod h1:h+uFLlag+Qp1Va5pdKtLDYj+kHp5pxUVkryuEj+Srlc=
|
||||||
github.com/joho/godotenv v1.5.1 h1:7eLL/+HRGLY0ldzfGMeQkb7vMd0as4CfYvUVzLqw0N0=
|
github.com/joho/godotenv v1.5.1 h1:7eLL/+HRGLY0ldzfGMeQkb7vMd0as4CfYvUVzLqw0N0=
|
||||||
github.com/joho/godotenv v1.5.1/go.mod h1:f4LDr5Voq0i2e/R5DDNOoa2zzDfwtkZa6DnEwAbqwq4=
|
github.com/joho/godotenv v1.5.1/go.mod h1:f4LDr5Voq0i2e/R5DDNOoa2zzDfwtkZa6DnEwAbqwq4=
|
||||||
github.com/josharian/intern v1.0.0 h1:vlS4z54oSdjm0bgjRigI+G1HpF+tI+9rE5LLzOg8HmY=
|
github.com/josharian/intern v1.0.0 h1:vlS4z54oSdjm0bgjRigI+G1HpF+tI+9rE5LLzOg8HmY=
|
||||||
github.com/josharian/intern v1.0.0/go.mod h1:5DoeVV0s6jJacbCEi61lwdGj/aVlrQvzHFFd8Hwg//Y=
|
github.com/josharian/intern v1.0.0/go.mod h1:5DoeVV0s6jJacbCEi61lwdGj/aVlrQvzHFFd8Hwg//Y=
|
||||||
|
github.com/jstemmer/go-junit-report v0.0.0-20190106144839-af01ea7f8024/go.mod h1:6v2b51hI/fHJwM22ozAgKL4VKDeJcHhJFhtBdhmNjmU=
|
||||||
|
github.com/jstemmer/go-junit-report v0.9.1/go.mod h1:Brl9GWCQeLvo8nXZwPNNblvFj/XSXhF0NWZEnDohbsk=
|
||||||
github.com/juju/gnuflag v0.0.0-20171113085948-2ce1bb71843d/go.mod h1:2PavIy+JPciBPrBUjwbNvtwB6RQlve+hkpll6QSNmOE=
|
github.com/juju/gnuflag v0.0.0-20171113085948-2ce1bb71843d/go.mod h1:2PavIy+JPciBPrBUjwbNvtwB6RQlve+hkpll6QSNmOE=
|
||||||
|
github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck=
|
||||||
github.com/klauspost/compress v1.17.9 h1:6KIumPrER1LHsvBVuDa0r5xaG0Es51mhhB9BQB2qeMA=
|
github.com/klauspost/compress v1.17.9 h1:6KIumPrER1LHsvBVuDa0r5xaG0Es51mhhB9BQB2qeMA=
|
||||||
github.com/klauspost/compress v1.17.9/go.mod h1:Di0epgTjJY877eYKx5yC51cX2A2Vl2ibi7bDH9ttBbw=
|
github.com/klauspost/compress v1.17.9/go.mod h1:Di0epgTjJY877eYKx5yC51cX2A2Vl2ibi7bDH9ttBbw=
|
||||||
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
|
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
|
||||||
|
github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE=
|
||||||
|
github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk=
|
||||||
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
|
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
|
||||||
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
|
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
|
||||||
|
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
|
||||||
|
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
|
||||||
github.com/mailru/easyjson v0.7.7 h1:UGYAvKxe3sBsEDzO8ZeWOSlIQfWFlxbzLZe7hwFURr0=
|
github.com/mailru/easyjson v0.7.7 h1:UGYAvKxe3sBsEDzO8ZeWOSlIQfWFlxbzLZe7hwFURr0=
|
||||||
github.com/mailru/easyjson v0.7.7/go.mod h1:xzfreul335JAWq5oZzymOObrkdz5UnU4kGfJJLY9Nlc=
|
github.com/mailru/easyjson v0.7.7/go.mod h1:xzfreul335JAWq5oZzymOObrkdz5UnU4kGfJJLY9Nlc=
|
||||||
github.com/mattn/go-colorable v0.1.13 h1:fFA4WZxdEF4tXPZVKMLwD8oUnCTTo08duU7wxecdEvA=
|
github.com/mattn/go-colorable v0.1.13 h1:fFA4WZxdEF4tXPZVKMLwD8oUnCTTo08duU7wxecdEvA=
|
||||||
@ -97,7 +208,10 @@ github.com/mohae/deepcopy v0.0.0-20170929034955-c48cc78d4826/go.mod h1:TaXosZuwd
|
|||||||
github.com/ncruces/go-strftime v0.1.9 h1:bY0MQC28UADQmHmaF5dgpLmImcShSi2kHU9XLdhx/f4=
|
github.com/ncruces/go-strftime v0.1.9 h1:bY0MQC28UADQmHmaF5dgpLmImcShSi2kHU9XLdhx/f4=
|
||||||
github.com/ncruces/go-strftime v0.1.9/go.mod h1:Fwc5htZGVVkseilnfgOVb9mKy6w1naJmn9CehxcKcls=
|
github.com/ncruces/go-strftime v0.1.9/go.mod h1:Fwc5htZGVVkseilnfgOVb9mKy6w1naJmn9CehxcKcls=
|
||||||
github.com/nxadm/tail v1.4.4/go.mod h1:kenIhsEOeOJmVchQTgglprH7qJGnHDVpk1VPCcaMI8A=
|
github.com/nxadm/tail v1.4.4/go.mod h1:kenIhsEOeOJmVchQTgglprH7qJGnHDVpk1VPCcaMI8A=
|
||||||
|
github.com/nxadm/tail v1.4.8 h1:nPr65rt6Y5JFSKQO7qToXr7pePgD6Gwiw05lkbyAQTE=
|
||||||
github.com/nxadm/tail v1.4.8/go.mod h1:+ncqLTQzXmGhMZNUePPaPqPvBxHAIsmXswZKocGu+AU=
|
github.com/nxadm/tail v1.4.8/go.mod h1:+ncqLTQzXmGhMZNUePPaPqPvBxHAIsmXswZKocGu+AU=
|
||||||
|
github.com/nyaruka/phonenumbers v1.6.4 h1:GFAa844VqRKJvO7oboosM1q3gFVgYvyNe0O6CCbg33A=
|
||||||
|
github.com/nyaruka/phonenumbers v1.6.4/go.mod h1:7gjs+Lchqm49adhAKB5cdcng5ZXgt6x7Jgvi0ZorUtU=
|
||||||
github.com/oapi-codegen/oapi-codegen/v2 v2.5.0 h1:iJvF8SdB/3/+eGOXEpsWkD8FQAHj6mqkb6Fnsoc8MFU=
|
github.com/oapi-codegen/oapi-codegen/v2 v2.5.0 h1:iJvF8SdB/3/+eGOXEpsWkD8FQAHj6mqkb6Fnsoc8MFU=
|
||||||
github.com/oapi-codegen/oapi-codegen/v2 v2.5.0/go.mod h1:fwlMxUEMuQK5ih9aymrxKPQqNm2n8bdLk1ppjH+lr9w=
|
github.com/oapi-codegen/oapi-codegen/v2 v2.5.0/go.mod h1:fwlMxUEMuQK5ih9aymrxKPQqNm2n8bdLk1ppjH+lr9w=
|
||||||
github.com/oapi-codegen/runtime v1.1.2 h1:P2+CubHq8fO4Q6fV1tqDBZHCwpVpvPg7oKiYzQgXIyI=
|
github.com/oapi-codegen/runtime v1.1.2 h1:P2+CubHq8fO4Q6fV1tqDBZHCwpVpvPg7oKiYzQgXIyI=
|
||||||
@ -110,12 +224,20 @@ github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+W
|
|||||||
github.com/onsi/ginkgo v1.10.2/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=
|
github.com/onsi/ginkgo v1.10.2/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=
|
||||||
github.com/onsi/ginkgo v1.12.1/go.mod h1:zj2OWP4+oCPe1qIXoGWkgMRwljMUYCdkwsT2108oapk=
|
github.com/onsi/ginkgo v1.12.1/go.mod h1:zj2OWP4+oCPe1qIXoGWkgMRwljMUYCdkwsT2108oapk=
|
||||||
github.com/onsi/ginkgo v1.16.4/go.mod h1:dX+/inL/fNMqNlz0e9LfyB9TswhZpCVdJM/Z6Vvnwo0=
|
github.com/onsi/ginkgo v1.16.4/go.mod h1:dX+/inL/fNMqNlz0e9LfyB9TswhZpCVdJM/Z6Vvnwo0=
|
||||||
|
github.com/onsi/ginkgo v1.16.5 h1:8xi0RTUf59SOSfEtZMvwTvXYMzG4gV23XVHOZiXNtnE=
|
||||||
|
github.com/onsi/ginkgo v1.16.5/go.mod h1:+E8gABHa3K6zRBolWtd+ROzc/U5bkGt0FwiG042wbpU=
|
||||||
github.com/onsi/ginkgo/v2 v2.1.3/go.mod h1:vw5CSIxN1JObi/U8gcbwft7ZxR2dgaR70JSE3/PpL4c=
|
github.com/onsi/ginkgo/v2 v2.1.3/go.mod h1:vw5CSIxN1JObi/U8gcbwft7ZxR2dgaR70JSE3/PpL4c=
|
||||||
github.com/onsi/gomega v1.7.0/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY=
|
github.com/onsi/gomega v1.7.0/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY=
|
||||||
github.com/onsi/gomega v1.7.1/go.mod h1:XdKZgCCFLUoM/7CFJVPcG8C1xQ1AJ0vpAezJrB7JYyY=
|
github.com/onsi/gomega v1.7.1/go.mod h1:XdKZgCCFLUoM/7CFJVPcG8C1xQ1AJ0vpAezJrB7JYyY=
|
||||||
github.com/onsi/gomega v1.10.1/go.mod h1:iN09h71vgCQne3DLsj+A5owkum+a2tYe+TOCB1ybHNo=
|
github.com/onsi/gomega v1.10.1/go.mod h1:iN09h71vgCQne3DLsj+A5owkum+a2tYe+TOCB1ybHNo=
|
||||||
github.com/onsi/gomega v1.17.0/go.mod h1:HnhC7FXeEQY45zxNK3PPoIUhzk/80Xly9PcubAlGdZY=
|
github.com/onsi/gomega v1.17.0/go.mod h1:HnhC7FXeEQY45zxNK3PPoIUhzk/80Xly9PcubAlGdZY=
|
||||||
github.com/onsi/gomega v1.19.0/go.mod h1:LY+I3pBVzYsTBU1AnDwOSxaYi9WoWiqgwooUqq9yPro=
|
github.com/onsi/gomega v1.19.0/go.mod h1:LY+I3pBVzYsTBU1AnDwOSxaYi9WoWiqgwooUqq9yPro=
|
||||||
|
github.com/onsi/gomega v1.36.2 h1:koNYke6TVk6ZmnyHrCXba/T/MoLBXFjeC1PtvYgw0A8=
|
||||||
|
github.com/onsi/gomega v1.36.2/go.mod h1:DdwyADRjrc825LhMEkD76cHR5+pUnjhUN8GlHlRPHzY=
|
||||||
|
github.com/ory/hydra-client-go v1.11.8 h1:GwJjvH/DBcfYzoST4vUpi4pIRzDGH5oODKpIVuhwVyc=
|
||||||
|
github.com/ory/hydra-client-go v1.11.8/go.mod h1:4YuBuwUEC4yiyDrnKjGYc1tB3gUXan4ZiUYMjXJbfxA=
|
||||||
|
github.com/pelletier/go-toml/v2 v2.2.3 h1:YmeHyLY8mFWbdkNWwpr+qIL2bEqT0o95WSdkNHvL12M=
|
||||||
|
github.com/pelletier/go-toml/v2 v2.2.3/go.mod h1:MfCQTFTvCcUyyvvwm1+G6H/jORL20Xlb6rzQu9GuUkc=
|
||||||
github.com/perimeterx/marshmallow v1.1.5 h1:a2LALqQ1BlHM8PZblsDdidgv1mWi1DgC2UmX50IvK2s=
|
github.com/perimeterx/marshmallow v1.1.5 h1:a2LALqQ1BlHM8PZblsDdidgv1mWi1DgC2UmX50IvK2s=
|
||||||
github.com/perimeterx/marshmallow v1.1.5/go.mod h1:dsXbUu8CRzfYP5a87xpp0xq9S3u0Vchtcl8we9tYaXw=
|
github.com/perimeterx/marshmallow v1.1.5/go.mod h1:dsXbUu8CRzfYP5a87xpp0xq9S3u0Vchtcl8we9tYaXw=
|
||||||
github.com/pganalyze/pg_query_go/v6 v6.1.0 h1:jG5ZLhcVgL1FAw4C/0VNQaVmX1SUJx71wBGdtTtBvls=
|
github.com/pganalyze/pg_query_go/v6 v6.1.0 h1:jG5ZLhcVgL1FAw4C/0VNQaVmX1SUJx71wBGdtTtBvls=
|
||||||
@ -130,37 +252,61 @@ github.com/pingcap/log v1.1.0/go.mod h1:DWQW5jICDR7UJh4HtxXSM20Churx4CQL0fwL/SoO
|
|||||||
github.com/pingcap/tidb/pkg/parser v0.0.0-20250324122243-d51e00e5bbf0 h1:W3rpAI3bubR6VWOcwxDIG0Gz9G5rl5b3SL116T0vBt0=
|
github.com/pingcap/tidb/pkg/parser v0.0.0-20250324122243-d51e00e5bbf0 h1:W3rpAI3bubR6VWOcwxDIG0Gz9G5rl5b3SL116T0vBt0=
|
||||||
github.com/pingcap/tidb/pkg/parser v0.0.0-20250324122243-d51e00e5bbf0/go.mod h1:+8feuexTKcXHZF/dkDfvCwEyBAmgb4paFc3/WeYV2eE=
|
github.com/pingcap/tidb/pkg/parser v0.0.0-20250324122243-d51e00e5bbf0/go.mod h1:+8feuexTKcXHZF/dkDfvCwEyBAmgb4paFc3/WeYV2eE=
|
||||||
github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
|
github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
|
||||||
|
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
|
||||||
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
||||||
|
github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA=
|
||||||
|
github.com/redis/rueidis v1.0.63 h1:zSt5focn0YgrgBAE5NcnAibyKf3ZKyv+eCQHk62jEFk=
|
||||||
|
github.com/redis/rueidis v1.0.63/go.mod h1:Lkhr2QTgcoYBhxARU7kJRO8SyVlgUuEkcJO1Y8MCluA=
|
||||||
github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec h1:W09IVJc94icq4NjY3clb7Lk8O1qJ8BdBEF8z0ibU0rE=
|
github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec h1:W09IVJc94icq4NjY3clb7Lk8O1qJ8BdBEF8z0ibU0rE=
|
||||||
github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec/go.mod h1:qqbHyh8v60DhA7CoWK5oRCqLrMHRGoxYCSS9EjAz6Eo=
|
github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec/go.mod h1:qqbHyh8v60DhA7CoWK5oRCqLrMHRGoxYCSS9EjAz6Eo=
|
||||||
github.com/rivo/uniseg v0.2.0 h1:S1pD9weZBuJdFmowNwbpi7BJ8TNftyUImj/0WQi72jY=
|
github.com/rivo/uniseg v0.2.0 h1:S1pD9weZBuJdFmowNwbpi7BJ8TNftyUImj/0WQi72jY=
|
||||||
github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc=
|
github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc=
|
||||||
github.com/riza-io/grpc-go v0.2.0 h1:2HxQKFVE7VuYstcJ8zqpN84VnAoJ4dCL6YFhJewNcHQ=
|
github.com/riza-io/grpc-go v0.2.0 h1:2HxQKFVE7VuYstcJ8zqpN84VnAoJ4dCL6YFhJewNcHQ=
|
||||||
github.com/riza-io/grpc-go v0.2.0/go.mod h1:2bDvR9KkKC3KhtlSHfR3dAXjUMT86kg4UfWFyVGWqi8=
|
github.com/riza-io/grpc-go v0.2.0/go.mod h1:2bDvR9KkKC3KhtlSHfR3dAXjUMT86kg4UfWFyVGWqi8=
|
||||||
|
github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4=
|
||||||
|
github.com/rogpeppe/go-internal v1.12.0 h1:exVL4IDcn6na9z1rAb56Vxr+CgyK3nn3O+epU5NdKM8=
|
||||||
|
github.com/rogpeppe/go-internal v1.12.0/go.mod h1:E+RYuTGaKKdloAfM02xzb0FW3Paa99yedzYV+kq4uf4=
|
||||||
github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
|
github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
|
||||||
github.com/samber/lo v1.51.0 h1:kysRYLbHy/MB7kQZf5DSN50JHmMsNEdeY24VzJFu7wI=
|
github.com/sagikazarmark/locafero v0.7.0 h1:5MqpDsTGNDhY8sGp0Aowyf0qKsPrhewaLSsFaodPcyo=
|
||||||
github.com/samber/lo v1.51.0/go.mod h1:4+MXEGsJzbKGaUEQFKBq2xtfuznW9oz/WrgyzMzRoM0=
|
github.com/sagikazarmark/locafero v0.7.0/go.mod h1:2za3Cg5rMaTMoG/2Ulr9AwtFaIppKXTRYnozin4aB5k=
|
||||||
|
github.com/sergi/go-diff v1.1.0 h1:we8PVUC3FE2uYfodKH/nBHMSetSfHDR6scGdBi+erh0=
|
||||||
github.com/sergi/go-diff v1.1.0/go.mod h1:STckp+ISIX8hZLjrqAeVduY0gWCT9IjLuqbuNXdaHfM=
|
github.com/sergi/go-diff v1.1.0/go.mod h1:STckp+ISIX8hZLjrqAeVduY0gWCT9IjLuqbuNXdaHfM=
|
||||||
|
github.com/sourcegraph/conc v0.3.0 h1:OQTbbt6P72L20UqAkXXuLOj79LfEanQ+YQFNpLA9ySo=
|
||||||
|
github.com/sourcegraph/conc v0.3.0/go.mod h1:Sdozi7LEKbFPqYX2/J+iBAM6HpqSLTASQIKqDmF7Mt0=
|
||||||
github.com/speakeasy-api/jsonpath v0.6.0 h1:IhtFOV9EbXplhyRqsVhHoBmmYjblIRh5D1/g8DHMXJ8=
|
github.com/speakeasy-api/jsonpath v0.6.0 h1:IhtFOV9EbXplhyRqsVhHoBmmYjblIRh5D1/g8DHMXJ8=
|
||||||
github.com/speakeasy-api/jsonpath v0.6.0/go.mod h1:ymb2iSkyOycmzKwbEAYPJV/yi2rSmvBCLZJcyD+VVWw=
|
github.com/speakeasy-api/jsonpath v0.6.0/go.mod h1:ymb2iSkyOycmzKwbEAYPJV/yi2rSmvBCLZJcyD+VVWw=
|
||||||
github.com/speakeasy-api/openapi-overlay v0.10.2 h1:VOdQ03eGKeiHnpb1boZCGm7x8Haj6gST0P3SGTX95GU=
|
github.com/speakeasy-api/openapi-overlay v0.10.2 h1:VOdQ03eGKeiHnpb1boZCGm7x8Haj6gST0P3SGTX95GU=
|
||||||
github.com/speakeasy-api/openapi-overlay v0.10.2/go.mod h1:n0iOU7AqKpNFfEt6tq7qYITC4f0yzVVdFw0S7hukemg=
|
github.com/speakeasy-api/openapi-overlay v0.10.2/go.mod h1:n0iOU7AqKpNFfEt6tq7qYITC4f0yzVVdFw0S7hukemg=
|
||||||
|
github.com/spf13/afero v1.12.0 h1:UcOPyRBYczmFn6yvphxkn9ZEOY65cpwGKb5mL36mrqs=
|
||||||
|
github.com/spf13/afero v1.12.0/go.mod h1:ZTlWwG4/ahT8W7T0WQ5uYmjI9duaLQGy3Q2OAl4sk/4=
|
||||||
|
github.com/spf13/cast v1.7.1 h1:cuNEagBQEHWN1FnbGEjCXL2szYEXqfJPbP2HNUaca9Y=
|
||||||
|
github.com/spf13/cast v1.7.1/go.mod h1:ancEpBxwJDODSW/UG4rDrAqiKolqNNh2DX3mk86cAdo=
|
||||||
github.com/spf13/cobra v1.9.1 h1:CXSaggrXdbHK9CF+8ywj8Amf7PBRmPCOJugH954Nnlo=
|
github.com/spf13/cobra v1.9.1 h1:CXSaggrXdbHK9CF+8ywj8Amf7PBRmPCOJugH954Nnlo=
|
||||||
github.com/spf13/cobra v1.9.1/go.mod h1:nDyEzZ8ogv936Cinf6g1RU9MRY64Ir93oCnqb9wxYW0=
|
github.com/spf13/cobra v1.9.1/go.mod h1:nDyEzZ8ogv936Cinf6g1RU9MRY64Ir93oCnqb9wxYW0=
|
||||||
github.com/spf13/pflag v1.0.6 h1:jFzHGLGAlb3ruxLB8MhbI6A8+AQX/2eW4qeyNZXNp2o=
|
github.com/spf13/pflag v1.0.6 h1:jFzHGLGAlb3ruxLB8MhbI6A8+AQX/2eW4qeyNZXNp2o=
|
||||||
github.com/spf13/pflag v1.0.6/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg=
|
github.com/spf13/pflag v1.0.6/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg=
|
||||||
|
github.com/spf13/viper v1.20.1 h1:ZMi+z/lvLyPSCoNtFCpqjy0S4kPbirhpTMwl8BkW9X4=
|
||||||
|
github.com/spf13/viper v1.20.1/go.mod h1:P9Mdzt1zoHIG8m2eZQinpiBjo6kCmZSKBClNNqjJvu4=
|
||||||
github.com/spkg/bom v0.0.0-20160624110644-59b7046e48ad/go.mod h1:qLr4V1qq6nMqFKkMo8ZTx3f+BZEkzsRUY10Xsm2mwU0=
|
github.com/spkg/bom v0.0.0-20160624110644-59b7046e48ad/go.mod h1:qLr4V1qq6nMqFKkMo8ZTx3f+BZEkzsRUY10Xsm2mwU0=
|
||||||
github.com/sqlc-dev/sqlc v1.29.0 h1:HQctoD7y/i29Bao53qXO7CZ/BV9NcvpGpsJWvz9nKWs=
|
github.com/sqlc-dev/sqlc v1.29.0 h1:HQctoD7y/i29Bao53qXO7CZ/BV9NcvpGpsJWvz9nKWs=
|
||||||
github.com/sqlc-dev/sqlc v1.29.0/go.mod h1:BavmYw11px5AdPOjAVHmb9fctP5A8GTziC38wBF9tp0=
|
github.com/sqlc-dev/sqlc v1.29.0/go.mod h1:BavmYw11px5AdPOjAVHmb9fctP5A8GTziC38wBF9tp0=
|
||||||
github.com/stoewer/go-strcase v1.2.0 h1:Z2iHWqGXH00XYgqDmNgQbIBxf3wrNq0F3feEy0ainaU=
|
github.com/stoewer/go-strcase v1.2.0 h1:Z2iHWqGXH00XYgqDmNgQbIBxf3wrNq0F3feEy0ainaU=
|
||||||
github.com/stoewer/go-strcase v1.2.0/go.mod h1:IBiWB2sKIp3wVVQ3Y035++gc+knqhUQag1KpM8ahLw8=
|
github.com/stoewer/go-strcase v1.2.0/go.mod h1:IBiWB2sKIp3wVVQ3Y035++gc+knqhUQag1KpM8ahLw8=
|
||||||
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
||||||
|
github.com/stretchr/objx v0.5.2 h1:xuMeJ0Sdp5ZMRXx/aWO6RZxdr3beISkG5/G/aIRr3pY=
|
||||||
|
github.com/stretchr/objx v0.5.2/go.mod h1:FRsXN1f5AsAjCGJKqEizvkpNtU+EGNCLh3NxZ/8L+MA=
|
||||||
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
|
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
|
||||||
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
|
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
|
||||||
github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA=
|
github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA=
|
||||||
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
||||||
|
github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOfJA=
|
||||||
|
github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
|
||||||
|
github.com/subosito/gotenv v1.6.0 h1:9NlTDc1FTs4qu0DDq7AEtTPNw6SVm7uBMsUCUjABIf8=
|
||||||
|
github.com/subosito/gotenv v1.6.0/go.mod h1:Dk4QP5c2W3ibzajGcXpNraDfq2IrhjMIvMSWPKKo0FU=
|
||||||
github.com/tetratelabs/wazero v1.9.0 h1:IcZ56OuxrtaEz8UYNRHBrUa9bYeX9oVY93KspZZBf/I=
|
github.com/tetratelabs/wazero v1.9.0 h1:IcZ56OuxrtaEz8UYNRHBrUa9bYeX9oVY93KspZZBf/I=
|
||||||
github.com/tetratelabs/wazero v1.9.0/go.mod h1:TSbcXCfFP0L2FGkRPxHphadXPjo1T6W+CseNNY7EkjM=
|
github.com/tetratelabs/wazero v1.9.0/go.mod h1:TSbcXCfFP0L2FGkRPxHphadXPjo1T6W+CseNNY7EkjM=
|
||||||
|
github.com/ugorji/go/codec v1.2.11 h1:BMaWp1Bb6fHwEtbplGBGJ498wD+LKlNSl25MjdZY4dU=
|
||||||
|
github.com/ugorji/go/codec v1.2.11/go.mod h1:UNopzCgEMSXjBc6AOMqYvWC1ktqTAfzJZUZgYf6w6lg=
|
||||||
github.com/valyala/bytebufferpool v1.0.0 h1:GqA5TC/0021Y/b9FG4Oi9Mr3q7XYx6KllzawFIhcdPw=
|
github.com/valyala/bytebufferpool v1.0.0 h1:GqA5TC/0021Y/b9FG4Oi9Mr3q7XYx6KllzawFIhcdPw=
|
||||||
github.com/valyala/bytebufferpool v1.0.0/go.mod h1:6bBcMArwyJ5K/AmCkWv1jt77kVWyCJ6HpOuEn7z0Csc=
|
github.com/valyala/bytebufferpool v1.0.0/go.mod h1:6bBcMArwyJ5K/AmCkWv1jt77kVWyCJ6HpOuEn7z0Csc=
|
||||||
github.com/valyala/fasthttp v1.51.0 h1:8b30A5JlZ6C7AS81RsWjYMQmrZG6feChmgAolCl1SqA=
|
github.com/valyala/fasthttp v1.51.0 h1:8b30A5JlZ6C7AS81RsWjYMQmrZG6feChmgAolCl1SqA=
|
||||||
@ -173,13 +319,39 @@ github.com/wasilibs/go-pgquery v0.0.0-20250409022910-10ac41983c07 h1:mJdDDPblDfP
|
|||||||
github.com/wasilibs/go-pgquery v0.0.0-20250409022910-10ac41983c07/go.mod h1:Ak17IJ037caFp4jpCw/iQQ7/W74Sqpb1YuKJU6HTKfM=
|
github.com/wasilibs/go-pgquery v0.0.0-20250409022910-10ac41983c07/go.mod h1:Ak17IJ037caFp4jpCw/iQQ7/W74Sqpb1YuKJU6HTKfM=
|
||||||
github.com/wasilibs/wazero-helpers v0.0.0-20240620070341-3dff1577cd52 h1:OvLBa8SqJnZ6P+mjlzc2K7PM22rRUPE1x32G9DTPrC4=
|
github.com/wasilibs/wazero-helpers v0.0.0-20240620070341-3dff1577cd52 h1:OvLBa8SqJnZ6P+mjlzc2K7PM22rRUPE1x32G9DTPrC4=
|
||||||
github.com/wasilibs/wazero-helpers v0.0.0-20240620070341-3dff1577cd52/go.mod h1:jMeV4Vpbi8osrE/pKUxRZkVaA0EX7NZN0A9/oRzgpgY=
|
github.com/wasilibs/wazero-helpers v0.0.0-20240620070341-3dff1577cd52/go.mod h1:jMeV4Vpbi8osrE/pKUxRZkVaA0EX7NZN0A9/oRzgpgY=
|
||||||
|
github.com/yuin/goldmark v1.1.25/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
|
||||||
|
github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
|
||||||
|
github.com/yuin/goldmark v1.1.32/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
|
||||||
github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
|
github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
|
||||||
|
go.opencensus.io v0.21.0/go.mod h1:mSImk1erAIZhrmZN+AvHh14ztQfjbGwt4TtuofqLduU=
|
||||||
|
go.opencensus.io v0.22.0/go.mod h1:+kGneAE2xo2IficOXnaByMWTGM9T73dGwxeWcUqIpI8=
|
||||||
|
go.opencensus.io v0.22.2/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw=
|
||||||
|
go.opencensus.io v0.22.3/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw=
|
||||||
|
go.opencensus.io v0.22.4/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw=
|
||||||
|
go.opentelemetry.io/auto/sdk v1.1.0 h1:cH53jehLUN6UFLY71z+NDOiNJqDdPRaXzTel0sJySYA=
|
||||||
|
go.opentelemetry.io/auto/sdk v1.1.0/go.mod h1:3wSPjt5PWp2RhlCcmmOial7AvC4DQqZb7a7wCow3W8A=
|
||||||
|
go.opentelemetry.io/otel v1.34.0 h1:zRLXxLCgL1WyKsPVrgbSdMN4c0FMkDAskSTQP+0hdUY=
|
||||||
|
go.opentelemetry.io/otel v1.34.0/go.mod h1:OWFPOQ+h4G8xpyjgqo4SxJYdDQ/qmRH+wivy7zzx9oI=
|
||||||
|
go.opentelemetry.io/otel/metric v1.34.0 h1:+eTR3U0MyfWjRDhmFMxe2SsW64QrZ84AOhvqS7Y+PoQ=
|
||||||
|
go.opentelemetry.io/otel/metric v1.34.0/go.mod h1:CEDrp0fy2D0MvkXE+dPV7cMi8tWZwX3dmaIhwPOaqHE=
|
||||||
|
go.opentelemetry.io/otel/sdk v1.34.0 h1:95zS4k/2GOy069d321O8jWgYsW3MzVV+KuSPKp7Wr1A=
|
||||||
|
go.opentelemetry.io/otel/sdk v1.34.0/go.mod h1:0e/pNiaMAqaykJGKbi+tSjWfNNHMTxoC9qANsCzbyxU=
|
||||||
|
go.opentelemetry.io/otel/sdk/metric v1.34.0 h1:5CeK9ujjbFVL5c1PhLuStg1wxA7vQv7ce1EK0Gyvahk=
|
||||||
|
go.opentelemetry.io/otel/sdk/metric v1.34.0/go.mod h1:jQ/r8Ze28zRKoNRdkjCZxfs6YvBTG1+YIqyFVFYec5w=
|
||||||
|
go.opentelemetry.io/otel/trace v1.34.0 h1:+ouXS2V8Rd4hp4580a8q23bg0azF2nI8cqLYnC8mh/k=
|
||||||
|
go.opentelemetry.io/otel/trace v1.34.0/go.mod h1:Svm7lSjQD7kG7KJ/MUHPVXSDGz2OX4h0M2jHBhmSfRE=
|
||||||
go.uber.org/atomic v1.6.0/go.mod h1:sABNBOSYdrvTF6hTgEIbc7YasKWGhgEQZyfxyTvoXHQ=
|
go.uber.org/atomic v1.6.0/go.mod h1:sABNBOSYdrvTF6hTgEIbc7YasKWGhgEQZyfxyTvoXHQ=
|
||||||
go.uber.org/atomic v1.7.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc=
|
go.uber.org/atomic v1.7.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc=
|
||||||
go.uber.org/atomic v1.9.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc=
|
go.uber.org/atomic v1.9.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc=
|
||||||
go.uber.org/atomic v1.11.0 h1:ZvwS0R+56ePWxUNi+Atn9dWONBPp/AUETXlHW0DxSjE=
|
go.uber.org/atomic v1.11.0 h1:ZvwS0R+56ePWxUNi+Atn9dWONBPp/AUETXlHW0DxSjE=
|
||||||
go.uber.org/atomic v1.11.0/go.mod h1:LUxbIzbOniOlMKjJjyPfpl4v+PKK2cNJn91OQbhoJI0=
|
go.uber.org/atomic v1.11.0/go.mod h1:LUxbIzbOniOlMKjJjyPfpl4v+PKK2cNJn91OQbhoJI0=
|
||||||
|
go.uber.org/dig v1.19.0 h1:BACLhebsYdpQ7IROQ1AGPjrXcP5dF80U3gKoFzbaq/4=
|
||||||
|
go.uber.org/dig v1.19.0/go.mod h1:Us0rSJiThwCv2GteUN0Q7OKvU7n5J4dxZ9JKUXozFdE=
|
||||||
|
go.uber.org/fx v1.24.0 h1:wE8mruvpg2kiiL1Vqd0CC+tr0/24XIB10Iwp2lLWzkg=
|
||||||
|
go.uber.org/fx v1.24.0/go.mod h1:AmDeGyS+ZARGKM4tlH4FY2Jr63VjbEDJHtqXTGP5hbo=
|
||||||
go.uber.org/goleak v1.1.10/go.mod h1:8a7PlsEVH3e/a/GLqe5IIrQx6GzcnRmZEufDUTk4A7A=
|
go.uber.org/goleak v1.1.10/go.mod h1:8a7PlsEVH3e/a/GLqe5IIrQx6GzcnRmZEufDUTk4A7A=
|
||||||
|
go.uber.org/goleak v1.3.0 h1:2K3zAYmnTNqV73imy9J1T3WC+gmCePx2hEGkimedGto=
|
||||||
|
go.uber.org/goleak v1.3.0/go.mod h1:CoHD4mav9JJNrW/WLlf7HGZPjdw8EucARQHekz1X6bE=
|
||||||
go.uber.org/multierr v1.6.0/go.mod h1:cdWPpRnG4AhwMwsgIHip0KRBQjJy5kYEpYjJxpXp9iU=
|
go.uber.org/multierr v1.6.0/go.mod h1:cdWPpRnG4AhwMwsgIHip0KRBQjJy5kYEpYjJxpXp9iU=
|
||||||
go.uber.org/multierr v1.7.0/go.mod h1:7EAYxJLBy9rStEaz58O2t4Uvip6FSURkq8/ppBp95ak=
|
go.uber.org/multierr v1.7.0/go.mod h1:7EAYxJLBy9rStEaz58O2t4Uvip6FSURkq8/ppBp95ak=
|
||||||
go.uber.org/multierr v1.11.0 h1:blXXJkSxSSfBVBlC76pxqeO+LN3aDfLQo+309xJstO0=
|
go.uber.org/multierr v1.11.0 h1:blXXJkSxSSfBVBlC76pxqeO+LN3aDfLQo+309xJstO0=
|
||||||
@ -188,39 +360,127 @@ go.uber.org/zap v1.19.0/go.mod h1:xg/QME4nWcxGxrpdeYfq7UvYrLh66cuVKdrbD1XF/NI=
|
|||||||
go.uber.org/zap v1.27.0 h1:aJMhYGrd5QSmlpLMr2MftRKl7t8J8PTZPA732ud/XR8=
|
go.uber.org/zap v1.27.0 h1:aJMhYGrd5QSmlpLMr2MftRKl7t8J8PTZPA732ud/XR8=
|
||||||
go.uber.org/zap v1.27.0/go.mod h1:GB2qFLM7cTU87MWRP2mPIjqfIDnGu+VIO4V/SdhGo2E=
|
go.uber.org/zap v1.27.0/go.mod h1:GB2qFLM7cTU87MWRP2mPIjqfIDnGu+VIO4V/SdhGo2E=
|
||||||
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
|
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
|
||||||
|
golang.org/x/crypto v0.0.0-20190510104115-cbcb75029529/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
|
||||||
|
golang.org/x/crypto v0.0.0-20190605123033-f99c8df09eb5/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
|
||||||
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
|
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
|
||||||
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
|
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
|
||||||
golang.org/x/crypto v0.40.0 h1:r4x+VvoG5Fm+eJcxMaY8CQM7Lb0l1lsmjGBQ6s8BfKM=
|
golang.org/x/crypto v0.40.0 h1:r4x+VvoG5Fm+eJcxMaY8CQM7Lb0l1lsmjGBQ6s8BfKM=
|
||||||
golang.org/x/crypto v0.40.0/go.mod h1:Qr1vMER5WyS2dfPHAlsOj01wgLbsyWtFn/aY+5+ZdxY=
|
golang.org/x/crypto v0.40.0/go.mod h1:Qr1vMER5WyS2dfPHAlsOj01wgLbsyWtFn/aY+5+ZdxY=
|
||||||
|
golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
|
||||||
|
golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
|
||||||
|
golang.org/x/exp v0.0.0-20190510132918-efd6b22b2522/go.mod h1:ZjyILWgesfNpC6sMxTJOJm9Kp84zZh5NQWvqDGG3Qr8=
|
||||||
|
golang.org/x/exp v0.0.0-20190829153037-c13cbed26979/go.mod h1:86+5VVa7VpoJ4kLfm080zCjGlMRFzhUhsZKEZO7MGek=
|
||||||
|
golang.org/x/exp v0.0.0-20191030013958-a1ab85dbe136/go.mod h1:JXzH8nQsPlswgeRAPE3MuO9GYsAcnJvJ4vnMwN/5qkY=
|
||||||
|
golang.org/x/exp v0.0.0-20191129062945-2f5052295587/go.mod h1:2RIsYlXP63K8oxa1u096TMicItID8zy7Y6sNkU49FU4=
|
||||||
|
golang.org/x/exp v0.0.0-20191227195350-da58074b4299/go.mod h1:2RIsYlXP63K8oxa1u096TMicItID8zy7Y6sNkU49FU4=
|
||||||
|
golang.org/x/exp v0.0.0-20200119233911-0405dc783f0a/go.mod h1:2RIsYlXP63K8oxa1u096TMicItID8zy7Y6sNkU49FU4=
|
||||||
|
golang.org/x/exp v0.0.0-20200207192155-f17229e696bd/go.mod h1:J/WKrq2StrnmMY6+EHIKF9dgMWnmCNThgcyBT1FY9mM=
|
||||||
|
golang.org/x/exp v0.0.0-20200224162631-6cc2880d07d6/go.mod h1:3jZMyOhIsHpP37uCMkUooju7aAi5cS1Q23tOzKc+0MU=
|
||||||
golang.org/x/exp v0.0.0-20250305212735-054e65f0b394 h1:nDVHiLt8aIbd/VzvPWN6kSOPE7+F/fNFDSXLVYkE/Iw=
|
golang.org/x/exp v0.0.0-20250305212735-054e65f0b394 h1:nDVHiLt8aIbd/VzvPWN6kSOPE7+F/fNFDSXLVYkE/Iw=
|
||||||
golang.org/x/exp v0.0.0-20250305212735-054e65f0b394/go.mod h1:sIifuuw/Yco/y6yb6+bDNfyeQ/MdPUy/hKEMYQV17cM=
|
golang.org/x/exp v0.0.0-20250305212735-054e65f0b394/go.mod h1:sIifuuw/Yco/y6yb6+bDNfyeQ/MdPUy/hKEMYQV17cM=
|
||||||
|
golang.org/x/image v0.0.0-20190227222117-0694c2d4d067/go.mod h1:kZ7UVZpmo3dzQBMxlp+ypCbDeSB+sBbTgSJuh5dn5js=
|
||||||
|
golang.org/x/image v0.0.0-20190802002840-cff245a6509b/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0=
|
||||||
|
golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE=
|
||||||
|
golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU=
|
||||||
|
golang.org/x/lint v0.0.0-20190301231843-5614ed5bae6f/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE=
|
||||||
|
golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc=
|
||||||
|
golang.org/x/lint v0.0.0-20190409202823-959b441ac422/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc=
|
||||||
|
golang.org/x/lint v0.0.0-20190909230951-414d861bb4ac/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc=
|
||||||
golang.org/x/lint v0.0.0-20190930215403-16217165b5de/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc=
|
golang.org/x/lint v0.0.0-20190930215403-16217165b5de/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc=
|
||||||
|
golang.org/x/lint v0.0.0-20191125180803-fdd1cda4f05f/go.mod h1:5qLYkcX4OjUUV8bRuDixDT3tpyyb+LUpUlRWLxfhWrs=
|
||||||
|
golang.org/x/lint v0.0.0-20200130185559-910be7a94367/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY=
|
||||||
|
golang.org/x/lint v0.0.0-20200302205851-738671d3881b/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY=
|
||||||
|
golang.org/x/mobile v0.0.0-20190312151609-d3739f865fa6/go.mod h1:z+o9i4GpDbdi3rU15maQ/Ox0txvL9dWGYEHz965HBQE=
|
||||||
|
golang.org/x/mobile v0.0.0-20190719004257-d2bd2a29d028/go.mod h1:E/iHnbuqvinMTCcRqshq8CkpyQDoeVncDDYHnLhea+o=
|
||||||
|
golang.org/x/mod v0.0.0-20190513183733-4bf6d317e70e/go.mod h1:mXi4GBBbnImb6dmsKGUJ2LatrhH/nqhxcFungHvyanc=
|
||||||
|
golang.org/x/mod v0.1.0/go.mod h1:0QHyrYULN0/3qlju5TqG8bIK38QM8yzMo5ekMj3DlcY=
|
||||||
|
golang.org/x/mod v0.1.1-0.20191105210325-c90efee705ee/go.mod h1:QqPTAvyqsEbceGzBzNggFXnrqF1CaUcvgkdR5Ot7KZg=
|
||||||
|
golang.org/x/mod v0.1.1-0.20191107180719-034126e5016b/go.mod h1:QqPTAvyqsEbceGzBzNggFXnrqF1CaUcvgkdR5Ot7KZg=
|
||||||
|
golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
|
||||||
golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
|
golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
|
||||||
golang.org/x/mod v0.25.0 h1:n7a+ZbQKQA/Ysbyb0/6IbB1H/X41mKgbhfv7AfG/44w=
|
golang.org/x/mod v0.25.0 h1:n7a+ZbQKQA/Ysbyb0/6IbB1H/X41mKgbhfv7AfG/44w=
|
||||||
golang.org/x/mod v0.25.0/go.mod h1:IXM97Txy2VM4PJ3gI61r1YEk/gAj6zAHN3AdZt6S9Ww=
|
golang.org/x/mod v0.25.0/go.mod h1:IXM97Txy2VM4PJ3gI61r1YEk/gAj6zAHN3AdZt6S9Ww=
|
||||||
|
golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||||
|
golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||||
golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||||
|
golang.org/x/net v0.0.0-20190108225652-1e06a53dbb7e/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||||
|
golang.org/x/net v0.0.0-20190213061140-3a22650c66bd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||||
golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
|
golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
|
||||||
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
|
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
|
||||||
|
golang.org/x/net v0.0.0-20190501004415-9ce7a6920f09/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
|
||||||
|
golang.org/x/net v0.0.0-20190503192946-f4e77d36d62c/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
|
||||||
|
golang.org/x/net v0.0.0-20190603091049-60506f45cf65/go.mod h1:HSz+uSET+XFnRR8LxR5pz3Of3rY3CfYBVs4xY44aLks=
|
||||||
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||||
|
golang.org/x/net v0.0.0-20190628185345-da137c7871d7/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||||
|
golang.org/x/net v0.0.0-20190724013045-ca1201d0de80/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||||
|
golang.org/x/net v0.0.0-20191209160850-c0dbc17a3553/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||||
|
golang.org/x/net v0.0.0-20200114155413-6afb5195e5aa/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||||
|
golang.org/x/net v0.0.0-20200202094626-16171245cfb2/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||||
|
golang.org/x/net v0.0.0-20200222125558-5a598a2470a0/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||||
|
golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||||
|
golang.org/x/net v0.0.0-20200301022130-244492dfa37a/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||||
|
golang.org/x/net v0.0.0-20200324143707-d3edc9973b7e/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A=
|
||||||
|
golang.org/x/net v0.0.0-20200501053045-e0ff5e5a1de5/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A=
|
||||||
|
golang.org/x/net v0.0.0-20200506145744-7e3656a0809f/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A=
|
||||||
|
golang.org/x/net v0.0.0-20200513185701-a91f0712d120/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A=
|
||||||
golang.org/x/net v0.0.0-20200520004742-59133d7f0dd7/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A=
|
golang.org/x/net v0.0.0-20200520004742-59133d7f0dd7/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A=
|
||||||
|
golang.org/x/net v0.0.0-20200520182314-0ba52f642ac2/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A=
|
||||||
|
golang.org/x/net v0.0.0-20200625001655-4c5254603344/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA=
|
||||||
|
golang.org/x/net v0.0.0-20200707034311-ab3426394381/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA=
|
||||||
|
golang.org/x/net v0.0.0-20200822124328-c89045814202/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA=
|
||||||
golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU=
|
golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU=
|
||||||
golang.org/x/net v0.0.0-20210428140749-89ef3d95e781/go.mod h1:OJAsFXCWl8Ukc7SiCT/9KSuxbyM7479/AVlXFRxuMCk=
|
golang.org/x/net v0.0.0-20210428140749-89ef3d95e781/go.mod h1:OJAsFXCWl8Ukc7SiCT/9KSuxbyM7479/AVlXFRxuMCk=
|
||||||
golang.org/x/net v0.0.0-20220225172249-27dd8689420f/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk=
|
golang.org/x/net v0.0.0-20220225172249-27dd8689420f/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk=
|
||||||
golang.org/x/net v0.41.0 h1:vBTly1HeNPEn3wtREYfy4GZ/NECgw2Cnl+nK6Nz3uvw=
|
golang.org/x/net v0.41.0 h1:vBTly1HeNPEn3wtREYfy4GZ/NECgw2Cnl+nK6Nz3uvw=
|
||||||
golang.org/x/net v0.41.0/go.mod h1:B/K4NNqkfmg07DQYrbwvSluqCJOOXwUjeb/5lOisjbA=
|
golang.org/x/net v0.41.0/go.mod h1:B/K4NNqkfmg07DQYrbwvSluqCJOOXwUjeb/5lOisjbA=
|
||||||
|
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
|
||||||
|
golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
|
||||||
|
golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
|
||||||
|
golang.org/x/oauth2 v0.0.0-20191202225959-858c2ad4c8b6/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
|
||||||
|
golang.org/x/oauth2 v0.0.0-20200107190931-bf48bf16ab8d/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
|
||||||
|
golang.org/x/oauth2 v0.0.0-20210323180902-22b0adad7558/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A=
|
||||||
|
golang.org/x/oauth2 v0.25.0 h1:CY4y7XT9v0cRI9oupztF8AgiIu99L/ksR/Xp/6jrZ70=
|
||||||
|
golang.org/x/oauth2 v0.25.0/go.mod h1:XYTD2NtWslqkgxebSiOHnXEap4TF09sJSc7H1sXbhtI=
|
||||||
golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||||
|
golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||||
|
golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||||
|
golang.org/x/sync v0.0.0-20190227155943-e225da77a7e6/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||||
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||||
|
golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||||
|
golang.org/x/sync v0.0.0-20200317015054-43a5402ce75a/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||||
|
golang.org/x/sync v0.0.0-20200625203802-6e8e738ad208/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||||
golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||||
golang.org/x/sync v0.16.0 h1:ycBJEhp9p4vXvUZNszeOq0kGTPghopOL8q0fq3vstxw=
|
golang.org/x/sync v0.16.0 h1:ycBJEhp9p4vXvUZNszeOq0kGTPghopOL8q0fq3vstxw=
|
||||||
golang.org/x/sync v0.16.0/go.mod h1:1dzgHSNfp02xaA81J2MS99Qcpr2w7fw1gpm99rleRqA=
|
golang.org/x/sync v0.16.0/go.mod h1:1dzgHSNfp02xaA81J2MS99Qcpr2w7fw1gpm99rleRqA=
|
||||||
|
golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||||
golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||||
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||||
|
golang.org/x/sys v0.0.0-20190312061237-fead79001313/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
|
golang.org/x/sys v0.0.0-20190502145724-3ef323f4f1fd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
|
golang.org/x/sys v0.0.0-20190507160741-ecd444e8653b/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
|
golang.org/x/sys v0.0.0-20190606165138-5da285871e9c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
|
golang.org/x/sys v0.0.0-20190624142023-c5567b49c5d0/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
|
golang.org/x/sys v0.0.0-20190726091711-fc99dfbffb4e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
golang.org/x/sys v0.0.0-20190904154756-749cb33beabd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
golang.org/x/sys v0.0.0-20190904154756-749cb33beabd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
|
golang.org/x/sys v0.0.0-20191001151750-bb3f8db39f24/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
golang.org/x/sys v0.0.0-20191005200804-aed5e4c7ecf9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
golang.org/x/sys v0.0.0-20191005200804-aed5e4c7ecf9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
golang.org/x/sys v0.0.0-20191120155948-bd437916bb0e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
golang.org/x/sys v0.0.0-20191120155948-bd437916bb0e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
golang.org/x/sys v0.0.0-20191204072324-ce4227a45e2e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
golang.org/x/sys v0.0.0-20191204072324-ce4227a45e2e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
|
golang.org/x/sys v0.0.0-20191228213918-04cbcbbfeed8/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
|
golang.org/x/sys v0.0.0-20200113162924-86b910548bc1/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
|
golang.org/x/sys v0.0.0-20200122134326-e047566fdf82/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
|
golang.org/x/sys v0.0.0-20200202164722-d101bd2416d5/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
|
golang.org/x/sys v0.0.0-20200212091648-12a6c2dcc1e4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
|
golang.org/x/sys v0.0.0-20200223170610-d5e6a3e2c0ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
|
golang.org/x/sys v0.0.0-20200302150141-5c8b2ff67527/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
|
golang.org/x/sys v0.0.0-20200331124033-c3d80250170d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
|
golang.org/x/sys v0.0.0-20200501052902-10377860bb8e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
|
golang.org/x/sys v0.0.0-20200511232937-7e40ca221e25/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
|
golang.org/x/sys v0.0.0-20200515095857-1151b9dac4a9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
|
golang.org/x/sys v0.0.0-20200523222454-059865788121/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
|
golang.org/x/sys v0.0.0-20200803210538-64077c9b5642/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
golang.org/x/sys v0.0.0-20210112080510-489259a85091/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
golang.org/x/sys v0.0.0-20210112080510-489259a85091/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
@ -229,23 +489,64 @@ golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBc
|
|||||||
golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
golang.org/x/sys v0.28.0 h1:Fksou7UEQUWlKvIdsqzJmUmCX3cZuD2+P3XyyzwMhlA=
|
|
||||||
golang.org/x/sys v0.28.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
|
|
||||||
golang.org/x/sys v0.34.0 h1:H5Y5sJ2L2JRdyv7ROF1he/lPdvFsd0mJHFw2ThKHxLA=
|
golang.org/x/sys v0.34.0 h1:H5Y5sJ2L2JRdyv7ROF1he/lPdvFsd0mJHFw2ThKHxLA=
|
||||||
golang.org/x/sys v0.34.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k=
|
golang.org/x/sys v0.34.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k=
|
||||||
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
|
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
|
||||||
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
|
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
|
||||||
|
golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||||
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||||
|
golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||||
|
golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk=
|
||||||
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
||||||
golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
||||||
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
|
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
|
||||||
golang.org/x/text v0.27.0 h1:4fGWRpyh641NLlecmyl4LOe6yDdfaYNrGb2zdfo4JV4=
|
golang.org/x/text v0.27.0 h1:4fGWRpyh641NLlecmyl4LOe6yDdfaYNrGb2zdfo4JV4=
|
||||||
golang.org/x/text v0.27.0/go.mod h1:1D28KMCvyooCX9hBiosv5Tz/+YLxj0j7XhWjpSUF7CU=
|
golang.org/x/text v0.27.0/go.mod h1:1D28KMCvyooCX9hBiosv5Tz/+YLxj0j7XhWjpSUF7CU=
|
||||||
|
golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
|
||||||
|
golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
|
||||||
|
golang.org/x/time v0.0.0-20191024005414-555d28b269f0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
|
||||||
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
||||||
|
golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
||||||
|
golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3HoIrodX9oNMXvdceNzlUR8zjMvY=
|
||||||
golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
|
golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
|
||||||
|
golang.org/x/tools v0.0.0-20190312151545-0bb0c0a6e846/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
|
||||||
|
golang.org/x/tools v0.0.0-20190312170243-e65039ee4138/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
|
||||||
|
golang.org/x/tools v0.0.0-20190425150028-36563e24a262/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q=
|
||||||
|
golang.org/x/tools v0.0.0-20190506145303-2d16b83fe98c/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q=
|
||||||
|
golang.org/x/tools v0.0.0-20190524140312-2c0ae7006135/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q=
|
||||||
|
golang.org/x/tools v0.0.0-20190606124116-d0a3d012864b/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc=
|
||||||
|
golang.org/x/tools v0.0.0-20190621195816-6e04913cbbac/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc=
|
||||||
|
golang.org/x/tools v0.0.0-20190628153133-6cdbf07be9d0/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc=
|
||||||
|
golang.org/x/tools v0.0.0-20190816200558-6889da9d5479/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
|
||||||
|
golang.org/x/tools v0.0.0-20190911174233-4f2ddba30aff/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
|
||||||
|
golang.org/x/tools v0.0.0-20191012152004-8de300cfc20a/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
|
||||||
golang.org/x/tools v0.0.0-20191029041327-9cc4af7d6b2c/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
|
golang.org/x/tools v0.0.0-20191029041327-9cc4af7d6b2c/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
|
||||||
golang.org/x/tools v0.0.0-20191108193012-7d206e10da11/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
|
golang.org/x/tools v0.0.0-20191108193012-7d206e10da11/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
|
||||||
|
golang.org/x/tools v0.0.0-20191113191852-77e3bb0ad9e7/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
|
||||||
|
golang.org/x/tools v0.0.0-20191115202509-3a792d9c32b2/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
|
||||||
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
|
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
|
||||||
|
golang.org/x/tools v0.0.0-20191125144606-a911d9008d1f/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
|
||||||
|
golang.org/x/tools v0.0.0-20191130070609-6e064ea0cf2d/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
|
||||||
|
golang.org/x/tools v0.0.0-20191216173652-a0e659d51361/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28=
|
||||||
|
golang.org/x/tools v0.0.0-20191227053925-7b8e75db28f4/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28=
|
||||||
|
golang.org/x/tools v0.0.0-20200117161641-43d50277825c/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28=
|
||||||
|
golang.org/x/tools v0.0.0-20200122220014-bf1340f18c4a/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28=
|
||||||
|
golang.org/x/tools v0.0.0-20200130002326-2f3ba24bd6e7/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28=
|
||||||
|
golang.org/x/tools v0.0.0-20200204074204-1cc6d1ef6c74/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28=
|
||||||
|
golang.org/x/tools v0.0.0-20200207183749-b753a1ba74fa/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28=
|
||||||
|
golang.org/x/tools v0.0.0-20200212150539-ea181f53ac56/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28=
|
||||||
|
golang.org/x/tools v0.0.0-20200224181240-023911ca70b2/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28=
|
||||||
|
golang.org/x/tools v0.0.0-20200227222343-706bc42d1f0d/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28=
|
||||||
|
golang.org/x/tools v0.0.0-20200304193943-95d2e580d8eb/go.mod h1:o4KQGtdN14AW+yjsvvwRTJJuXz8XRtIHtEnmAXLyFUw=
|
||||||
|
golang.org/x/tools v0.0.0-20200312045724-11d5b4c81c7d/go.mod h1:o4KQGtdN14AW+yjsvvwRTJJuXz8XRtIHtEnmAXLyFUw=
|
||||||
|
golang.org/x/tools v0.0.0-20200331025713-a30bf2db82d4/go.mod h1:Sl4aGygMT6LrqrWclx+PTx3U+LnKx/seiNR+3G19Ar8=
|
||||||
|
golang.org/x/tools v0.0.0-20200501065659-ab2804fb9c9d/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE=
|
||||||
|
golang.org/x/tools v0.0.0-20200512131952-2bc93b1c0c88/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE=
|
||||||
|
golang.org/x/tools v0.0.0-20200515010526-7d3b6ebf133d/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE=
|
||||||
|
golang.org/x/tools v0.0.0-20200618134242-20370b0cb4b2/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE=
|
||||||
|
golang.org/x/tools v0.0.0-20200729194436-6467de6f59a7/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA=
|
||||||
|
golang.org/x/tools v0.0.0-20200804011535-6c149bb5ef0d/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA=
|
||||||
|
golang.org/x/tools v0.0.0-20200825202427-b303f430e36d/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA=
|
||||||
golang.org/x/tools v0.0.0-20201224043029-2b0845dc783e/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA=
|
golang.org/x/tools v0.0.0-20201224043029-2b0845dc783e/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA=
|
||||||
golang.org/x/tools v0.34.0 h1:qIpSLOxeCYGg9TrcJokLBG4KFA6d795g0xkBkiESGlo=
|
golang.org/x/tools v0.34.0 h1:qIpSLOxeCYGg9TrcJokLBG4KFA6d795g0xkBkiESGlo=
|
||||||
golang.org/x/tools v0.34.0/go.mod h1:pAP9OwEaY1CAW3HOmg3hLZC5Z0CCmzjAF2UQMSqNARg=
|
golang.org/x/tools v0.34.0/go.mod h1:pAP9OwEaY1CAW3HOmg3hLZC5Z0CCmzjAF2UQMSqNARg=
|
||||||
@ -253,10 +554,73 @@ golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8T
|
|||||||
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||||
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||||
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||||
|
google.golang.org/api v0.4.0/go.mod h1:8k5glujaEP+g9n7WNsDg8QP6cUVNI86fCNMcbazEtwE=
|
||||||
|
google.golang.org/api v0.7.0/go.mod h1:WtwebWUNSVBH/HAw79HIFXZNqEvBhG+Ra+ax0hx3E3M=
|
||||||
|
google.golang.org/api v0.8.0/go.mod h1:o4eAsZoiT+ibD93RtjEohWalFOjRDx6CVaqeizhEnKg=
|
||||||
|
google.golang.org/api v0.9.0/go.mod h1:o4eAsZoiT+ibD93RtjEohWalFOjRDx6CVaqeizhEnKg=
|
||||||
|
google.golang.org/api v0.13.0/go.mod h1:iLdEw5Ide6rF15KTC1Kkl0iskquN2gFfn9o9XIsbkAI=
|
||||||
|
google.golang.org/api v0.14.0/go.mod h1:iLdEw5Ide6rF15KTC1Kkl0iskquN2gFfn9o9XIsbkAI=
|
||||||
|
google.golang.org/api v0.15.0/go.mod h1:iLdEw5Ide6rF15KTC1Kkl0iskquN2gFfn9o9XIsbkAI=
|
||||||
|
google.golang.org/api v0.17.0/go.mod h1:BwFmGc8tA3vsd7r/7kR8DY7iEEGSU04BFxCo5jP/sfE=
|
||||||
|
google.golang.org/api v0.18.0/go.mod h1:BwFmGc8tA3vsd7r/7kR8DY7iEEGSU04BFxCo5jP/sfE=
|
||||||
|
google.golang.org/api v0.19.0/go.mod h1:BwFmGc8tA3vsd7r/7kR8DY7iEEGSU04BFxCo5jP/sfE=
|
||||||
|
google.golang.org/api v0.20.0/go.mod h1:BwFmGc8tA3vsd7r/7kR8DY7iEEGSU04BFxCo5jP/sfE=
|
||||||
|
google.golang.org/api v0.22.0/go.mod h1:BwFmGc8tA3vsd7r/7kR8DY7iEEGSU04BFxCo5jP/sfE=
|
||||||
|
google.golang.org/api v0.24.0/go.mod h1:lIXQywCXRcnZPGlsd8NbLnOjtAoL6em04bJ9+z0MncE=
|
||||||
|
google.golang.org/api v0.28.0/go.mod h1:lIXQywCXRcnZPGlsd8NbLnOjtAoL6em04bJ9+z0MncE=
|
||||||
|
google.golang.org/api v0.29.0/go.mod h1:Lcubydp8VUV7KeIHD9z2Bys/sm/vGKnG1UHuDBSrHWM=
|
||||||
|
google.golang.org/api v0.30.0/go.mod h1:QGmEvQ87FHZNiUVJkT14jQNYJ4ZJjdRF23ZXz5138Fc=
|
||||||
|
google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM=
|
||||||
|
google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4=
|
||||||
|
google.golang.org/appengine v1.5.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4=
|
||||||
|
google.golang.org/appengine v1.6.1/go.mod h1:i06prIuMbXzDqacNJfV5OdTW448YApPu5ww/cMBSeb0=
|
||||||
|
google.golang.org/appengine v1.6.5/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc=
|
||||||
|
google.golang.org/appengine v1.6.6/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc=
|
||||||
|
google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc=
|
||||||
|
google.golang.org/genproto v0.0.0-20190307195333-5fe7a883aa19/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE=
|
||||||
|
google.golang.org/genproto v0.0.0-20190418145605-e7d98fc518a7/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE=
|
||||||
|
google.golang.org/genproto v0.0.0-20190425155659-357c62f0e4bb/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE=
|
||||||
|
google.golang.org/genproto v0.0.0-20190502173448-54afdca5d873/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE=
|
||||||
|
google.golang.org/genproto v0.0.0-20190801165951-fa694d86fc64/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc=
|
||||||
|
google.golang.org/genproto v0.0.0-20190819201941-24fa4b261c55/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc=
|
||||||
|
google.golang.org/genproto v0.0.0-20190911173649-1774047e7e51/go.mod h1:IbNlFCBrqXvoKpeg0TB2l7cyZUmoaFKYIwrEpbDKLA8=
|
||||||
|
google.golang.org/genproto v0.0.0-20191108220845-16a3f7862a1a/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc=
|
||||||
|
google.golang.org/genproto v0.0.0-20191115194625-c23dd37a84c9/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc=
|
||||||
|
google.golang.org/genproto v0.0.0-20191216164720-4f79533eabd1/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc=
|
||||||
|
google.golang.org/genproto v0.0.0-20191230161307-f3c370f40bfb/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc=
|
||||||
|
google.golang.org/genproto v0.0.0-20200115191322-ca5a22157cba/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc=
|
||||||
|
google.golang.org/genproto v0.0.0-20200122232147-0452cf42e150/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc=
|
||||||
|
google.golang.org/genproto v0.0.0-20200204135345-fa8e72b47b90/go.mod h1:GmwEX6Z4W5gMy59cAlVYjN9JhxgbQH6Gn+gFDQe2lzA=
|
||||||
|
google.golang.org/genproto v0.0.0-20200212174721-66ed5ce911ce/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c=
|
||||||
|
google.golang.org/genproto v0.0.0-20200224152610-e50cd9704f63/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c=
|
||||||
|
google.golang.org/genproto v0.0.0-20200228133532-8c2c7df3a383/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c=
|
||||||
|
google.golang.org/genproto v0.0.0-20200305110556-506484158171/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c=
|
||||||
|
google.golang.org/genproto v0.0.0-20200312145019-da6875a35672/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c=
|
||||||
|
google.golang.org/genproto v0.0.0-20200331122359-1ee6d9798940/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c=
|
||||||
|
google.golang.org/genproto v0.0.0-20200430143042-b979b6f78d84/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c=
|
||||||
|
google.golang.org/genproto v0.0.0-20200511104702-f5ebc3bea380/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c=
|
||||||
|
google.golang.org/genproto v0.0.0-20200515170657-fc4c6c6a6587/go.mod h1:YsZOwe1myG/8QRHRsmBRE1LrgQY60beZKjly0O1fX9U=
|
||||||
|
google.golang.org/genproto v0.0.0-20200526211855-cb27e3aa2013/go.mod h1:NbSheEEYHJ7i3ixzK3sjbqSGDJWnxyFXZblF3eUsNvo=
|
||||||
|
google.golang.org/genproto v0.0.0-20200618031413-b414f8b61790/go.mod h1:jDfRM7FcilCzHH/e9qn6dsT145K34l5v+OpcnNgKAAA=
|
||||||
|
google.golang.org/genproto v0.0.0-20200729003335-053ba62fc06f/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no=
|
||||||
|
google.golang.org/genproto v0.0.0-20200804131852-c06518451d9c/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no=
|
||||||
|
google.golang.org/genproto v0.0.0-20200825200019-8632dd797987/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no=
|
||||||
google.golang.org/genproto/googleapis/api v0.0.0-20250106144421-5f5ef82da422 h1:GVIKPyP/kLIyVOgOnTwFOrvQaQUzOzGMCxgFUOEmm24=
|
google.golang.org/genproto/googleapis/api v0.0.0-20250106144421-5f5ef82da422 h1:GVIKPyP/kLIyVOgOnTwFOrvQaQUzOzGMCxgFUOEmm24=
|
||||||
google.golang.org/genproto/googleapis/api v0.0.0-20250106144421-5f5ef82da422/go.mod h1:b6h1vNKhxaSoEI+5jc3PJUCustfli/mRab7295pY7rw=
|
google.golang.org/genproto/googleapis/api v0.0.0-20250106144421-5f5ef82da422/go.mod h1:b6h1vNKhxaSoEI+5jc3PJUCustfli/mRab7295pY7rw=
|
||||||
google.golang.org/genproto/googleapis/rpc v0.0.0-20250115164207-1a7da9e5054f h1:OxYkA3wjPsZyBylwymxSHa7ViiW1Sml4ToBrncvFehI=
|
google.golang.org/genproto/googleapis/rpc v0.0.0-20250115164207-1a7da9e5054f h1:OxYkA3wjPsZyBylwymxSHa7ViiW1Sml4ToBrncvFehI=
|
||||||
google.golang.org/genproto/googleapis/rpc v0.0.0-20250115164207-1a7da9e5054f/go.mod h1:+2Yz8+CLJbIfL9z73EW45avw8Lmge3xVElCP9zEKi50=
|
google.golang.org/genproto/googleapis/rpc v0.0.0-20250115164207-1a7da9e5054f/go.mod h1:+2Yz8+CLJbIfL9z73EW45avw8Lmge3xVElCP9zEKi50=
|
||||||
|
google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c=
|
||||||
|
google.golang.org/grpc v1.20.1/go.mod h1:10oTOabMzJvdu6/UiuZezV6QK5dSlG84ov/aaiqXj38=
|
||||||
|
google.golang.org/grpc v1.21.1/go.mod h1:oYelfM1adQP15Ek0mdvEgi9Df8B9CZIaU1084ijfRaM=
|
||||||
|
google.golang.org/grpc v1.23.0/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg=
|
||||||
|
google.golang.org/grpc v1.25.1/go.mod h1:c3i+UQWmh7LiEpx4sFZnkU36qjEYZ0imhYfXVyQciAY=
|
||||||
|
google.golang.org/grpc v1.26.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk=
|
||||||
|
google.golang.org/grpc v1.27.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk=
|
||||||
|
google.golang.org/grpc v1.27.1/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk=
|
||||||
|
google.golang.org/grpc v1.28.0/go.mod h1:rpkK4SK4GF4Ach/+MFLZUBavHOvF2JJB5uozKKal+60=
|
||||||
|
google.golang.org/grpc v1.29.1/go.mod h1:itym6AZVZYACWQqET3MqgPpjcuV5QH3BxFS3IjizoKk=
|
||||||
|
google.golang.org/grpc v1.30.0/go.mod h1:N36X2cJ7JwdamYAgDz+s+rVMFjt3numwzf/HckM8pak=
|
||||||
|
google.golang.org/grpc v1.31.0/go.mod h1:N36X2cJ7JwdamYAgDz+s+rVMFjt3numwzf/HckM8pak=
|
||||||
google.golang.org/grpc v1.71.1 h1:ffsFWr7ygTUscGPI0KKK6TLrGz0476KUvvsbqWK0rPI=
|
google.golang.org/grpc v1.71.1 h1:ffsFWr7ygTUscGPI0KKK6TLrGz0476KUvvsbqWK0rPI=
|
||||||
google.golang.org/grpc v1.71.1/go.mod h1:H0GRtasmQOh9LkFoCPDu3ZrwUtD1YGE+b2vYBYd/8Ec=
|
google.golang.org/grpc v1.71.1/go.mod h1:H0GRtasmQOh9LkFoCPDu3ZrwUtD1YGE+b2vYBYd/8Ec=
|
||||||
google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8=
|
google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8=
|
||||||
@ -264,7 +628,11 @@ google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ
|
|||||||
google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM=
|
google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM=
|
||||||
google.golang.org/protobuf v1.20.1-0.20200309200217-e05f789c0967/go.mod h1:A+miEFZTKqfCUM6K7xSMQL9OKL/b6hQv+e19PK+JZNE=
|
google.golang.org/protobuf v1.20.1-0.20200309200217-e05f789c0967/go.mod h1:A+miEFZTKqfCUM6K7xSMQL9OKL/b6hQv+e19PK+JZNE=
|
||||||
google.golang.org/protobuf v1.21.0/go.mod h1:47Nbq4nVaFHyn7ilMalzfO3qCViNmqZ2kzikPIcrTAo=
|
google.golang.org/protobuf v1.21.0/go.mod h1:47Nbq4nVaFHyn7ilMalzfO3qCViNmqZ2kzikPIcrTAo=
|
||||||
|
google.golang.org/protobuf v1.22.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU=
|
||||||
google.golang.org/protobuf v1.23.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU=
|
google.golang.org/protobuf v1.23.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU=
|
||||||
|
google.golang.org/protobuf v1.23.1-0.20200526195155-81db48ad09cc/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU=
|
||||||
|
google.golang.org/protobuf v1.24.0/go.mod h1:r/3tXBNzIEhYS9I1OUVjXDlt8tc493IdKGjtUeSXeh4=
|
||||||
|
google.golang.org/protobuf v1.25.0/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlbajtzgsN7c=
|
||||||
google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw=
|
google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw=
|
||||||
google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc=
|
google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc=
|
||||||
google.golang.org/protobuf v1.31.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I=
|
google.golang.org/protobuf v1.31.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I=
|
||||||
@ -273,10 +641,14 @@ google.golang.org/protobuf v1.36.6/go.mod h1:jduwjTPXsFjZGTmRluh+L6NjiWu7pchiJ2/
|
|||||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||||
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||||
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||||
|
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk=
|
||||||
|
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q=
|
||||||
|
gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI=
|
||||||
gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys=
|
gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys=
|
||||||
gopkg.in/natefinch/lumberjack.v2 v2.0.0/go.mod h1:l0ndWWf7gzL7RNwBG7wST/UCcT4T24xpD6X8LsfU/+k=
|
gopkg.in/natefinch/lumberjack.v2 v2.0.0/go.mod h1:l0ndWWf7gzL7RNwBG7wST/UCcT4T24xpD6X8LsfU/+k=
|
||||||
gopkg.in/natefinch/lumberjack.v2 v2.2.1 h1:bBRl1b0OH9s/DuPhuXpNl+VtCaJXFZ5/uEFST95x9zc=
|
gopkg.in/natefinch/lumberjack.v2 v2.2.1 h1:bBRl1b0OH9s/DuPhuXpNl+VtCaJXFZ5/uEFST95x9zc=
|
||||||
gopkg.in/natefinch/lumberjack.v2 v2.2.1/go.mod h1:YD8tP3GAjkrDg1eZH7EGmyESg/lsYskCTPBJVb9jqSc=
|
gopkg.in/natefinch/lumberjack.v2 v2.2.1/go.mod h1:YD8tP3GAjkrDg1eZH7EGmyESg/lsYskCTPBJVb9jqSc=
|
||||||
|
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 h1:uRGJdciOHaEIrze2W8Q3AKkepLTh2hOroT7a+7czfdQ=
|
||||||
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw=
|
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw=
|
||||||
gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||||
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||||
@ -290,11 +662,37 @@ gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C
|
|||||||
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||||
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
|
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
|
||||||
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||||
|
honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
|
||||||
|
honnef.co/go/tools v0.0.0-20190106161140-3f1c8253044a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
|
||||||
|
honnef.co/go/tools v0.0.0-20190418001031-e561f6794a2a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
|
||||||
|
honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
|
||||||
|
honnef.co/go/tools v0.0.1-2019.2.3/go.mod h1:a3bituU0lyd329TUQxRnasdCoJDkEUEAqEt0JzvZhAg=
|
||||||
|
honnef.co/go/tools v0.0.1-2020.1.3/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k=
|
||||||
|
honnef.co/go/tools v0.0.1-2020.1.4/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k=
|
||||||
|
modernc.org/cc/v4 v4.25.2 h1:T2oH7sZdGvTaie0BRNFbIYsabzCxUQg8nLqCdQ2i0ic=
|
||||||
|
modernc.org/cc/v4 v4.25.2/go.mod h1:uVtb5OGqUKpoLWhqwNQo/8LwvoiEBLvZXIQ/SmO6mL0=
|
||||||
|
modernc.org/ccgo/v4 v4.25.1 h1:TFSzPrAGmDsdnhT9X2UrcPMI3N/mJ9/X9ykKXwLhDsU=
|
||||||
|
modernc.org/ccgo/v4 v4.25.1/go.mod h1:njjuAYiPflywOOrm3B7kCB444ONP5pAVr8PIEoE0uDw=
|
||||||
|
modernc.org/fileutil v1.3.0 h1:gQ5SIzK3H9kdfai/5x41oQiKValumqNTDXMvKo62HvE=
|
||||||
|
modernc.org/fileutil v1.3.0/go.mod h1:XatxS8fZi3pS8/hKG2GH/ArUogfxjpEKs3Ku3aK4JyQ=
|
||||||
|
modernc.org/gc/v2 v2.6.5 h1:nyqdV8q46KvTpZlsw66kWqwXRHdjIlJOhG6kxiV/9xI=
|
||||||
|
modernc.org/gc/v2 v2.6.5/go.mod h1:YgIahr1ypgfe7chRuJi2gD7DBQiKSLMPgBQe9oIiito=
|
||||||
modernc.org/libc v1.62.1 h1:s0+fv5E3FymN8eJVmnk0llBe6rOxCu/DEU+XygRbS8s=
|
modernc.org/libc v1.62.1 h1:s0+fv5E3FymN8eJVmnk0llBe6rOxCu/DEU+XygRbS8s=
|
||||||
modernc.org/libc v1.62.1/go.mod h1:iXhATfJQLjG3NWy56a6WVU73lWOcdYVxsvwCgoPljuo=
|
modernc.org/libc v1.62.1/go.mod h1:iXhATfJQLjG3NWy56a6WVU73lWOcdYVxsvwCgoPljuo=
|
||||||
modernc.org/mathutil v1.7.1 h1:GCZVGXdaN8gTqB1Mf/usp1Y/hSqgI2vAGGP4jZMCxOU=
|
modernc.org/mathutil v1.7.1 h1:GCZVGXdaN8gTqB1Mf/usp1Y/hSqgI2vAGGP4jZMCxOU=
|
||||||
modernc.org/mathutil v1.7.1/go.mod h1:4p5IwJITfppl0G4sUEDtCr4DthTaT47/N3aT6MhfgJg=
|
modernc.org/mathutil v1.7.1/go.mod h1:4p5IwJITfppl0G4sUEDtCr4DthTaT47/N3aT6MhfgJg=
|
||||||
modernc.org/memory v1.9.1 h1:V/Z1solwAVmMW1yttq3nDdZPJqV1rM05Ccq6KMSZ34g=
|
modernc.org/memory v1.9.1 h1:V/Z1solwAVmMW1yttq3nDdZPJqV1rM05Ccq6KMSZ34g=
|
||||||
modernc.org/memory v1.9.1/go.mod h1:/JP4VbVC+K5sU2wZi9bHoq2MAkCnrt2r98UGeSK7Mjw=
|
modernc.org/memory v1.9.1/go.mod h1:/JP4VbVC+K5sU2wZi9bHoq2MAkCnrt2r98UGeSK7Mjw=
|
||||||
|
modernc.org/opt v0.1.4 h1:2kNGMRiUjrp4LcaPuLY2PzUfqM/w9N23quVwhKt5Qm8=
|
||||||
|
modernc.org/opt v0.1.4/go.mod h1:03fq9lsNfvkYSfxrfUhZCWPk1lm4cq4N+Bh//bEtgns=
|
||||||
|
modernc.org/sortutil v1.2.1 h1:+xyoGf15mM3NMlPDnFqrteY07klSFxLElE2PVuWIJ7w=
|
||||||
|
modernc.org/sortutil v1.2.1/go.mod h1:7ZI3a3REbai7gzCLcotuw9AC4VZVpYMjDzETGsSMqJE=
|
||||||
modernc.org/sqlite v1.37.0 h1:s1TMe7T3Q3ovQiK2Ouz4Jwh7dw4ZDqbebSDTlSJdfjI=
|
modernc.org/sqlite v1.37.0 h1:s1TMe7T3Q3ovQiK2Ouz4Jwh7dw4ZDqbebSDTlSJdfjI=
|
||||||
modernc.org/sqlite v1.37.0/go.mod h1:5YiWv+YviqGMuGw4V+PNplcyaJ5v+vQd7TQOgkACoJM=
|
modernc.org/sqlite v1.37.0/go.mod h1:5YiWv+YviqGMuGw4V+PNplcyaJ5v+vQd7TQOgkACoJM=
|
||||||
|
modernc.org/strutil v1.2.1 h1:UneZBkQA+DX2Rp35KcM69cSsNES9ly8mQWD71HKlOA0=
|
||||||
|
modernc.org/strutil v1.2.1/go.mod h1:EHkiggD70koQxjVdSBM3JKM7k6L0FbGE5eymy9i3B9A=
|
||||||
|
modernc.org/token v1.1.0 h1:Xl7Ap9dKaEs5kLoOQeQmPWevfnk/DM5qcLcYlA8ys6Y=
|
||||||
|
modernc.org/token v1.1.0/go.mod h1:UGzOrNV1mAFSEB63lOFHIpNRUVMvYTc6yu1SMY/XTDM=
|
||||||
|
rsc.io/binaryregexp v0.2.0/go.mod h1:qTv7/COck+e2FymRvadv62gMdZztPaShugOCi3I+8D8=
|
||||||
|
rsc.io/quote/v3 v3.1.0/go.mod h1:yEA65RcK8LyAZtP9Kv3t0HmxON59tX3rD+tICJqUlj0=
|
||||||
|
rsc.io/sampler v1.3.0/go.mod h1:T1hPZKmBbMNahiBKFy5HrXp6adAjACjK9JXDnKaTXpA=
|
||||||
|
|||||||
51
internal/api/auth/domain/auth_domain.go
Normal file
51
internal/api/auth/domain/auth_domain.go
Normal file
@ -0,0 +1,51 @@
|
|||||||
|
package domain
|
||||||
|
|
||||||
|
import "context"
|
||||||
|
|
||||||
|
type AuthRepository interface {
|
||||||
|
SaveOtpRequest(ctx context.Context, uuid string, code string) error
|
||||||
|
GetOtpRequest(ctx context.Context, uuid string) (*string, error)
|
||||||
|
}
|
||||||
|
|
||||||
|
type ErrOtpNotFound struct {
|
||||||
|
Uuid string
|
||||||
|
}
|
||||||
|
|
||||||
|
func (e ErrOtpNotFound) Error() string {
|
||||||
|
return "OTP request not found for UUID: " + e.Uuid
|
||||||
|
}
|
||||||
|
|
||||||
|
type ErrUserNotFound struct {
|
||||||
|
PhoneNumber string
|
||||||
|
}
|
||||||
|
|
||||||
|
func (e ErrUserNotFound) Error() string {
|
||||||
|
return "User not found with phone number: " + e.PhoneNumber
|
||||||
|
}
|
||||||
|
|
||||||
|
type ErrOtpInvalid struct {
|
||||||
|
Code string
|
||||||
|
Uuid string
|
||||||
|
}
|
||||||
|
|
||||||
|
func (e ErrOtpInvalid) Error() string {
|
||||||
|
return "Invalid OTP code: " + e.Code + " for UUID: " + e.Uuid
|
||||||
|
}
|
||||||
|
|
||||||
|
type ErrInvalidHydraAccept struct {
|
||||||
|
Message string
|
||||||
|
Uuid string
|
||||||
|
}
|
||||||
|
|
||||||
|
func (e ErrInvalidHydraAccept) Error() string {
|
||||||
|
return "Invalid Hydra accept request: " + e.Message + " for UUID: " + e.Uuid
|
||||||
|
}
|
||||||
|
|
||||||
|
type ErrInvalidPhoneNumber struct {
|
||||||
|
PhoneNumber string
|
||||||
|
Err error
|
||||||
|
}
|
||||||
|
|
||||||
|
func (e ErrInvalidPhoneNumber) Error() string {
|
||||||
|
return "Invalid phone number: " + e.PhoneNumber + ", error: " + e.Err.Error()
|
||||||
|
}
|
||||||
146
internal/api/auth/domain/auth_domain_test.go
Normal file
146
internal/api/auth/domain/auth_domain_test.go
Normal file
@ -0,0 +1,146 @@
|
|||||||
|
package domain
|
||||||
|
|
||||||
|
import (
|
||||||
|
"testing"
|
||||||
|
|
||||||
|
"github.com/stretchr/testify/assert"
|
||||||
|
)
|
||||||
|
|
||||||
|
func TestErrOtpNotFound_Error(t *testing.T) {
|
||||||
|
tests := []struct {
|
||||||
|
name string
|
||||||
|
uuid string
|
||||||
|
want string
|
||||||
|
}{
|
||||||
|
{
|
||||||
|
name: "returns formatted error message",
|
||||||
|
uuid: "123e4567-e89b-12d3-a456-426614174000",
|
||||||
|
want: "OTP request not found for UUID: 123e4567-e89b-12d3-a456-426614174000",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "handles empty uuid",
|
||||||
|
uuid: "",
|
||||||
|
want: "OTP request not found for UUID: ",
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, tt := range tests {
|
||||||
|
t.Run(tt.name, func(t *testing.T) {
|
||||||
|
err := ErrOtpNotFound{Uuid: tt.uuid}
|
||||||
|
assert.Equal(t, tt.want, err.Error())
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestErrUserNotFound_Error(t *testing.T) {
|
||||||
|
tests := []struct {
|
||||||
|
name string
|
||||||
|
phoneNumber string
|
||||||
|
want string
|
||||||
|
}{
|
||||||
|
{
|
||||||
|
name: "returns formatted error message",
|
||||||
|
phoneNumber: "+1234567890",
|
||||||
|
want: "User not found with phone number: +1234567890",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "handles empty phone number",
|
||||||
|
phoneNumber: "",
|
||||||
|
want: "User not found with phone number: ",
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, tt := range tests {
|
||||||
|
t.Run(tt.name, func(t *testing.T) {
|
||||||
|
err := ErrUserNotFound{PhoneNumber: tt.phoneNumber}
|
||||||
|
assert.Equal(t, tt.want, err.Error())
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestErrOtpInvalid_Error(t *testing.T) {
|
||||||
|
tests := []struct {
|
||||||
|
name string
|
||||||
|
code string
|
||||||
|
uuid string
|
||||||
|
want string
|
||||||
|
}{
|
||||||
|
{
|
||||||
|
name: "returns formatted error message",
|
||||||
|
code: "123456",
|
||||||
|
uuid: "123e4567-e89b-12d3-a456-426614174000",
|
||||||
|
want: "Invalid OTP code: 123456 for UUID: 123e4567-e89b-12d3-a456-426614174000",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "handles empty values",
|
||||||
|
code: "",
|
||||||
|
uuid: "",
|
||||||
|
want: "Invalid OTP code: for UUID: ",
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, tt := range tests {
|
||||||
|
t.Run(tt.name, func(t *testing.T) {
|
||||||
|
err := ErrOtpInvalid{Code: tt.code, Uuid: tt.uuid}
|
||||||
|
assert.Equal(t, tt.want, err.Error())
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestErrInvalidHydraAccept_Error(t *testing.T) {
|
||||||
|
tests := []struct {
|
||||||
|
name string
|
||||||
|
message string
|
||||||
|
uuid string
|
||||||
|
want string
|
||||||
|
}{
|
||||||
|
{
|
||||||
|
name: "returns formatted error message",
|
||||||
|
message: "Invalid response",
|
||||||
|
uuid: "123e4567-e89b-12d3-a456-426614174000",
|
||||||
|
want: "Invalid Hydra accept request: Invalid response for UUID: 123e4567-e89b-12d3-a456-426614174000",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "handles empty values",
|
||||||
|
message: "",
|
||||||
|
uuid: "",
|
||||||
|
want: "Invalid Hydra accept request: for UUID: ",
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, tt := range tests {
|
||||||
|
t.Run(tt.name, func(t *testing.T) {
|
||||||
|
err := ErrInvalidHydraAccept{Message: tt.message, Uuid: tt.uuid}
|
||||||
|
assert.Equal(t, tt.want, err.Error())
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestErrInvalidPhoneNumber_Error(t *testing.T) {
|
||||||
|
tests := []struct {
|
||||||
|
name string
|
||||||
|
phoneNumber string
|
||||||
|
err error
|
||||||
|
want string
|
||||||
|
}{
|
||||||
|
{
|
||||||
|
name: "returns formatted error message with nested error",
|
||||||
|
phoneNumber: "invalid",
|
||||||
|
err: assert.AnError,
|
||||||
|
want: "Invalid phone number: invalid, error: assert.AnError general error for testing",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "handles empty phone number",
|
||||||
|
phoneNumber: "",
|
||||||
|
err: assert.AnError,
|
||||||
|
want: "Invalid phone number: , error: assert.AnError general error for testing",
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, tt := range tests {
|
||||||
|
t.Run(tt.name, func(t *testing.T) {
|
||||||
|
err := ErrInvalidPhoneNumber{PhoneNumber: tt.phoneNumber, Err: tt.err}
|
||||||
|
assert.Equal(t, tt.want, err.Error())
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
20
internal/api/auth/fx.go
Normal file
20
internal/api/auth/fx.go
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
package auth
|
||||||
|
|
||||||
|
import (
|
||||||
|
"git.logidex.ru/fakz9/logidex-id/internal/api/auth/handler"
|
||||||
|
"git.logidex.ru/fakz9/logidex-id/internal/api/auth/repo"
|
||||||
|
"git.logidex.ru/fakz9/logidex-id/internal/api/auth/service"
|
||||||
|
"github.com/gofiber/fiber/v2"
|
||||||
|
"go.uber.org/fx"
|
||||||
|
)
|
||||||
|
|
||||||
|
var Module = fx.Options(
|
||||||
|
fx.Provide(
|
||||||
|
repo.NewAuthRepo,
|
||||||
|
service.NewAuthService,
|
||||||
|
handler.NewAuthHandler,
|
||||||
|
),
|
||||||
|
fx.Invoke(func(handler *handler.AuthHandler, router fiber.Router) {
|
||||||
|
handler.RegisterRoutes(router)
|
||||||
|
}),
|
||||||
|
)
|
||||||
343
internal/api/auth/handler/gen.go
Normal file
343
internal/api/auth/handler/gen.go
Normal file
@ -0,0 +1,343 @@
|
|||||||
|
// Package handler provides primitives to interact with the openapi HTTP API.
|
||||||
|
//
|
||||||
|
// Code generated by github.com/oapi-codegen/oapi-codegen/v2 version v2.5.0 DO NOT EDIT.
|
||||||
|
package handler
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"fmt"
|
||||||
|
|
||||||
|
"github.com/gofiber/fiber/v2"
|
||||||
|
)
|
||||||
|
|
||||||
|
// AcceptConsentRequest defines model for AcceptConsentRequest.
|
||||||
|
type AcceptConsentRequest struct {
|
||||||
|
// ConsentChallenge The consent challenge to accept
|
||||||
|
ConsentChallenge string `json:"consent_challenge"`
|
||||||
|
|
||||||
|
// PhoneNumber Phone number associated with the consent
|
||||||
|
PhoneNumber string `json:"phone_number"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// AcceptConsentResponse defines model for AcceptConsentResponse.
|
||||||
|
type AcceptConsentResponse struct {
|
||||||
|
Message string `json:"message"`
|
||||||
|
|
||||||
|
// Ok Status of the consent acceptance
|
||||||
|
Ok bool `json:"ok"`
|
||||||
|
|
||||||
|
// RedirectUrl URL to redirect to after accepting consent
|
||||||
|
RedirectUrl string `json:"redirect_url"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// RequestOTPRequest defines model for RequestOTPRequest.
|
||||||
|
type RequestOTPRequest struct {
|
||||||
|
// PhoneNumber Phone number to send OTP to
|
||||||
|
PhoneNumber string `json:"phone_number"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// RequestOTPResponse defines model for RequestOTPResponse.
|
||||||
|
type RequestOTPResponse struct {
|
||||||
|
// Message Confirmation message
|
||||||
|
Message string `json:"message"`
|
||||||
|
|
||||||
|
// Ok Status of the request
|
||||||
|
Ok bool `json:"ok"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// VerifyOTPRequest defines model for VerifyOTPRequest.
|
||||||
|
type VerifyOTPRequest struct {
|
||||||
|
// LoginChallenge Login challenge for verification
|
||||||
|
LoginChallenge string `json:"login_challenge"`
|
||||||
|
|
||||||
|
// Otp One-time password to verify
|
||||||
|
Otp string `json:"otp"`
|
||||||
|
|
||||||
|
// PhoneNumber Phone number to verify OTP for
|
||||||
|
PhoneNumber string `json:"phone_number"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// VerifyOTPResponse defines model for VerifyOTPResponse.
|
||||||
|
type VerifyOTPResponse struct {
|
||||||
|
// Message Confirmation message
|
||||||
|
Message string `json:"message"`
|
||||||
|
|
||||||
|
// Ok Status of the verification
|
||||||
|
Ok bool `json:"ok"`
|
||||||
|
|
||||||
|
// RedirectUrl URL to redirect to after successful verification
|
||||||
|
RedirectUrl string `json:"redirect_url"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// PostAuthConsentAcceptJSONRequestBody defines body for PostAuthConsentAccept for application/json ContentType.
|
||||||
|
type PostAuthConsentAcceptJSONRequestBody = AcceptConsentRequest
|
||||||
|
|
||||||
|
// PostAuthOtpRequestJSONRequestBody defines body for PostAuthOtpRequest for application/json ContentType.
|
||||||
|
type PostAuthOtpRequestJSONRequestBody = RequestOTPRequest
|
||||||
|
|
||||||
|
// PostAuthOtpVerifyJSONRequestBody defines body for PostAuthOtpVerify for application/json ContentType.
|
||||||
|
type PostAuthOtpVerifyJSONRequestBody = VerifyOTPRequest
|
||||||
|
|
||||||
|
// ServerInterface represents all server handlers.
|
||||||
|
type ServerInterface interface {
|
||||||
|
// Accept consent
|
||||||
|
// (POST /auth/consent/accept)
|
||||||
|
PostAuthConsentAccept(c *fiber.Ctx) error
|
||||||
|
// Request OTP
|
||||||
|
// (POST /auth/otp/request)
|
||||||
|
PostAuthOtpRequest(c *fiber.Ctx) error
|
||||||
|
// Verify OTP
|
||||||
|
// (POST /auth/otp/verify)
|
||||||
|
PostAuthOtpVerify(c *fiber.Ctx) error
|
||||||
|
}
|
||||||
|
|
||||||
|
// ServerInterfaceWrapper converts contexts to parameters.
|
||||||
|
type ServerInterfaceWrapper struct {
|
||||||
|
Handler ServerInterface
|
||||||
|
}
|
||||||
|
|
||||||
|
type MiddlewareFunc fiber.Handler
|
||||||
|
|
||||||
|
// PostAuthConsentAccept operation middleware
|
||||||
|
func (siw *ServerInterfaceWrapper) PostAuthConsentAccept(c *fiber.Ctx) error {
|
||||||
|
|
||||||
|
return siw.Handler.PostAuthConsentAccept(c)
|
||||||
|
}
|
||||||
|
|
||||||
|
// PostAuthOtpRequest operation middleware
|
||||||
|
func (siw *ServerInterfaceWrapper) PostAuthOtpRequest(c *fiber.Ctx) error {
|
||||||
|
|
||||||
|
return siw.Handler.PostAuthOtpRequest(c)
|
||||||
|
}
|
||||||
|
|
||||||
|
// PostAuthOtpVerify operation middleware
|
||||||
|
func (siw *ServerInterfaceWrapper) PostAuthOtpVerify(c *fiber.Ctx) error {
|
||||||
|
|
||||||
|
return siw.Handler.PostAuthOtpVerify(c)
|
||||||
|
}
|
||||||
|
|
||||||
|
// FiberServerOptions provides options for the Fiber server.
|
||||||
|
type FiberServerOptions struct {
|
||||||
|
BaseURL string
|
||||||
|
Middlewares []MiddlewareFunc
|
||||||
|
}
|
||||||
|
|
||||||
|
// RegisterHandlers creates http.Handler with routing matching OpenAPI spec.
|
||||||
|
func RegisterHandlers(router fiber.Router, si ServerInterface) {
|
||||||
|
RegisterHandlersWithOptions(router, si, FiberServerOptions{})
|
||||||
|
}
|
||||||
|
|
||||||
|
// RegisterHandlersWithOptions creates http.Handler with additional options
|
||||||
|
func RegisterHandlersWithOptions(router fiber.Router, si ServerInterface, options FiberServerOptions) {
|
||||||
|
wrapper := ServerInterfaceWrapper{
|
||||||
|
Handler: si,
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, m := range options.Middlewares {
|
||||||
|
router.Use(fiber.Handler(m))
|
||||||
|
}
|
||||||
|
|
||||||
|
router.Post(options.BaseURL+"/auth/consent/accept", wrapper.PostAuthConsentAccept)
|
||||||
|
|
||||||
|
router.Post(options.BaseURL+"/auth/otp/request", wrapper.PostAuthOtpRequest)
|
||||||
|
|
||||||
|
router.Post(options.BaseURL+"/auth/otp/verify", wrapper.PostAuthOtpVerify)
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
type PostAuthConsentAcceptRequestObject struct {
|
||||||
|
Body *PostAuthConsentAcceptJSONRequestBody
|
||||||
|
}
|
||||||
|
|
||||||
|
type PostAuthConsentAcceptResponseObject interface {
|
||||||
|
VisitPostAuthConsentAcceptResponse(ctx *fiber.Ctx) error
|
||||||
|
}
|
||||||
|
|
||||||
|
type PostAuthConsentAccept200JSONResponse AcceptConsentResponse
|
||||||
|
|
||||||
|
func (response PostAuthConsentAccept200JSONResponse) VisitPostAuthConsentAcceptResponse(ctx *fiber.Ctx) error {
|
||||||
|
ctx.Response().Header.Set("Content-Type", "application/json")
|
||||||
|
ctx.Status(200)
|
||||||
|
|
||||||
|
return ctx.JSON(&response)
|
||||||
|
}
|
||||||
|
|
||||||
|
type PostAuthConsentAccept400JSONResponse AcceptConsentResponse
|
||||||
|
|
||||||
|
func (response PostAuthConsentAccept400JSONResponse) VisitPostAuthConsentAcceptResponse(ctx *fiber.Ctx) error {
|
||||||
|
ctx.Response().Header.Set("Content-Type", "application/json")
|
||||||
|
ctx.Status(400)
|
||||||
|
|
||||||
|
return ctx.JSON(&response)
|
||||||
|
}
|
||||||
|
|
||||||
|
type PostAuthOtpRequestRequestObject struct {
|
||||||
|
Body *PostAuthOtpRequestJSONRequestBody
|
||||||
|
}
|
||||||
|
|
||||||
|
type PostAuthOtpRequestResponseObject interface {
|
||||||
|
VisitPostAuthOtpRequestResponse(ctx *fiber.Ctx) error
|
||||||
|
}
|
||||||
|
|
||||||
|
type PostAuthOtpRequest200JSONResponse RequestOTPResponse
|
||||||
|
|
||||||
|
func (response PostAuthOtpRequest200JSONResponse) VisitPostAuthOtpRequestResponse(ctx *fiber.Ctx) error {
|
||||||
|
ctx.Response().Header.Set("Content-Type", "application/json")
|
||||||
|
ctx.Status(200)
|
||||||
|
|
||||||
|
return ctx.JSON(&response)
|
||||||
|
}
|
||||||
|
|
||||||
|
type PostAuthOtpRequest400JSONResponse RequestOTPResponse
|
||||||
|
|
||||||
|
func (response PostAuthOtpRequest400JSONResponse) VisitPostAuthOtpRequestResponse(ctx *fiber.Ctx) error {
|
||||||
|
ctx.Response().Header.Set("Content-Type", "application/json")
|
||||||
|
ctx.Status(400)
|
||||||
|
|
||||||
|
return ctx.JSON(&response)
|
||||||
|
}
|
||||||
|
|
||||||
|
type PostAuthOtpVerifyRequestObject struct {
|
||||||
|
Body *PostAuthOtpVerifyJSONRequestBody
|
||||||
|
}
|
||||||
|
|
||||||
|
type PostAuthOtpVerifyResponseObject interface {
|
||||||
|
VisitPostAuthOtpVerifyResponse(ctx *fiber.Ctx) error
|
||||||
|
}
|
||||||
|
|
||||||
|
type PostAuthOtpVerify200JSONResponse VerifyOTPResponse
|
||||||
|
|
||||||
|
func (response PostAuthOtpVerify200JSONResponse) VisitPostAuthOtpVerifyResponse(ctx *fiber.Ctx) error {
|
||||||
|
ctx.Response().Header.Set("Content-Type", "application/json")
|
||||||
|
ctx.Status(200)
|
||||||
|
|
||||||
|
return ctx.JSON(&response)
|
||||||
|
}
|
||||||
|
|
||||||
|
type PostAuthOtpVerify400JSONResponse VerifyOTPResponse
|
||||||
|
|
||||||
|
func (response PostAuthOtpVerify400JSONResponse) VisitPostAuthOtpVerifyResponse(ctx *fiber.Ctx) error {
|
||||||
|
ctx.Response().Header.Set("Content-Type", "application/json")
|
||||||
|
ctx.Status(400)
|
||||||
|
|
||||||
|
return ctx.JSON(&response)
|
||||||
|
}
|
||||||
|
|
||||||
|
// StrictServerInterface represents all server handlers.
|
||||||
|
type StrictServerInterface interface {
|
||||||
|
// Accept consent
|
||||||
|
// (POST /auth/consent/accept)
|
||||||
|
PostAuthConsentAccept(ctx context.Context, request PostAuthConsentAcceptRequestObject) (PostAuthConsentAcceptResponseObject, error)
|
||||||
|
// Request OTP
|
||||||
|
// (POST /auth/otp/request)
|
||||||
|
PostAuthOtpRequest(ctx context.Context, request PostAuthOtpRequestRequestObject) (PostAuthOtpRequestResponseObject, error)
|
||||||
|
// Verify OTP
|
||||||
|
// (POST /auth/otp/verify)
|
||||||
|
PostAuthOtpVerify(ctx context.Context, request PostAuthOtpVerifyRequestObject) (PostAuthOtpVerifyResponseObject, error)
|
||||||
|
}
|
||||||
|
|
||||||
|
type StrictHandlerFunc func(ctx *fiber.Ctx, args interface{}) (interface{}, error)
|
||||||
|
|
||||||
|
type StrictMiddlewareFunc func(f StrictHandlerFunc, operationID string) StrictHandlerFunc
|
||||||
|
|
||||||
|
func NewStrictHandler(ssi StrictServerInterface, middlewares []StrictMiddlewareFunc) ServerInterface {
|
||||||
|
return &strictHandler{ssi: ssi, middlewares: middlewares}
|
||||||
|
}
|
||||||
|
|
||||||
|
type strictHandler struct {
|
||||||
|
ssi StrictServerInterface
|
||||||
|
middlewares []StrictMiddlewareFunc
|
||||||
|
}
|
||||||
|
|
||||||
|
// PostAuthConsentAccept operation middleware
|
||||||
|
func (sh *strictHandler) PostAuthConsentAccept(ctx *fiber.Ctx) error {
|
||||||
|
var request PostAuthConsentAcceptRequestObject
|
||||||
|
|
||||||
|
var body PostAuthConsentAcceptJSONRequestBody
|
||||||
|
if err := ctx.BodyParser(&body); err != nil {
|
||||||
|
return fiber.NewError(fiber.StatusBadRequest, err.Error())
|
||||||
|
}
|
||||||
|
request.Body = &body
|
||||||
|
|
||||||
|
handler := func(ctx *fiber.Ctx, request interface{}) (interface{}, error) {
|
||||||
|
return sh.ssi.PostAuthConsentAccept(ctx.UserContext(), request.(PostAuthConsentAcceptRequestObject))
|
||||||
|
}
|
||||||
|
for _, middleware := range sh.middlewares {
|
||||||
|
handler = middleware(handler, "PostAuthConsentAccept")
|
||||||
|
}
|
||||||
|
|
||||||
|
response, err := handler(ctx, request)
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
return fiber.NewError(fiber.StatusBadRequest, err.Error())
|
||||||
|
} else if validResponse, ok := response.(PostAuthConsentAcceptResponseObject); ok {
|
||||||
|
if err := validResponse.VisitPostAuthConsentAcceptResponse(ctx); err != nil {
|
||||||
|
return fiber.NewError(fiber.StatusBadRequest, err.Error())
|
||||||
|
}
|
||||||
|
} else if response != nil {
|
||||||
|
return fmt.Errorf("unexpected response type: %T", response)
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// PostAuthOtpRequest operation middleware
|
||||||
|
func (sh *strictHandler) PostAuthOtpRequest(ctx *fiber.Ctx) error {
|
||||||
|
var request PostAuthOtpRequestRequestObject
|
||||||
|
|
||||||
|
var body PostAuthOtpRequestJSONRequestBody
|
||||||
|
if err := ctx.BodyParser(&body); err != nil {
|
||||||
|
return fiber.NewError(fiber.StatusBadRequest, err.Error())
|
||||||
|
}
|
||||||
|
request.Body = &body
|
||||||
|
|
||||||
|
handler := func(ctx *fiber.Ctx, request interface{}) (interface{}, error) {
|
||||||
|
return sh.ssi.PostAuthOtpRequest(ctx.UserContext(), request.(PostAuthOtpRequestRequestObject))
|
||||||
|
}
|
||||||
|
for _, middleware := range sh.middlewares {
|
||||||
|
handler = middleware(handler, "PostAuthOtpRequest")
|
||||||
|
}
|
||||||
|
|
||||||
|
response, err := handler(ctx, request)
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
return fiber.NewError(fiber.StatusBadRequest, err.Error())
|
||||||
|
} else if validResponse, ok := response.(PostAuthOtpRequestResponseObject); ok {
|
||||||
|
if err := validResponse.VisitPostAuthOtpRequestResponse(ctx); err != nil {
|
||||||
|
return fiber.NewError(fiber.StatusBadRequest, err.Error())
|
||||||
|
}
|
||||||
|
} else if response != nil {
|
||||||
|
return fmt.Errorf("unexpected response type: %T", response)
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// PostAuthOtpVerify operation middleware
|
||||||
|
func (sh *strictHandler) PostAuthOtpVerify(ctx *fiber.Ctx) error {
|
||||||
|
var request PostAuthOtpVerifyRequestObject
|
||||||
|
|
||||||
|
var body PostAuthOtpVerifyJSONRequestBody
|
||||||
|
if err := ctx.BodyParser(&body); err != nil {
|
||||||
|
return fiber.NewError(fiber.StatusBadRequest, err.Error())
|
||||||
|
}
|
||||||
|
request.Body = &body
|
||||||
|
|
||||||
|
handler := func(ctx *fiber.Ctx, request interface{}) (interface{}, error) {
|
||||||
|
return sh.ssi.PostAuthOtpVerify(ctx.UserContext(), request.(PostAuthOtpVerifyRequestObject))
|
||||||
|
}
|
||||||
|
for _, middleware := range sh.middlewares {
|
||||||
|
handler = middleware(handler, "PostAuthOtpVerify")
|
||||||
|
}
|
||||||
|
|
||||||
|
response, err := handler(ctx, request)
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
return fiber.NewError(fiber.StatusBadRequest, err.Error())
|
||||||
|
} else if validResponse, ok := response.(PostAuthOtpVerifyResponseObject); ok {
|
||||||
|
if err := validResponse.VisitPostAuthOtpVerifyResponse(ctx); err != nil {
|
||||||
|
return fiber.NewError(fiber.StatusBadRequest, err.Error())
|
||||||
|
}
|
||||||
|
} else if response != nil {
|
||||||
|
return fmt.Errorf("unexpected response type: %T", response)
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
3
internal/api/auth/handler/generate.go
Normal file
3
internal/api/auth/handler/generate.go
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
package handler
|
||||||
|
|
||||||
|
//go:generate go tool oapi-codegen -config ../../../../api/auth/cfg.yaml ../../../../api/auth/api.yaml
|
||||||
69
internal/api/auth/handler/impl.go
Normal file
69
internal/api/auth/handler/impl.go
Normal file
@ -0,0 +1,69 @@
|
|||||||
|
package handler
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
|
||||||
|
"git.logidex.ru/fakz9/logidex-id/internal/api/auth/service"
|
||||||
|
"github.com/gofiber/fiber/v2"
|
||||||
|
)
|
||||||
|
|
||||||
|
type AuthHandler struct {
|
||||||
|
service service.AuthService
|
||||||
|
}
|
||||||
|
|
||||||
|
func (h AuthHandler) PostAuthOtpRequest(ctx context.Context, request PostAuthOtpRequestRequestObject) (PostAuthOtpRequestResponseObject, error) {
|
||||||
|
err := h.service.OtpRequest(ctx, request.Body.PhoneNumber)
|
||||||
|
if err != nil {
|
||||||
|
return PostAuthOtpRequest400JSONResponse{
|
||||||
|
Message: err.Error(),
|
||||||
|
Ok: false,
|
||||||
|
}, nil
|
||||||
|
}
|
||||||
|
return PostAuthOtpRequest200JSONResponse{
|
||||||
|
Message: "OTP request successful",
|
||||||
|
Ok: true,
|
||||||
|
}, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (h AuthHandler) PostAuthOtpVerify(ctx context.Context, request PostAuthOtpVerifyRequestObject) (PostAuthOtpVerifyResponseObject, error) {
|
||||||
|
redirectUrl, err := h.service.OtpVerify(ctx, request.Body.PhoneNumber, request.Body.Otp, request.Body.LoginChallenge)
|
||||||
|
if err != nil {
|
||||||
|
return PostAuthOtpVerify400JSONResponse{
|
||||||
|
Message: err.Error(),
|
||||||
|
Ok: false,
|
||||||
|
RedirectUrl: "",
|
||||||
|
}, nil
|
||||||
|
}
|
||||||
|
return PostAuthOtpVerify200JSONResponse{
|
||||||
|
Message: "OTP verification successful",
|
||||||
|
Ok: true,
|
||||||
|
RedirectUrl: redirectUrl,
|
||||||
|
}, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (h AuthHandler) PostAuthConsentAccept(ctx context.Context, request PostAuthConsentAcceptRequestObject) (PostAuthConsentAcceptResponseObject, error) {
|
||||||
|
redirectUrl, err := h.service.AcceptConsent(ctx, request.Body.PhoneNumber, request.Body.ConsentChallenge)
|
||||||
|
if err != nil {
|
||||||
|
return PostAuthConsentAccept400JSONResponse{
|
||||||
|
Message: err.Error(),
|
||||||
|
Ok: false,
|
||||||
|
RedirectUrl: "",
|
||||||
|
}, nil
|
||||||
|
}
|
||||||
|
return PostAuthConsentAccept200JSONResponse{
|
||||||
|
Message: "Consent accepted successfully",
|
||||||
|
Ok: true,
|
||||||
|
RedirectUrl: redirectUrl,
|
||||||
|
}, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
var _ StrictServerInterface = (*AuthHandler)(nil)
|
||||||
|
|
||||||
|
func NewAuthHandler(service service.AuthService) *AuthHandler {
|
||||||
|
return &AuthHandler{service: service}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (h AuthHandler) RegisterRoutes(router fiber.Router) {
|
||||||
|
server := NewStrictHandler(h, nil)
|
||||||
|
RegisterHandlers(router, server)
|
||||||
|
}
|
||||||
293
internal/api/auth/handler/impl_test.go
Normal file
293
internal/api/auth/handler/impl_test.go
Normal file
@ -0,0 +1,293 @@
|
|||||||
|
package handler
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"testing"
|
||||||
|
|
||||||
|
"github.com/stretchr/testify/assert"
|
||||||
|
"github.com/stretchr/testify/mock"
|
||||||
|
)
|
||||||
|
|
||||||
|
// MockAuthService implements service.AuthService
|
||||||
|
type MockAuthService struct {
|
||||||
|
mock.Mock
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *MockAuthService) OtpRequest(ctx context.Context, phoneNumber string) error {
|
||||||
|
args := m.Called(ctx, phoneNumber)
|
||||||
|
return args.Error(0)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *MockAuthService) OtpVerify(ctx context.Context, phoneNumber, code string, loginChallenge string) (string, error) {
|
||||||
|
args := m.Called(ctx, phoneNumber, code, loginChallenge)
|
||||||
|
return args.String(0), args.Error(1)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *MockAuthService) AcceptConsent(ctx context.Context, phoneNumber string, challenge string) (string, error) {
|
||||||
|
args := m.Called(ctx, phoneNumber, challenge)
|
||||||
|
return args.String(0), args.Error(1)
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestNewAuthHandler(t *testing.T) {
|
||||||
|
mockService := &MockAuthService{}
|
||||||
|
handler := NewAuthHandler(mockService)
|
||||||
|
|
||||||
|
assert.NotNil(t, handler)
|
||||||
|
assert.Equal(t, mockService, handler.service)
|
||||||
|
assert.Implements(t, (*StrictServerInterface)(nil), handler)
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestAuthHandler_PostAuthOtpRequest(t *testing.T) {
|
||||||
|
tests := []struct {
|
||||||
|
name string
|
||||||
|
phoneNumber string
|
||||||
|
setupMock func(*MockAuthService)
|
||||||
|
expectedStatus int
|
||||||
|
expectedOk bool
|
||||||
|
expectedMsg string
|
||||||
|
}{
|
||||||
|
{
|
||||||
|
name: "successful otp request",
|
||||||
|
phoneNumber: "+79161234567",
|
||||||
|
setupMock: func(m *MockAuthService) {
|
||||||
|
m.On("OtpRequest", mock.Anything, "+79161234567").Return(nil).Once()
|
||||||
|
},
|
||||||
|
expectedStatus: 200,
|
||||||
|
expectedOk: true,
|
||||||
|
expectedMsg: "OTP request successful",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "service error",
|
||||||
|
phoneNumber: "invalid",
|
||||||
|
setupMock: func(m *MockAuthService) {
|
||||||
|
m.On("OtpRequest", mock.Anything, "invalid").Return(assert.AnError).Once()
|
||||||
|
},
|
||||||
|
expectedStatus: 400,
|
||||||
|
expectedOk: false,
|
||||||
|
expectedMsg: assert.AnError.Error(),
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, tt := range tests {
|
||||||
|
t.Run(tt.name, func(t *testing.T) {
|
||||||
|
mockService := &MockAuthService{}
|
||||||
|
handler := &AuthHandler{service: mockService}
|
||||||
|
ctx := context.Background()
|
||||||
|
|
||||||
|
tt.setupMock(mockService)
|
||||||
|
|
||||||
|
request := PostAuthOtpRequestRequestObject{
|
||||||
|
Body: &PostAuthOtpRequestJSONRequestBody{
|
||||||
|
PhoneNumber: tt.phoneNumber,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
result, err := handler.PostAuthOtpRequest(ctx, request)
|
||||||
|
|
||||||
|
assert.NoError(t, err) // Handler should not return errors, only response objects
|
||||||
|
|
||||||
|
if tt.expectedStatus == 200 {
|
||||||
|
response, ok := result.(PostAuthOtpRequest200JSONResponse)
|
||||||
|
assert.True(t, ok)
|
||||||
|
assert.Equal(t, tt.expectedOk, response.Ok)
|
||||||
|
assert.Equal(t, tt.expectedMsg, response.Message)
|
||||||
|
} else {
|
||||||
|
response, ok := result.(PostAuthOtpRequest400JSONResponse)
|
||||||
|
assert.True(t, ok)
|
||||||
|
assert.Equal(t, tt.expectedOk, response.Ok)
|
||||||
|
assert.Equal(t, tt.expectedMsg, response.Message)
|
||||||
|
}
|
||||||
|
|
||||||
|
mockService.AssertExpectations(t)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestAuthHandler_PostAuthOtpVerify(t *testing.T) {
|
||||||
|
tests := []struct {
|
||||||
|
name string
|
||||||
|
phoneNumber string
|
||||||
|
otp string
|
||||||
|
loginChallenge string
|
||||||
|
setupMock func(*MockAuthService)
|
||||||
|
expectedStatus int
|
||||||
|
expectedOk bool
|
||||||
|
expectedMsg string
|
||||||
|
expectedRedirect string
|
||||||
|
}{
|
||||||
|
{
|
||||||
|
name: "successful otp verification",
|
||||||
|
phoneNumber: "+79161234567",
|
||||||
|
otp: "123456",
|
||||||
|
loginChallenge: "challenge123",
|
||||||
|
setupMock: func(m *MockAuthService) {
|
||||||
|
m.On("OtpVerify", mock.Anything, "+79161234567", "123456", "challenge123").
|
||||||
|
Return("https://example.com/callback", nil).Once()
|
||||||
|
},
|
||||||
|
expectedStatus: 200,
|
||||||
|
expectedOk: true,
|
||||||
|
expectedMsg: "OTP verification successful",
|
||||||
|
expectedRedirect: "https://example.com/callback",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "service error",
|
||||||
|
phoneNumber: "+79161234567",
|
||||||
|
otp: "wrong",
|
||||||
|
loginChallenge: "challenge123",
|
||||||
|
setupMock: func(m *MockAuthService) {
|
||||||
|
m.On("OtpVerify", mock.Anything, "+79161234567", "wrong", "challenge123").
|
||||||
|
Return("", assert.AnError).Once()
|
||||||
|
},
|
||||||
|
expectedStatus: 400,
|
||||||
|
expectedOk: false,
|
||||||
|
expectedMsg: assert.AnError.Error(),
|
||||||
|
expectedRedirect: "",
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, tt := range tests {
|
||||||
|
t.Run(tt.name, func(t *testing.T) {
|
||||||
|
mockService := &MockAuthService{}
|
||||||
|
handler := &AuthHandler{service: mockService}
|
||||||
|
ctx := context.Background()
|
||||||
|
|
||||||
|
tt.setupMock(mockService)
|
||||||
|
|
||||||
|
request := PostAuthOtpVerifyRequestObject{
|
||||||
|
Body: &PostAuthOtpVerifyJSONRequestBody{
|
||||||
|
PhoneNumber: tt.phoneNumber,
|
||||||
|
Otp: tt.otp,
|
||||||
|
LoginChallenge: tt.loginChallenge,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
result, err := handler.PostAuthOtpVerify(ctx, request)
|
||||||
|
|
||||||
|
assert.NoError(t, err)
|
||||||
|
|
||||||
|
if tt.expectedStatus == 200 {
|
||||||
|
response, ok := result.(PostAuthOtpVerify200JSONResponse)
|
||||||
|
assert.True(t, ok)
|
||||||
|
assert.Equal(t, tt.expectedOk, response.Ok)
|
||||||
|
assert.Equal(t, tt.expectedMsg, response.Message)
|
||||||
|
assert.Equal(t, tt.expectedRedirect, response.RedirectUrl)
|
||||||
|
} else {
|
||||||
|
response, ok := result.(PostAuthOtpVerify400JSONResponse)
|
||||||
|
assert.True(t, ok)
|
||||||
|
assert.Equal(t, tt.expectedOk, response.Ok)
|
||||||
|
assert.Equal(t, tt.expectedMsg, response.Message)
|
||||||
|
assert.Equal(t, tt.expectedRedirect, response.RedirectUrl)
|
||||||
|
}
|
||||||
|
|
||||||
|
mockService.AssertExpectations(t)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestAuthHandler_PostAuthConsentAccept(t *testing.T) {
|
||||||
|
tests := []struct {
|
||||||
|
name string
|
||||||
|
phoneNumber string
|
||||||
|
consentChallenge string
|
||||||
|
setupMock func(*MockAuthService)
|
||||||
|
expectedStatus int
|
||||||
|
expectedOk bool
|
||||||
|
expectedMsg string
|
||||||
|
expectedRedirect string
|
||||||
|
}{
|
||||||
|
{
|
||||||
|
name: "successful consent accept",
|
||||||
|
phoneNumber: "+79161234567",
|
||||||
|
consentChallenge: "consent123",
|
||||||
|
setupMock: func(m *MockAuthService) {
|
||||||
|
m.On("AcceptConsent", mock.Anything, "+79161234567", "consent123").
|
||||||
|
Return("https://example.com/callback", nil).Once()
|
||||||
|
},
|
||||||
|
expectedStatus: 200,
|
||||||
|
expectedOk: true,
|
||||||
|
expectedMsg: "Consent accepted successfully",
|
||||||
|
expectedRedirect: "https://example.com/callback",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "service error",
|
||||||
|
phoneNumber: "+79161234567",
|
||||||
|
consentChallenge: "invalid",
|
||||||
|
setupMock: func(m *MockAuthService) {
|
||||||
|
m.On("AcceptConsent", mock.Anything, "+79161234567", "invalid").
|
||||||
|
Return("", assert.AnError).Once()
|
||||||
|
},
|
||||||
|
expectedStatus: 400,
|
||||||
|
expectedOk: false,
|
||||||
|
expectedMsg: assert.AnError.Error(),
|
||||||
|
expectedRedirect: "",
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, tt := range tests {
|
||||||
|
t.Run(tt.name, func(t *testing.T) {
|
||||||
|
mockService := &MockAuthService{}
|
||||||
|
handler := &AuthHandler{service: mockService}
|
||||||
|
ctx := context.Background()
|
||||||
|
|
||||||
|
tt.setupMock(mockService)
|
||||||
|
|
||||||
|
request := PostAuthConsentAcceptRequestObject{
|
||||||
|
Body: &PostAuthConsentAcceptJSONRequestBody{
|
||||||
|
PhoneNumber: tt.phoneNumber,
|
||||||
|
ConsentChallenge: tt.consentChallenge,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
result, err := handler.PostAuthConsentAccept(ctx, request)
|
||||||
|
|
||||||
|
assert.NoError(t, err)
|
||||||
|
|
||||||
|
if tt.expectedStatus == 200 {
|
||||||
|
response, ok := result.(PostAuthConsentAccept200JSONResponse)
|
||||||
|
assert.True(t, ok)
|
||||||
|
assert.Equal(t, tt.expectedOk, response.Ok)
|
||||||
|
assert.Equal(t, tt.expectedMsg, response.Message)
|
||||||
|
assert.Equal(t, tt.expectedRedirect, response.RedirectUrl)
|
||||||
|
} else {
|
||||||
|
response, ok := result.(PostAuthConsentAccept400JSONResponse)
|
||||||
|
assert.True(t, ok)
|
||||||
|
assert.Equal(t, tt.expectedOk, response.Ok)
|
||||||
|
assert.Equal(t, tt.expectedMsg, response.Message)
|
||||||
|
assert.Equal(t, tt.expectedRedirect, response.RedirectUrl)
|
||||||
|
}
|
||||||
|
|
||||||
|
mockService.AssertExpectations(t)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestAuthHandler_EdgeCases(t *testing.T) {
|
||||||
|
t.Run("nil request body should not panic", func(t *testing.T) {
|
||||||
|
mockService := &MockAuthService{}
|
||||||
|
handler := &AuthHandler{service: mockService}
|
||||||
|
ctx := context.Background()
|
||||||
|
|
||||||
|
// Test with nil body - this should be handled by the generated code
|
||||||
|
// but we test that our handler doesn't panic
|
||||||
|
defer func() {
|
||||||
|
if r := recover(); r != nil {
|
||||||
|
t.Errorf("Handler panicked with nil body: %v", r)
|
||||||
|
}
|
||||||
|
}()
|
||||||
|
|
||||||
|
request := PostAuthOtpRequestRequestObject{
|
||||||
|
Body: &PostAuthOtpRequestJSONRequestBody{
|
||||||
|
PhoneNumber: "",
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
mockService.On("OtpRequest", mock.Anything, "").Return(assert.AnError).Once()
|
||||||
|
|
||||||
|
result, err := handler.PostAuthOtpRequest(ctx, request)
|
||||||
|
|
||||||
|
assert.NoError(t, err)
|
||||||
|
assert.NotNil(t, result)
|
||||||
|
|
||||||
|
mockService.AssertExpectations(t)
|
||||||
|
})
|
||||||
|
}
|
||||||
45
internal/api/auth/repo/auth_repo.go
Normal file
45
internal/api/auth/repo/auth_repo.go
Normal file
@ -0,0 +1,45 @@
|
|||||||
|
package repo
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"time"
|
||||||
|
|
||||||
|
"git.logidex.ru/fakz9/logidex-id/internal/api/auth/domain"
|
||||||
|
"github.com/redis/rueidis"
|
||||||
|
)
|
||||||
|
|
||||||
|
type authRepo struct {
|
||||||
|
redisClient rueidis.Client
|
||||||
|
}
|
||||||
|
|
||||||
|
func (a authRepo) GetOtpRequest(ctx context.Context, uuid string) (*string, error) {
|
||||||
|
redisClient := a.redisClient
|
||||||
|
|
||||||
|
resp, err := redisClient.Do(ctx, redisClient.B().Get().Key("otp:"+uuid).Build()).ToString()
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
if resp == "" {
|
||||||
|
// create error
|
||||||
|
return nil, &domain.ErrOtpNotFound{Uuid: uuid}
|
||||||
|
}
|
||||||
|
|
||||||
|
return &resp, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (a authRepo) SaveOtpRequest(ctx context.Context, uuid string, code string) error {
|
||||||
|
redisClient := a.redisClient
|
||||||
|
|
||||||
|
err := redisClient.Do(ctx, redisClient.B().Set().Key("otp:"+uuid).Value(code).Ex(120*time.Second).Build()).Error()
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewAuthRepo(redisClient rueidis.Client) domain.AuthRepository {
|
||||||
|
return &authRepo{redisClient: redisClient}
|
||||||
|
}
|
||||||
34
internal/api/auth/repo/auth_repo_test.go
Normal file
34
internal/api/auth/repo/auth_repo_test.go
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
package repo
|
||||||
|
|
||||||
|
import (
|
||||||
|
"testing"
|
||||||
|
|
||||||
|
"git.logidex.ru/fakz9/logidex-id/internal/api/auth/domain"
|
||||||
|
"github.com/stretchr/testify/assert"
|
||||||
|
)
|
||||||
|
|
||||||
|
func TestNewAuthRepo(t *testing.T) {
|
||||||
|
// Test with nil client for interface testing
|
||||||
|
// In real tests, you would use a mock or test container
|
||||||
|
repo := NewAuthRepo(nil)
|
||||||
|
|
||||||
|
assert.NotNil(t, repo)
|
||||||
|
assert.Implements(t, (*domain.AuthRepository)(nil), repo)
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestAuthRepo_Interface(t *testing.T) {
|
||||||
|
// Test that our auth repo implements the domain interface
|
||||||
|
var _ domain.AuthRepository = (*authRepo)(nil)
|
||||||
|
|
||||||
|
// Test constructor returns correct interface
|
||||||
|
repo := NewAuthRepo(nil)
|
||||||
|
|
||||||
|
// Verify interface compliance
|
||||||
|
assert.Implements(t, (*domain.AuthRepository)(nil), repo)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Note: Actual Redis operations testing requires either:
|
||||||
|
// 1. Test containers with real Redis
|
||||||
|
// 2. A simpler interface wrapper around Redis
|
||||||
|
// 3. A Redis mock library specifically designed for rueidis
|
||||||
|
// For now, we focus on interface compliance and constructor behavior
|
||||||
194
internal/api/auth/service/auth_service.go
Normal file
194
internal/api/auth/service/auth_service.go
Normal file
@ -0,0 +1,194 @@
|
|||||||
|
package service
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"net/http"
|
||||||
|
"strconv"
|
||||||
|
|
||||||
|
"git.logidex.ru/fakz9/logidex-id/internal/api/auth/domain"
|
||||||
|
userDomain "git.logidex.ru/fakz9/logidex-id/internal/api/user/domain"
|
||||||
|
userService "git.logidex.ru/fakz9/logidex-id/internal/api/user/service"
|
||||||
|
"git.logidex.ru/fakz9/logidex-id/internal/phoneutil"
|
||||||
|
hydraApi "github.com/ory/hydra-client-go"
|
||||||
|
)
|
||||||
|
|
||||||
|
type AuthService interface {
|
||||||
|
OtpRequest(ctx context.Context, phoneNumber string) error
|
||||||
|
OtpVerify(ctx context.Context, phoneNumber, code string, loggingChallenge string) (string, error)
|
||||||
|
AcceptConsent(ctx context.Context, phoneNumber string, challenge string) (string, error)
|
||||||
|
}
|
||||||
|
|
||||||
|
type authService struct {
|
||||||
|
repo domain.AuthRepository
|
||||||
|
userService userService.UserService
|
||||||
|
hydraClient *hydraApi.APIClient
|
||||||
|
}
|
||||||
|
|
||||||
|
func (a authService) validateAndFormatPhoneNumber(phoneNumber string) (string, error) {
|
||||||
|
formattedPhone, err := phoneutil.ParseAndFormatPhoneNumber(phoneNumber)
|
||||||
|
if err != nil {
|
||||||
|
return "", domain.ErrInvalidPhoneNumber{
|
||||||
|
PhoneNumber: phoneNumber,
|
||||||
|
Err: err,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return formattedPhone, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (a authService) getUserByPhoneNumber(ctx context.Context, phoneNumber string) (*userDomain.User, error) {
|
||||||
|
user, err := a.userService.GetUserByPhoneNumber(ctx, phoneNumber)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
if user == nil {
|
||||||
|
return nil, domain.ErrUserNotFound{PhoneNumber: phoneNumber}
|
||||||
|
}
|
||||||
|
return user, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (a authService) getOrCreateUser(ctx context.Context, phoneNumber string) (*userDomain.User, error) {
|
||||||
|
user, err := a.userService.GetUserByPhoneNumber(ctx, phoneNumber)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
if user == nil {
|
||||||
|
user, err = a.userService.CreateUser(ctx, phoneNumber)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return user, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (a authService) validateHydraResponse(rawRsp *http.Response, userUuid string) error {
|
||||||
|
if rawRsp.StatusCode != 200 {
|
||||||
|
return domain.ErrInvalidHydraAccept{
|
||||||
|
Message: "Hydra response status: " + strconv.Itoa(rawRsp.StatusCode),
|
||||||
|
Uuid: userUuid,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (a authService) extractRedirectUrl(rsp interface{ GetRedirectToOk() (*string, bool) }, userUuid string) (string, error) {
|
||||||
|
redirectTo, ok := rsp.GetRedirectToOk()
|
||||||
|
if !ok || redirectTo == nil {
|
||||||
|
return "", domain.ErrInvalidHydraAccept{
|
||||||
|
Message: "Hydra redirectTo is nil",
|
||||||
|
Uuid: userUuid,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return *redirectTo, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (a authService) AcceptConsent(ctx context.Context, phoneNumber string, challenge string) (string, error) {
|
||||||
|
phoneNumber, err := a.validateAndFormatPhoneNumber(phoneNumber)
|
||||||
|
if err != nil {
|
||||||
|
return "", err
|
||||||
|
}
|
||||||
|
user, err := a.getUserByPhoneNumber(ctx, phoneNumber)
|
||||||
|
if err != nil {
|
||||||
|
return "", err
|
||||||
|
}
|
||||||
|
request := hydraApi.AcceptConsentRequest{}
|
||||||
|
request.SetGrantScope([]string{"openid"})
|
||||||
|
request.SetRemember(true)
|
||||||
|
request.SetRememberFor(3600)
|
||||||
|
|
||||||
|
rsp, rawRsp, err := a.hydraClient.AdminApi.
|
||||||
|
AcceptConsentRequest(ctx).
|
||||||
|
ConsentChallenge(challenge).
|
||||||
|
AcceptConsentRequest(request).
|
||||||
|
Execute()
|
||||||
|
if err != nil {
|
||||||
|
return "", err
|
||||||
|
}
|
||||||
|
if err = a.validateHydraResponse(rawRsp, user.Uuid); err != nil {
|
||||||
|
return "", err
|
||||||
|
}
|
||||||
|
redirectUrl, err := a.extractRedirectUrl(rsp, user.Uuid)
|
||||||
|
if err != nil {
|
||||||
|
return "", err
|
||||||
|
}
|
||||||
|
// TODO: Verify user in the database
|
||||||
|
_, err = a.userService.VerifyUser(ctx, user.Uuid)
|
||||||
|
if err != nil {
|
||||||
|
return "", err
|
||||||
|
}
|
||||||
|
return redirectUrl, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (a authService) OtpRequest(ctx context.Context, phoneNumber string) error {
|
||||||
|
phoneNumber, err := a.validateAndFormatPhoneNumber(phoneNumber)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
user, err := a.getOrCreateUser(ctx, phoneNumber)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
code := "123456"
|
||||||
|
err = a.repo.SaveOtpRequest(ctx, user.Uuid, code)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
// TODO implement sending OTP code via SMS
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (a authService) OtpVerify(ctx context.Context, phoneNumber string, code string, loggingChallenge string) (string, error) {
|
||||||
|
phoneNumber, err := a.validateAndFormatPhoneNumber(phoneNumber)
|
||||||
|
if err != nil {
|
||||||
|
return "", err
|
||||||
|
}
|
||||||
|
|
||||||
|
user, err := a.getUserByPhoneNumber(ctx, phoneNumber)
|
||||||
|
if err != nil {
|
||||||
|
return "", err
|
||||||
|
}
|
||||||
|
|
||||||
|
otp, err := a.repo.GetOtpRequest(ctx, user.Uuid)
|
||||||
|
if err != nil {
|
||||||
|
return "", err
|
||||||
|
}
|
||||||
|
if otp == nil {
|
||||||
|
return "", domain.ErrOtpNotFound{Uuid: user.Uuid}
|
||||||
|
}
|
||||||
|
if *otp != code {
|
||||||
|
return "", domain.ErrOtpInvalid{Uuid: user.Uuid, Code: code}
|
||||||
|
}
|
||||||
|
|
||||||
|
request := hydraApi.AcceptLoginRequest{}
|
||||||
|
request.SetSubject(user.Uuid)
|
||||||
|
request.SetRemember(true)
|
||||||
|
request.SetRememberFor(3600) // 1 hour
|
||||||
|
|
||||||
|
rsp, rawRsp, err := a.hydraClient.AdminApi.
|
||||||
|
AcceptLoginRequest(ctx).
|
||||||
|
LoginChallenge(loggingChallenge).
|
||||||
|
AcceptLoginRequest(request).
|
||||||
|
Execute()
|
||||||
|
if err != nil {
|
||||||
|
return "", err
|
||||||
|
}
|
||||||
|
if err = a.validateHydraResponse(rawRsp, user.Uuid); err != nil {
|
||||||
|
return "", err
|
||||||
|
}
|
||||||
|
|
||||||
|
redirectUrl, err := a.extractRedirectUrl(rsp, user.Uuid)
|
||||||
|
if err != nil {
|
||||||
|
return "", err
|
||||||
|
}
|
||||||
|
|
||||||
|
return redirectUrl, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewAuthService(repo domain.AuthRepository, userService userService.UserService, hydraClient *hydraApi.APIClient) AuthService {
|
||||||
|
return &authService{
|
||||||
|
repo: repo,
|
||||||
|
userService: userService,
|
||||||
|
hydraClient: hydraClient,
|
||||||
|
}
|
||||||
|
}
|
||||||
429
internal/api/auth/service/auth_service_test.go
Normal file
429
internal/api/auth/service/auth_service_test.go
Normal file
@ -0,0 +1,429 @@
|
|||||||
|
package service
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"net/http"
|
||||||
|
"testing"
|
||||||
|
|
||||||
|
"git.logidex.ru/fakz9/logidex-id/internal/api/auth/domain"
|
||||||
|
userDomain "git.logidex.ru/fakz9/logidex-id/internal/api/user/domain"
|
||||||
|
hydraApi "github.com/ory/hydra-client-go"
|
||||||
|
"github.com/stretchr/testify/assert"
|
||||||
|
"github.com/stretchr/testify/mock"
|
||||||
|
)
|
||||||
|
|
||||||
|
// MockAuthRepository implements domain.AuthRepository
|
||||||
|
type MockAuthRepository struct {
|
||||||
|
mock.Mock
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *MockAuthRepository) SaveOtpRequest(ctx context.Context, uuid string, code string) error {
|
||||||
|
args := m.Called(ctx, uuid, code)
|
||||||
|
return args.Error(0)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *MockAuthRepository) GetOtpRequest(ctx context.Context, uuid string) (*string, error) {
|
||||||
|
args := m.Called(ctx, uuid)
|
||||||
|
if args.Get(0) == nil {
|
||||||
|
return nil, args.Error(1)
|
||||||
|
}
|
||||||
|
return args.Get(0).(*string), args.Error(1)
|
||||||
|
}
|
||||||
|
|
||||||
|
// MockUserService implements userService.UserService
|
||||||
|
type MockUserService struct {
|
||||||
|
mock.Mock
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *MockUserService) GetUserByPhoneNumber(ctx context.Context, phoneNumber string) (*userDomain.User, error) {
|
||||||
|
args := m.Called(ctx, phoneNumber)
|
||||||
|
if args.Get(0) == nil {
|
||||||
|
return nil, args.Error(1)
|
||||||
|
}
|
||||||
|
return args.Get(0).(*userDomain.User), args.Error(1)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *MockUserService) GetUserByUuid(ctx context.Context, uuid string) (*userDomain.User, error) {
|
||||||
|
args := m.Called(ctx, uuid)
|
||||||
|
if args.Get(0) == nil {
|
||||||
|
return nil, args.Error(1)
|
||||||
|
}
|
||||||
|
return args.Get(0).(*userDomain.User), args.Error(1)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *MockUserService) CreateUser(ctx context.Context, phoneNumber string) (*userDomain.User, error) {
|
||||||
|
args := m.Called(ctx, phoneNumber)
|
||||||
|
if args.Get(0) == nil {
|
||||||
|
return nil, args.Error(1)
|
||||||
|
}
|
||||||
|
return args.Get(0).(*userDomain.User), args.Error(1)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *MockUserService) VerifyUser(ctx context.Context, uuid string) (*userDomain.User, error) {
|
||||||
|
args := m.Called(ctx, uuid)
|
||||||
|
if args.Get(0) == nil {
|
||||||
|
return nil, args.Error(1)
|
||||||
|
}
|
||||||
|
return args.Get(0).(*userDomain.User), args.Error(1)
|
||||||
|
}
|
||||||
|
|
||||||
|
// MockHydraResponse implements hydra response interface
|
||||||
|
type MockHydraResponse struct {
|
||||||
|
redirectTo *string
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *MockHydraResponse) GetRedirectToOk() (*string, bool) {
|
||||||
|
if m.redirectTo == nil {
|
||||||
|
return nil, false
|
||||||
|
}
|
||||||
|
return m.redirectTo, true
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestNewAuthService(t *testing.T) {
|
||||||
|
mockRepo := &MockAuthRepository{}
|
||||||
|
mockUserService := &MockUserService{}
|
||||||
|
mockHydraClient := &hydraApi.APIClient{}
|
||||||
|
|
||||||
|
service := NewAuthService(mockRepo, mockUserService, mockHydraClient)
|
||||||
|
|
||||||
|
assert.NotNil(t, service)
|
||||||
|
assert.Implements(t, (*AuthService)(nil), service)
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestAuthService_getUserByPhoneNumber(t *testing.T) {
|
||||||
|
mockUserService := &MockUserService{}
|
||||||
|
service := &authService{userService: mockUserService}
|
||||||
|
ctx := context.Background()
|
||||||
|
phoneNumber := "+79161234567"
|
||||||
|
|
||||||
|
tests := []struct {
|
||||||
|
name string
|
||||||
|
setupMock func()
|
||||||
|
expectedUser *userDomain.User
|
||||||
|
wantErr bool
|
||||||
|
errType interface{}
|
||||||
|
}{
|
||||||
|
{
|
||||||
|
name: "user found",
|
||||||
|
setupMock: func() {
|
||||||
|
user := &userDomain.User{
|
||||||
|
Uuid: "test-uuid",
|
||||||
|
PhoneNumber: phoneNumber,
|
||||||
|
}
|
||||||
|
mockUserService.On("GetUserByPhoneNumber", ctx, phoneNumber).Return(user, nil).Once()
|
||||||
|
},
|
||||||
|
expectedUser: &userDomain.User{
|
||||||
|
Uuid: "test-uuid",
|
||||||
|
PhoneNumber: phoneNumber,
|
||||||
|
},
|
||||||
|
wantErr: false,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "user not found",
|
||||||
|
setupMock: func() {
|
||||||
|
mockUserService.On("GetUserByPhoneNumber", ctx, phoneNumber).Return(nil, nil).Once()
|
||||||
|
},
|
||||||
|
wantErr: true,
|
||||||
|
errType: domain.ErrUserNotFound{},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "service error",
|
||||||
|
setupMock: func() {
|
||||||
|
mockUserService.On("GetUserByPhoneNumber", ctx, phoneNumber).Return(nil, assert.AnError).Once()
|
||||||
|
},
|
||||||
|
wantErr: true,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, tt := range tests {
|
||||||
|
t.Run(tt.name, func(t *testing.T) {
|
||||||
|
tt.setupMock()
|
||||||
|
|
||||||
|
result, err := service.getUserByPhoneNumber(ctx, phoneNumber)
|
||||||
|
|
||||||
|
if tt.wantErr {
|
||||||
|
assert.Error(t, err)
|
||||||
|
assert.Nil(t, result)
|
||||||
|
if tt.errType != nil {
|
||||||
|
assert.IsType(t, tt.errType, err)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
assert.NoError(t, err)
|
||||||
|
assert.Equal(t, tt.expectedUser, result)
|
||||||
|
}
|
||||||
|
|
||||||
|
mockUserService.AssertExpectations(t)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestAuthService_getOrCreateUser(t *testing.T) {
|
||||||
|
mockUserService := &MockUserService{}
|
||||||
|
service := &authService{userService: mockUserService}
|
||||||
|
ctx := context.Background()
|
||||||
|
phoneNumber := "+79161234567"
|
||||||
|
|
||||||
|
tests := []struct {
|
||||||
|
name string
|
||||||
|
setupMock func()
|
||||||
|
expectedUser *userDomain.User
|
||||||
|
wantErr bool
|
||||||
|
}{
|
||||||
|
{
|
||||||
|
name: "existing user found",
|
||||||
|
setupMock: func() {
|
||||||
|
user := &userDomain.User{
|
||||||
|
Uuid: "test-uuid",
|
||||||
|
PhoneNumber: phoneNumber,
|
||||||
|
}
|
||||||
|
mockUserService.On("GetUserByPhoneNumber", ctx, phoneNumber).Return(user, nil).Once()
|
||||||
|
},
|
||||||
|
expectedUser: &userDomain.User{
|
||||||
|
Uuid: "test-uuid",
|
||||||
|
PhoneNumber: phoneNumber,
|
||||||
|
},
|
||||||
|
wantErr: false,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "user not found, create new",
|
||||||
|
setupMock: func() {
|
||||||
|
newUser := &userDomain.User{
|
||||||
|
Uuid: "new-uuid",
|
||||||
|
PhoneNumber: phoneNumber,
|
||||||
|
}
|
||||||
|
mockUserService.On("GetUserByPhoneNumber", ctx, phoneNumber).Return(nil, nil).Once()
|
||||||
|
mockUserService.On("CreateUser", ctx, phoneNumber).Return(newUser, nil).Once()
|
||||||
|
},
|
||||||
|
expectedUser: &userDomain.User{
|
||||||
|
Uuid: "new-uuid",
|
||||||
|
PhoneNumber: phoneNumber,
|
||||||
|
},
|
||||||
|
wantErr: false,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "get user service error",
|
||||||
|
setupMock: func() {
|
||||||
|
mockUserService.On("GetUserByPhoneNumber", ctx, phoneNumber).Return(nil, assert.AnError).Once()
|
||||||
|
},
|
||||||
|
wantErr: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "create user service error",
|
||||||
|
setupMock: func() {
|
||||||
|
mockUserService.On("GetUserByPhoneNumber", ctx, phoneNumber).Return(nil, nil).Once()
|
||||||
|
mockUserService.On("CreateUser", ctx, phoneNumber).Return(nil, assert.AnError).Once()
|
||||||
|
},
|
||||||
|
wantErr: true,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, tt := range tests {
|
||||||
|
t.Run(tt.name, func(t *testing.T) {
|
||||||
|
tt.setupMock()
|
||||||
|
|
||||||
|
result, err := service.getOrCreateUser(ctx, phoneNumber)
|
||||||
|
|
||||||
|
if tt.wantErr {
|
||||||
|
assert.Error(t, err)
|
||||||
|
assert.Nil(t, result)
|
||||||
|
} else {
|
||||||
|
assert.NoError(t, err)
|
||||||
|
assert.Equal(t, tt.expectedUser, result)
|
||||||
|
}
|
||||||
|
|
||||||
|
mockUserService.AssertExpectations(t)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestAuthService_validateHydraResponse(t *testing.T) {
|
||||||
|
service := &authService{}
|
||||||
|
userUuid := "test-uuid"
|
||||||
|
|
||||||
|
tests := []struct {
|
||||||
|
name string
|
||||||
|
statusCode int
|
||||||
|
wantErr bool
|
||||||
|
errType interface{}
|
||||||
|
}{
|
||||||
|
{
|
||||||
|
name: "success status",
|
||||||
|
statusCode: 200,
|
||||||
|
wantErr: false,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "bad request status",
|
||||||
|
statusCode: 400,
|
||||||
|
wantErr: true,
|
||||||
|
errType: domain.ErrInvalidHydraAccept{},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "internal server error status",
|
||||||
|
statusCode: 500,
|
||||||
|
wantErr: true,
|
||||||
|
errType: domain.ErrInvalidHydraAccept{},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, tt := range tests {
|
||||||
|
t.Run(tt.name, func(t *testing.T) {
|
||||||
|
resp := &http.Response{StatusCode: tt.statusCode}
|
||||||
|
|
||||||
|
err := service.validateHydraResponse(resp, userUuid)
|
||||||
|
|
||||||
|
if tt.wantErr {
|
||||||
|
assert.Error(t, err)
|
||||||
|
if tt.errType != nil {
|
||||||
|
assert.IsType(t, tt.errType, err)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
assert.NoError(t, err)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestAuthService_extractRedirectUrl(t *testing.T) {
|
||||||
|
service := &authService{}
|
||||||
|
userUuid := "test-uuid"
|
||||||
|
|
||||||
|
tests := []struct {
|
||||||
|
name string
|
||||||
|
response *MockHydraResponse
|
||||||
|
expectedUrl string
|
||||||
|
wantErr bool
|
||||||
|
errType interface{}
|
||||||
|
}{
|
||||||
|
{
|
||||||
|
name: "valid redirect url",
|
||||||
|
response: &MockHydraResponse{
|
||||||
|
redirectTo: stringPtr("https://example.com/callback"),
|
||||||
|
},
|
||||||
|
expectedUrl: "https://example.com/callback",
|
||||||
|
wantErr: false,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "nil redirect url",
|
||||||
|
response: &MockHydraResponse{
|
||||||
|
redirectTo: nil,
|
||||||
|
},
|
||||||
|
wantErr: true,
|
||||||
|
errType: domain.ErrInvalidHydraAccept{},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, tt := range tests {
|
||||||
|
t.Run(tt.name, func(t *testing.T) {
|
||||||
|
result, err := service.extractRedirectUrl(tt.response, userUuid)
|
||||||
|
|
||||||
|
if tt.wantErr {
|
||||||
|
assert.Error(t, err)
|
||||||
|
assert.Empty(t, result)
|
||||||
|
if tt.errType != nil {
|
||||||
|
assert.IsType(t, tt.errType, err)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
assert.NoError(t, err)
|
||||||
|
assert.Equal(t, tt.expectedUrl, result)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestAuthService_OtpRequest(t *testing.T) {
|
||||||
|
mockRepo := &MockAuthRepository{}
|
||||||
|
mockUserService := &MockUserService{}
|
||||||
|
service := &authService{
|
||||||
|
repo: mockRepo,
|
||||||
|
userService: mockUserService,
|
||||||
|
}
|
||||||
|
ctx := context.Background()
|
||||||
|
phoneNumber := "89161234567" // will be formatted to +79161234567
|
||||||
|
|
||||||
|
tests := []struct {
|
||||||
|
name string
|
||||||
|
setupMock func()
|
||||||
|
wantErr bool
|
||||||
|
errType interface{}
|
||||||
|
}{
|
||||||
|
{
|
||||||
|
name: "success - existing user",
|
||||||
|
setupMock: func() {
|
||||||
|
user := &userDomain.User{
|
||||||
|
Uuid: "test-uuid",
|
||||||
|
PhoneNumber: "+79161234567",
|
||||||
|
}
|
||||||
|
mockUserService.On("GetUserByPhoneNumber", ctx, "+79161234567").Return(user, nil).Once()
|
||||||
|
mockRepo.On("SaveOtpRequest", ctx, "test-uuid", "123456").Return(nil).Once()
|
||||||
|
},
|
||||||
|
wantErr: false,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "success - create new user",
|
||||||
|
setupMock: func() {
|
||||||
|
newUser := &userDomain.User{
|
||||||
|
Uuid: "new-uuid",
|
||||||
|
PhoneNumber: "+79161234567",
|
||||||
|
}
|
||||||
|
mockUserService.On("GetUserByPhoneNumber", ctx, "+79161234567").Return(nil, nil).Once()
|
||||||
|
mockUserService.On("CreateUser", ctx, "+79161234567").Return(newUser, nil).Once()
|
||||||
|
mockRepo.On("SaveOtpRequest", ctx, "new-uuid", "123456").Return(nil).Once()
|
||||||
|
},
|
||||||
|
wantErr: false,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "invalid phone number",
|
||||||
|
setupMock: func() {
|
||||||
|
// No mock setup needed for invalid phone
|
||||||
|
},
|
||||||
|
wantErr: true,
|
||||||
|
errType: domain.ErrInvalidPhoneNumber{},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "repo save error",
|
||||||
|
setupMock: func() {
|
||||||
|
user := &userDomain.User{
|
||||||
|
Uuid: "test-uuid",
|
||||||
|
PhoneNumber: "+79161234567",
|
||||||
|
}
|
||||||
|
mockUserService.On("GetUserByPhoneNumber", ctx, "+79161234567").Return(user, nil).Once()
|
||||||
|
mockRepo.On("SaveOtpRequest", ctx, "test-uuid", "123456").Return(assert.AnError).Once()
|
||||||
|
},
|
||||||
|
wantErr: true,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, tt := range tests {
|
||||||
|
t.Run(tt.name, func(t *testing.T) {
|
||||||
|
// Reset mocks
|
||||||
|
mockRepo.ExpectedCalls = nil
|
||||||
|
mockUserService.ExpectedCalls = nil
|
||||||
|
|
||||||
|
tt.setupMock()
|
||||||
|
|
||||||
|
testPhone := phoneNumber
|
||||||
|
if tt.name == "invalid phone number" {
|
||||||
|
testPhone = "invalid"
|
||||||
|
}
|
||||||
|
|
||||||
|
err := service.OtpRequest(ctx, testPhone)
|
||||||
|
|
||||||
|
if tt.wantErr {
|
||||||
|
assert.Error(t, err)
|
||||||
|
if tt.errType != nil {
|
||||||
|
assert.IsType(t, tt.errType, err)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
assert.NoError(t, err)
|
||||||
|
}
|
||||||
|
|
||||||
|
mockRepo.AssertExpectations(t)
|
||||||
|
mockUserService.AssertExpectations(t)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Helper function to create string pointer
|
||||||
|
func stringPtr(s string) *string {
|
||||||
|
return &s
|
||||||
|
}
|
||||||
@ -1,441 +0,0 @@
|
|||||||
// Package handler provides primitives to interact with the openapi HTTP API.
|
|
||||||
//
|
|
||||||
// Code generated by github.com/oapi-codegen/oapi-codegen/v2 version v2.5.0 DO NOT EDIT.
|
|
||||||
package handler
|
|
||||||
|
|
||||||
import (
|
|
||||||
"context"
|
|
||||||
"fmt"
|
|
||||||
|
|
||||||
"github.com/gofiber/fiber/v2"
|
|
||||||
"github.com/oapi-codegen/runtime"
|
|
||||||
)
|
|
||||||
|
|
||||||
// Todo defines model for Todo.
|
|
||||||
type Todo struct {
|
|
||||||
Completed bool `json:"completed"`
|
|
||||||
Description *string `json:"description,omitempty"`
|
|
||||||
Id string `json:"id"`
|
|
||||||
Title string `json:"title"`
|
|
||||||
}
|
|
||||||
|
|
||||||
// TodoCreate defines model for TodoCreate.
|
|
||||||
type TodoCreate struct {
|
|
||||||
Description *string `json:"description,omitempty"`
|
|
||||||
Title string `json:"title"`
|
|
||||||
}
|
|
||||||
|
|
||||||
// TodoUpdate defines model for TodoUpdate.
|
|
||||||
type TodoUpdate struct {
|
|
||||||
Completed *bool `json:"completed,omitempty"`
|
|
||||||
Description *string `json:"description,omitempty"`
|
|
||||||
Title *string `json:"title,omitempty"`
|
|
||||||
}
|
|
||||||
|
|
||||||
// PostTodosJSONRequestBody defines body for PostTodos for application/json ContentType.
|
|
||||||
type PostTodosJSONRequestBody = TodoCreate
|
|
||||||
|
|
||||||
// PutTodosTodoIdJSONRequestBody defines body for PutTodosTodoId for application/json ContentType.
|
|
||||||
type PutTodosTodoIdJSONRequestBody = TodoUpdate
|
|
||||||
|
|
||||||
// ServerInterface represents all server handlers.
|
|
||||||
type ServerInterface interface {
|
|
||||||
// Get all todos
|
|
||||||
// (GET /todos)
|
|
||||||
GetTodos(c *fiber.Ctx) error
|
|
||||||
// Create a new todo
|
|
||||||
// (POST /todos)
|
|
||||||
PostTodos(c *fiber.Ctx) error
|
|
||||||
// Delete a todo by ID
|
|
||||||
// (DELETE /todos/{todoId})
|
|
||||||
DeleteTodosTodoId(c *fiber.Ctx, todoId string) error
|
|
||||||
// Get a todo by ID
|
|
||||||
// (GET /todos/{todoId})
|
|
||||||
GetTodosTodoId(c *fiber.Ctx, todoId string) error
|
|
||||||
// Update a todo by ID
|
|
||||||
// (PUT /todos/{todoId})
|
|
||||||
PutTodosTodoId(c *fiber.Ctx, todoId string) error
|
|
||||||
}
|
|
||||||
|
|
||||||
// ServerInterfaceWrapper converts contexts to parameters.
|
|
||||||
type ServerInterfaceWrapper struct {
|
|
||||||
Handler ServerInterface
|
|
||||||
}
|
|
||||||
|
|
||||||
type MiddlewareFunc fiber.Handler
|
|
||||||
|
|
||||||
// GetTodos operation middleware
|
|
||||||
func (siw *ServerInterfaceWrapper) GetTodos(c *fiber.Ctx) error {
|
|
||||||
|
|
||||||
return siw.Handler.GetTodos(c)
|
|
||||||
}
|
|
||||||
|
|
||||||
// PostTodos operation middleware
|
|
||||||
func (siw *ServerInterfaceWrapper) PostTodos(c *fiber.Ctx) error {
|
|
||||||
|
|
||||||
return siw.Handler.PostTodos(c)
|
|
||||||
}
|
|
||||||
|
|
||||||
// DeleteTodosTodoId operation middleware
|
|
||||||
func (siw *ServerInterfaceWrapper) DeleteTodosTodoId(c *fiber.Ctx) error {
|
|
||||||
|
|
||||||
var err error
|
|
||||||
|
|
||||||
// ------------- Path parameter "todoId" -------------
|
|
||||||
var todoId string
|
|
||||||
|
|
||||||
err = runtime.BindStyledParameterWithOptions("simple", "todoId", c.Params("todoId"), &todoId, runtime.BindStyledParameterOptions{Explode: false, Required: true})
|
|
||||||
if err != nil {
|
|
||||||
return fiber.NewError(fiber.StatusBadRequest, fmt.Errorf("Invalid format for parameter todoId: %w", err).Error())
|
|
||||||
}
|
|
||||||
|
|
||||||
return siw.Handler.DeleteTodosTodoId(c, todoId)
|
|
||||||
}
|
|
||||||
|
|
||||||
// GetTodosTodoId operation middleware
|
|
||||||
func (siw *ServerInterfaceWrapper) GetTodosTodoId(c *fiber.Ctx) error {
|
|
||||||
|
|
||||||
var err error
|
|
||||||
|
|
||||||
// ------------- Path parameter "todoId" -------------
|
|
||||||
var todoId string
|
|
||||||
|
|
||||||
err = runtime.BindStyledParameterWithOptions("simple", "todoId", c.Params("todoId"), &todoId, runtime.BindStyledParameterOptions{Explode: false, Required: true})
|
|
||||||
if err != nil {
|
|
||||||
return fiber.NewError(fiber.StatusBadRequest, fmt.Errorf("Invalid format for parameter todoId: %w", err).Error())
|
|
||||||
}
|
|
||||||
|
|
||||||
return siw.Handler.GetTodosTodoId(c, todoId)
|
|
||||||
}
|
|
||||||
|
|
||||||
// PutTodosTodoId operation middleware
|
|
||||||
func (siw *ServerInterfaceWrapper) PutTodosTodoId(c *fiber.Ctx) error {
|
|
||||||
|
|
||||||
var err error
|
|
||||||
|
|
||||||
// ------------- Path parameter "todoId" -------------
|
|
||||||
var todoId string
|
|
||||||
|
|
||||||
err = runtime.BindStyledParameterWithOptions("simple", "todoId", c.Params("todoId"), &todoId, runtime.BindStyledParameterOptions{Explode: false, Required: true})
|
|
||||||
if err != nil {
|
|
||||||
return fiber.NewError(fiber.StatusBadRequest, fmt.Errorf("Invalid format for parameter todoId: %w", err).Error())
|
|
||||||
}
|
|
||||||
|
|
||||||
return siw.Handler.PutTodosTodoId(c, todoId)
|
|
||||||
}
|
|
||||||
|
|
||||||
// FiberServerOptions provides options for the Fiber server.
|
|
||||||
type FiberServerOptions struct {
|
|
||||||
BaseURL string
|
|
||||||
Middlewares []MiddlewareFunc
|
|
||||||
}
|
|
||||||
|
|
||||||
// RegisterHandlers creates http.Handler with routing matching OpenAPI spec.
|
|
||||||
func RegisterHandlers(router fiber.Router, si ServerInterface) {
|
|
||||||
RegisterHandlersWithOptions(router, si, FiberServerOptions{})
|
|
||||||
}
|
|
||||||
|
|
||||||
// RegisterHandlersWithOptions creates http.Handler with additional options
|
|
||||||
func RegisterHandlersWithOptions(router fiber.Router, si ServerInterface, options FiberServerOptions) {
|
|
||||||
wrapper := ServerInterfaceWrapper{
|
|
||||||
Handler: si,
|
|
||||||
}
|
|
||||||
|
|
||||||
for _, m := range options.Middlewares {
|
|
||||||
router.Use(fiber.Handler(m))
|
|
||||||
}
|
|
||||||
|
|
||||||
router.Get(options.BaseURL+"/todos", wrapper.GetTodos)
|
|
||||||
|
|
||||||
router.Post(options.BaseURL+"/todos", wrapper.PostTodos)
|
|
||||||
|
|
||||||
router.Delete(options.BaseURL+"/todos/:todoId", wrapper.DeleteTodosTodoId)
|
|
||||||
|
|
||||||
router.Get(options.BaseURL+"/todos/:todoId", wrapper.GetTodosTodoId)
|
|
||||||
|
|
||||||
router.Put(options.BaseURL+"/todos/:todoId", wrapper.PutTodosTodoId)
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
type GetTodosRequestObject struct {
|
|
||||||
}
|
|
||||||
|
|
||||||
type GetTodosResponseObject interface {
|
|
||||||
VisitGetTodosResponse(ctx *fiber.Ctx) error
|
|
||||||
}
|
|
||||||
|
|
||||||
type GetTodos200JSONResponse []Todo
|
|
||||||
|
|
||||||
func (response GetTodos200JSONResponse) VisitGetTodosResponse(ctx *fiber.Ctx) error {
|
|
||||||
ctx.Response().Header.Set("Content-Type", "application/json")
|
|
||||||
ctx.Status(200)
|
|
||||||
|
|
||||||
return ctx.JSON(&response)
|
|
||||||
}
|
|
||||||
|
|
||||||
type PostTodosRequestObject struct {
|
|
||||||
Body *PostTodosJSONRequestBody
|
|
||||||
}
|
|
||||||
|
|
||||||
type PostTodosResponseObject interface {
|
|
||||||
VisitPostTodosResponse(ctx *fiber.Ctx) error
|
|
||||||
}
|
|
||||||
|
|
||||||
type PostTodos201JSONResponse Todo
|
|
||||||
|
|
||||||
func (response PostTodos201JSONResponse) VisitPostTodosResponse(ctx *fiber.Ctx) error {
|
|
||||||
ctx.Response().Header.Set("Content-Type", "application/json")
|
|
||||||
ctx.Status(201)
|
|
||||||
|
|
||||||
return ctx.JSON(&response)
|
|
||||||
}
|
|
||||||
|
|
||||||
type DeleteTodosTodoIdRequestObject struct {
|
|
||||||
TodoId string `json:"todoId"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type DeleteTodosTodoIdResponseObject interface {
|
|
||||||
VisitDeleteTodosTodoIdResponse(ctx *fiber.Ctx) error
|
|
||||||
}
|
|
||||||
|
|
||||||
type DeleteTodosTodoId204Response struct {
|
|
||||||
}
|
|
||||||
|
|
||||||
func (response DeleteTodosTodoId204Response) VisitDeleteTodosTodoIdResponse(ctx *fiber.Ctx) error {
|
|
||||||
ctx.Status(204)
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
type DeleteTodosTodoId404Response struct {
|
|
||||||
}
|
|
||||||
|
|
||||||
func (response DeleteTodosTodoId404Response) VisitDeleteTodosTodoIdResponse(ctx *fiber.Ctx) error {
|
|
||||||
ctx.Status(404)
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
type GetTodosTodoIdRequestObject struct {
|
|
||||||
TodoId string `json:"todoId"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type GetTodosTodoIdResponseObject interface {
|
|
||||||
VisitGetTodosTodoIdResponse(ctx *fiber.Ctx) error
|
|
||||||
}
|
|
||||||
|
|
||||||
type GetTodosTodoId200JSONResponse Todo
|
|
||||||
|
|
||||||
func (response GetTodosTodoId200JSONResponse) VisitGetTodosTodoIdResponse(ctx *fiber.Ctx) error {
|
|
||||||
ctx.Response().Header.Set("Content-Type", "application/json")
|
|
||||||
ctx.Status(200)
|
|
||||||
|
|
||||||
return ctx.JSON(&response)
|
|
||||||
}
|
|
||||||
|
|
||||||
type GetTodosTodoId404Response struct {
|
|
||||||
}
|
|
||||||
|
|
||||||
func (response GetTodosTodoId404Response) VisitGetTodosTodoIdResponse(ctx *fiber.Ctx) error {
|
|
||||||
ctx.Status(404)
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
type PutTodosTodoIdRequestObject struct {
|
|
||||||
TodoId string `json:"todoId"`
|
|
||||||
Body *PutTodosTodoIdJSONRequestBody
|
|
||||||
}
|
|
||||||
|
|
||||||
type PutTodosTodoIdResponseObject interface {
|
|
||||||
VisitPutTodosTodoIdResponse(ctx *fiber.Ctx) error
|
|
||||||
}
|
|
||||||
|
|
||||||
type PutTodosTodoId200JSONResponse Todo
|
|
||||||
|
|
||||||
func (response PutTodosTodoId200JSONResponse) VisitPutTodosTodoIdResponse(ctx *fiber.Ctx) error {
|
|
||||||
ctx.Response().Header.Set("Content-Type", "application/json")
|
|
||||||
ctx.Status(200)
|
|
||||||
|
|
||||||
return ctx.JSON(&response)
|
|
||||||
}
|
|
||||||
|
|
||||||
type PutTodosTodoId404Response struct {
|
|
||||||
}
|
|
||||||
|
|
||||||
func (response PutTodosTodoId404Response) VisitPutTodosTodoIdResponse(ctx *fiber.Ctx) error {
|
|
||||||
ctx.Status(404)
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// StrictServerInterface represents all server handlers.
|
|
||||||
type StrictServerInterface interface {
|
|
||||||
// Get all todos
|
|
||||||
// (GET /todos)
|
|
||||||
GetTodos(ctx context.Context, request GetTodosRequestObject) (GetTodosResponseObject, error)
|
|
||||||
// Create a new todo
|
|
||||||
// (POST /todos)
|
|
||||||
PostTodos(ctx context.Context, request PostTodosRequestObject) (PostTodosResponseObject, error)
|
|
||||||
// Delete a todo by ID
|
|
||||||
// (DELETE /todos/{todoId})
|
|
||||||
DeleteTodosTodoId(ctx context.Context, request DeleteTodosTodoIdRequestObject) (DeleteTodosTodoIdResponseObject, error)
|
|
||||||
// Get a todo by ID
|
|
||||||
// (GET /todos/{todoId})
|
|
||||||
GetTodosTodoId(ctx context.Context, request GetTodosTodoIdRequestObject) (GetTodosTodoIdResponseObject, error)
|
|
||||||
// Update a todo by ID
|
|
||||||
// (PUT /todos/{todoId})
|
|
||||||
PutTodosTodoId(ctx context.Context, request PutTodosTodoIdRequestObject) (PutTodosTodoIdResponseObject, error)
|
|
||||||
}
|
|
||||||
|
|
||||||
type StrictHandlerFunc func(ctx *fiber.Ctx, args interface{}) (interface{}, error)
|
|
||||||
|
|
||||||
type StrictMiddlewareFunc func(f StrictHandlerFunc, operationID string) StrictHandlerFunc
|
|
||||||
|
|
||||||
func NewStrictHandler(ssi StrictServerInterface, middlewares []StrictMiddlewareFunc) ServerInterface {
|
|
||||||
return &strictHandler{ssi: ssi, middlewares: middlewares}
|
|
||||||
}
|
|
||||||
|
|
||||||
type strictHandler struct {
|
|
||||||
ssi StrictServerInterface
|
|
||||||
middlewares []StrictMiddlewareFunc
|
|
||||||
}
|
|
||||||
|
|
||||||
// GetTodos operation middleware
|
|
||||||
func (sh *strictHandler) GetTodos(ctx *fiber.Ctx) error {
|
|
||||||
var request GetTodosRequestObject
|
|
||||||
|
|
||||||
handler := func(ctx *fiber.Ctx, request interface{}) (interface{}, error) {
|
|
||||||
return sh.ssi.GetTodos(ctx.UserContext(), request.(GetTodosRequestObject))
|
|
||||||
}
|
|
||||||
for _, middleware := range sh.middlewares {
|
|
||||||
handler = middleware(handler, "GetTodos")
|
|
||||||
}
|
|
||||||
|
|
||||||
response, err := handler(ctx, request)
|
|
||||||
|
|
||||||
if err != nil {
|
|
||||||
return fiber.NewError(fiber.StatusBadRequest, err.Error())
|
|
||||||
} else if validResponse, ok := response.(GetTodosResponseObject); ok {
|
|
||||||
if err := validResponse.VisitGetTodosResponse(ctx); err != nil {
|
|
||||||
return fiber.NewError(fiber.StatusBadRequest, err.Error())
|
|
||||||
}
|
|
||||||
} else if response != nil {
|
|
||||||
return fmt.Errorf("unexpected response type: %T", response)
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// PostTodos operation middleware
|
|
||||||
func (sh *strictHandler) PostTodos(ctx *fiber.Ctx) error {
|
|
||||||
var request PostTodosRequestObject
|
|
||||||
|
|
||||||
var body PostTodosJSONRequestBody
|
|
||||||
if err := ctx.BodyParser(&body); err != nil {
|
|
||||||
return fiber.NewError(fiber.StatusBadRequest, err.Error())
|
|
||||||
}
|
|
||||||
request.Body = &body
|
|
||||||
|
|
||||||
handler := func(ctx *fiber.Ctx, request interface{}) (interface{}, error) {
|
|
||||||
return sh.ssi.PostTodos(ctx.UserContext(), request.(PostTodosRequestObject))
|
|
||||||
}
|
|
||||||
for _, middleware := range sh.middlewares {
|
|
||||||
handler = middleware(handler, "PostTodos")
|
|
||||||
}
|
|
||||||
|
|
||||||
response, err := handler(ctx, request)
|
|
||||||
|
|
||||||
if err != nil {
|
|
||||||
return fiber.NewError(fiber.StatusBadRequest, err.Error())
|
|
||||||
} else if validResponse, ok := response.(PostTodosResponseObject); ok {
|
|
||||||
if err := validResponse.VisitPostTodosResponse(ctx); err != nil {
|
|
||||||
return fiber.NewError(fiber.StatusBadRequest, err.Error())
|
|
||||||
}
|
|
||||||
} else if response != nil {
|
|
||||||
return fmt.Errorf("unexpected response type: %T", response)
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// DeleteTodosTodoId operation middleware
|
|
||||||
func (sh *strictHandler) DeleteTodosTodoId(ctx *fiber.Ctx, todoId string) error {
|
|
||||||
var request DeleteTodosTodoIdRequestObject
|
|
||||||
|
|
||||||
request.TodoId = todoId
|
|
||||||
|
|
||||||
handler := func(ctx *fiber.Ctx, request interface{}) (interface{}, error) {
|
|
||||||
return sh.ssi.DeleteTodosTodoId(ctx.UserContext(), request.(DeleteTodosTodoIdRequestObject))
|
|
||||||
}
|
|
||||||
for _, middleware := range sh.middlewares {
|
|
||||||
handler = middleware(handler, "DeleteTodosTodoId")
|
|
||||||
}
|
|
||||||
|
|
||||||
response, err := handler(ctx, request)
|
|
||||||
|
|
||||||
if err != nil {
|
|
||||||
return fiber.NewError(fiber.StatusBadRequest, err.Error())
|
|
||||||
} else if validResponse, ok := response.(DeleteTodosTodoIdResponseObject); ok {
|
|
||||||
if err := validResponse.VisitDeleteTodosTodoIdResponse(ctx); err != nil {
|
|
||||||
return fiber.NewError(fiber.StatusBadRequest, err.Error())
|
|
||||||
}
|
|
||||||
} else if response != nil {
|
|
||||||
return fmt.Errorf("unexpected response type: %T", response)
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// GetTodosTodoId operation middleware
|
|
||||||
func (sh *strictHandler) GetTodosTodoId(ctx *fiber.Ctx, todoId string) error {
|
|
||||||
var request GetTodosTodoIdRequestObject
|
|
||||||
|
|
||||||
request.TodoId = todoId
|
|
||||||
|
|
||||||
handler := func(ctx *fiber.Ctx, request interface{}) (interface{}, error) {
|
|
||||||
return sh.ssi.GetTodosTodoId(ctx.UserContext(), request.(GetTodosTodoIdRequestObject))
|
|
||||||
}
|
|
||||||
for _, middleware := range sh.middlewares {
|
|
||||||
handler = middleware(handler, "GetTodosTodoId")
|
|
||||||
}
|
|
||||||
|
|
||||||
response, err := handler(ctx, request)
|
|
||||||
|
|
||||||
if err != nil {
|
|
||||||
return fiber.NewError(fiber.StatusBadRequest, err.Error())
|
|
||||||
} else if validResponse, ok := response.(GetTodosTodoIdResponseObject); ok {
|
|
||||||
if err := validResponse.VisitGetTodosTodoIdResponse(ctx); err != nil {
|
|
||||||
return fiber.NewError(fiber.StatusBadRequest, err.Error())
|
|
||||||
}
|
|
||||||
} else if response != nil {
|
|
||||||
return fmt.Errorf("unexpected response type: %T", response)
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// PutTodosTodoId operation middleware
|
|
||||||
func (sh *strictHandler) PutTodosTodoId(ctx *fiber.Ctx, todoId string) error {
|
|
||||||
var request PutTodosTodoIdRequestObject
|
|
||||||
|
|
||||||
request.TodoId = todoId
|
|
||||||
|
|
||||||
var body PutTodosTodoIdJSONRequestBody
|
|
||||||
if err := ctx.BodyParser(&body); err != nil {
|
|
||||||
return fiber.NewError(fiber.StatusBadRequest, err.Error())
|
|
||||||
}
|
|
||||||
request.Body = &body
|
|
||||||
|
|
||||||
handler := func(ctx *fiber.Ctx, request interface{}) (interface{}, error) {
|
|
||||||
return sh.ssi.PutTodosTodoId(ctx.UserContext(), request.(PutTodosTodoIdRequestObject))
|
|
||||||
}
|
|
||||||
for _, middleware := range sh.middlewares {
|
|
||||||
handler = middleware(handler, "PutTodosTodoId")
|
|
||||||
}
|
|
||||||
|
|
||||||
response, err := handler(ctx, request)
|
|
||||||
|
|
||||||
if err != nil {
|
|
||||||
return fiber.NewError(fiber.StatusBadRequest, err.Error())
|
|
||||||
} else if validResponse, ok := response.(PutTodosTodoIdResponseObject); ok {
|
|
||||||
if err := validResponse.VisitPutTodosTodoIdResponse(ctx); err != nil {
|
|
||||||
return fiber.NewError(fiber.StatusBadRequest, err.Error())
|
|
||||||
}
|
|
||||||
} else if response != nil {
|
|
||||||
return fmt.Errorf("unexpected response type: %T", response)
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
@ -1,3 +0,0 @@
|
|||||||
package handler
|
|
||||||
|
|
||||||
//go:generate go tool oapi-codegen -config ../../../../api/todo/cfg.yaml ../../../../api/todo/todo.yaml
|
|
||||||
@ -1,46 +0,0 @@
|
|||||||
package handler
|
|
||||||
|
|
||||||
import (
|
|
||||||
"context"
|
|
||||||
"github.com/gofiber/fiber/v2"
|
|
||||||
)
|
|
||||||
|
|
||||||
type TodoHandler struct {
|
|
||||||
}
|
|
||||||
|
|
||||||
var _ StrictServerInterface = (*TodoHandler)(nil)
|
|
||||||
|
|
||||||
func (t TodoHandler) GetTodos(ctx context.Context, request GetTodosRequestObject) (GetTodosResponseObject, error) {
|
|
||||||
//TODO implement me
|
|
||||||
panic("implement me")
|
|
||||||
}
|
|
||||||
|
|
||||||
func (t TodoHandler) PostTodos(ctx context.Context, request PostTodosRequestObject) (PostTodosResponseObject, error) {
|
|
||||||
//TODO implement me
|
|
||||||
panic("implement me")
|
|
||||||
}
|
|
||||||
|
|
||||||
func (t TodoHandler) DeleteTodosTodoId(ctx context.Context, request DeleteTodosTodoIdRequestObject) (DeleteTodosTodoIdResponseObject, error) {
|
|
||||||
//TODO implement me
|
|
||||||
panic("implement me")
|
|
||||||
}
|
|
||||||
|
|
||||||
func (t TodoHandler) GetTodosTodoId(ctx context.Context, request GetTodosTodoIdRequestObject) (GetTodosTodoIdResponseObject, error) {
|
|
||||||
//TODO implement me
|
|
||||||
panic("implement me")
|
|
||||||
}
|
|
||||||
|
|
||||||
func (t TodoHandler) PutTodosTodoId(ctx context.Context, request PutTodosTodoIdRequestObject) (PutTodosTodoIdResponseObject, error) {
|
|
||||||
//TODO implement me
|
|
||||||
panic("implement me")
|
|
||||||
}
|
|
||||||
|
|
||||||
func NewTodoHandler() *TodoHandler {
|
|
||||||
return &TodoHandler{}
|
|
||||||
}
|
|
||||||
|
|
||||||
func RegisterApp(router fiber.Router) {
|
|
||||||
server := NewStrictHandler(NewTodoHandler(), nil)
|
|
||||||
RegisterHandlers(router, server)
|
|
||||||
|
|
||||||
}
|
|
||||||
27
internal/api/user/domain/user_domain.go
Normal file
27
internal/api/user/domain/user_domain.go
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
package domain
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
|
||||||
|
db "git.logidex.ru/fakz9/logidex-id/internal/db/generated"
|
||||||
|
)
|
||||||
|
|
||||||
|
type User struct {
|
||||||
|
Uuid string `json:"uuid"`
|
||||||
|
PhoneNumber string `json:"phone_number"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type UserRepository interface {
|
||||||
|
GetUserByPhoneNumber(ctx context.Context, phoneNumber string) (*db.User, error)
|
||||||
|
GetUserByUuid(ctx context.Context, uuid string) (*db.User, error)
|
||||||
|
CreateUser(ctx context.Context, phoneNumber string) (*db.User, error)
|
||||||
|
VerifyUser(ctx context.Context, uuid string) (*db.User, error)
|
||||||
|
}
|
||||||
|
|
||||||
|
type ErrUserNotFound struct {
|
||||||
|
PhoneNumber string
|
||||||
|
}
|
||||||
|
|
||||||
|
func (e ErrUserNotFound) Error() string {
|
||||||
|
return "User not found with phone number: " + e.PhoneNumber
|
||||||
|
}
|
||||||
53
internal/api/user/domain/user_domain_test.go
Normal file
53
internal/api/user/domain/user_domain_test.go
Normal file
@ -0,0 +1,53 @@
|
|||||||
|
package domain
|
||||||
|
|
||||||
|
import (
|
||||||
|
"testing"
|
||||||
|
|
||||||
|
"github.com/stretchr/testify/assert"
|
||||||
|
)
|
||||||
|
|
||||||
|
func TestUser_Structure(t *testing.T) {
|
||||||
|
user := User{
|
||||||
|
Uuid: "123e4567-e89b-12d3-a456-426614174000",
|
||||||
|
PhoneNumber: "+1234567890",
|
||||||
|
}
|
||||||
|
|
||||||
|
assert.Equal(t, "123e4567-e89b-12d3-a456-426614174000", user.Uuid)
|
||||||
|
assert.Equal(t, "+1234567890", user.PhoneNumber)
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestErrUserNotFound_Error(t *testing.T) {
|
||||||
|
tests := []struct {
|
||||||
|
name string
|
||||||
|
phoneNumber string
|
||||||
|
want string
|
||||||
|
}{
|
||||||
|
{
|
||||||
|
name: "returns formatted error message",
|
||||||
|
phoneNumber: "+1234567890",
|
||||||
|
want: "User not found with phone number: +1234567890",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "handles empty phone number",
|
||||||
|
phoneNumber: "",
|
||||||
|
want: "User not found with phone number: ",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "handles international phone number",
|
||||||
|
phoneNumber: "+44123456789",
|
||||||
|
want: "User not found with phone number: +44123456789",
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, tt := range tests {
|
||||||
|
t.Run(tt.name, func(t *testing.T) {
|
||||||
|
err := ErrUserNotFound{PhoneNumber: tt.phoneNumber}
|
||||||
|
assert.Equal(t, tt.want, err.Error())
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestErrUserNotFound_IsError(t *testing.T) {
|
||||||
|
err := ErrUserNotFound{PhoneNumber: "+1234567890"}
|
||||||
|
assert.Implements(t, (*error)(nil), err)
|
||||||
|
}
|
||||||
20
internal/api/user/fx.go
Normal file
20
internal/api/user/fx.go
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
package user
|
||||||
|
|
||||||
|
import (
|
||||||
|
"git.logidex.ru/fakz9/logidex-id/internal/api/user/handler"
|
||||||
|
"git.logidex.ru/fakz9/logidex-id/internal/api/user/repo"
|
||||||
|
"git.logidex.ru/fakz9/logidex-id/internal/api/user/service"
|
||||||
|
"github.com/gofiber/fiber/v2"
|
||||||
|
"go.uber.org/fx"
|
||||||
|
)
|
||||||
|
|
||||||
|
var Module = fx.Options(
|
||||||
|
fx.Provide(
|
||||||
|
repo.NewUserRepo,
|
||||||
|
service.NewUserService,
|
||||||
|
handler.NewUserHandler,
|
||||||
|
),
|
||||||
|
fx.Invoke(func(handler *handler.UserHandler, router fiber.Router) {
|
||||||
|
handler.RegisterRoutes(router)
|
||||||
|
}),
|
||||||
|
)
|
||||||
@ -9,52 +9,30 @@ import (
|
|||||||
|
|
||||||
"github.com/gofiber/fiber/v2"
|
"github.com/gofiber/fiber/v2"
|
||||||
"github.com/oapi-codegen/runtime"
|
"github.com/oapi-codegen/runtime"
|
||||||
openapi_types "github.com/oapi-codegen/runtime/types"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// User defines model for User.
|
// User defines model for User.
|
||||||
type User struct {
|
type User struct {
|
||||||
Email openapi_types.Email `json:"email"`
|
PhoneNumber string `json:"phone_number"`
|
||||||
Id string `json:"id"`
|
Uuid string `json:"uuid"`
|
||||||
Username string `json:"username"`
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// UserCreate defines model for UserCreate.
|
// UserCreate defines model for UserCreate.
|
||||||
type UserCreate struct {
|
type UserCreate struct {
|
||||||
Email openapi_types.Email `json:"email"`
|
PhoneNumber string `json:"phone_number"`
|
||||||
Password string `json:"password"`
|
|
||||||
Username string `json:"username"`
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// UserUpdate defines model for UserUpdate.
|
// CreateUserJSONRequestBody defines body for CreateUser for application/json ContentType.
|
||||||
type UserUpdate struct {
|
type CreateUserJSONRequestBody = UserCreate
|
||||||
Email openapi_types.Email `json:"email"`
|
|
||||||
Username string `json:"username"`
|
|
||||||
}
|
|
||||||
|
|
||||||
// PostUsersJSONRequestBody defines body for PostUsers for application/json ContentType.
|
|
||||||
type PostUsersJSONRequestBody = UserCreate
|
|
||||||
|
|
||||||
// PutUsersUserIdJSONRequestBody defines body for PutUsersUserId for application/json ContentType.
|
|
||||||
type PutUsersUserIdJSONRequestBody = UserUpdate
|
|
||||||
|
|
||||||
// ServerInterface represents all server handlers.
|
// ServerInterface represents all server handlers.
|
||||||
type ServerInterface interface {
|
type ServerInterface interface {
|
||||||
// Get all users
|
// Create a new user with phone number
|
||||||
// (GET /users)
|
|
||||||
GetUsers(c *fiber.Ctx) error
|
|
||||||
// Create a new user
|
|
||||||
// (POST /users)
|
// (POST /users)
|
||||||
PostUsers(c *fiber.Ctx) error
|
CreateUser(c *fiber.Ctx) error
|
||||||
// Delete a user by ID
|
|
||||||
// (DELETE /users/{userId})
|
|
||||||
DeleteUsersUserId(c *fiber.Ctx, userId string) error
|
|
||||||
// Get a user by ID
|
// Get a user by ID
|
||||||
// (GET /users/{userId})
|
// (GET /users/{userId})
|
||||||
GetUsersUserId(c *fiber.Ctx, userId string) error
|
GetUserById(c *fiber.Ctx, userId string) error
|
||||||
// Update a user by ID
|
|
||||||
// (PUT /users/{userId})
|
|
||||||
PutUsersUserId(c *fiber.Ctx, userId string) error
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// ServerInterfaceWrapper converts contexts to parameters.
|
// ServerInterfaceWrapper converts contexts to parameters.
|
||||||
@ -64,20 +42,14 @@ type ServerInterfaceWrapper struct {
|
|||||||
|
|
||||||
type MiddlewareFunc fiber.Handler
|
type MiddlewareFunc fiber.Handler
|
||||||
|
|
||||||
// GetUsers operation middleware
|
// CreateUser operation middleware
|
||||||
func (siw *ServerInterfaceWrapper) GetUsers(c *fiber.Ctx) error {
|
func (siw *ServerInterfaceWrapper) CreateUser(c *fiber.Ctx) error {
|
||||||
|
|
||||||
return siw.Handler.GetUsers(c)
|
return siw.Handler.CreateUser(c)
|
||||||
}
|
}
|
||||||
|
|
||||||
// PostUsers operation middleware
|
// GetUserById operation middleware
|
||||||
func (siw *ServerInterfaceWrapper) PostUsers(c *fiber.Ctx) error {
|
func (siw *ServerInterfaceWrapper) GetUserById(c *fiber.Ctx) error {
|
||||||
|
|
||||||
return siw.Handler.PostUsers(c)
|
|
||||||
}
|
|
||||||
|
|
||||||
// DeleteUsersUserId operation middleware
|
|
||||||
func (siw *ServerInterfaceWrapper) DeleteUsersUserId(c *fiber.Ctx) error {
|
|
||||||
|
|
||||||
var err error
|
var err error
|
||||||
|
|
||||||
@ -89,39 +61,7 @@ func (siw *ServerInterfaceWrapper) DeleteUsersUserId(c *fiber.Ctx) error {
|
|||||||
return fiber.NewError(fiber.StatusBadRequest, fmt.Errorf("Invalid format for parameter userId: %w", err).Error())
|
return fiber.NewError(fiber.StatusBadRequest, fmt.Errorf("Invalid format for parameter userId: %w", err).Error())
|
||||||
}
|
}
|
||||||
|
|
||||||
return siw.Handler.DeleteUsersUserId(c, userId)
|
return siw.Handler.GetUserById(c, userId)
|
||||||
}
|
|
||||||
|
|
||||||
// GetUsersUserId operation middleware
|
|
||||||
func (siw *ServerInterfaceWrapper) GetUsersUserId(c *fiber.Ctx) error {
|
|
||||||
|
|
||||||
var err error
|
|
||||||
|
|
||||||
// ------------- Path parameter "userId" -------------
|
|
||||||
var userId string
|
|
||||||
|
|
||||||
err = runtime.BindStyledParameterWithOptions("simple", "userId", c.Params("userId"), &userId, runtime.BindStyledParameterOptions{Explode: false, Required: true})
|
|
||||||
if err != nil {
|
|
||||||
return fiber.NewError(fiber.StatusBadRequest, fmt.Errorf("Invalid format for parameter userId: %w", err).Error())
|
|
||||||
}
|
|
||||||
|
|
||||||
return siw.Handler.GetUsersUserId(c, userId)
|
|
||||||
}
|
|
||||||
|
|
||||||
// PutUsersUserId operation middleware
|
|
||||||
func (siw *ServerInterfaceWrapper) PutUsersUserId(c *fiber.Ctx) error {
|
|
||||||
|
|
||||||
var err error
|
|
||||||
|
|
||||||
// ------------- Path parameter "userId" -------------
|
|
||||||
var userId string
|
|
||||||
|
|
||||||
err = runtime.BindStyledParameterWithOptions("simple", "userId", c.Params("userId"), &userId, runtime.BindStyledParameterOptions{Explode: false, Required: true})
|
|
||||||
if err != nil {
|
|
||||||
return fiber.NewError(fiber.StatusBadRequest, fmt.Errorf("Invalid format for parameter userId: %w", err).Error())
|
|
||||||
}
|
|
||||||
|
|
||||||
return siw.Handler.PutUsersUserId(c, userId)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// FiberServerOptions provides options for the Fiber server.
|
// FiberServerOptions provides options for the Fiber server.
|
||||||
@ -145,143 +85,67 @@ func RegisterHandlersWithOptions(router fiber.Router, si ServerInterface, option
|
|||||||
router.Use(fiber.Handler(m))
|
router.Use(fiber.Handler(m))
|
||||||
}
|
}
|
||||||
|
|
||||||
router.Get(options.BaseURL+"/users", wrapper.GetUsers)
|
router.Post(options.BaseURL+"/users", wrapper.CreateUser)
|
||||||
|
|
||||||
router.Post(options.BaseURL+"/users", wrapper.PostUsers)
|
router.Get(options.BaseURL+"/users/:userId", wrapper.GetUserById)
|
||||||
|
|
||||||
router.Delete(options.BaseURL+"/users/:userId", wrapper.DeleteUsersUserId)
|
|
||||||
|
|
||||||
router.Get(options.BaseURL+"/users/:userId", wrapper.GetUsersUserId)
|
|
||||||
|
|
||||||
router.Put(options.BaseURL+"/users/:userId", wrapper.PutUsersUserId)
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
type GetUsersRequestObject struct {
|
type CreateUserRequestObject struct {
|
||||||
|
Body *CreateUserJSONRequestBody
|
||||||
}
|
}
|
||||||
|
|
||||||
type GetUsersResponseObject interface {
|
type CreateUserResponseObject interface {
|
||||||
VisitGetUsersResponse(ctx *fiber.Ctx) error
|
VisitCreateUserResponse(ctx *fiber.Ctx) error
|
||||||
}
|
}
|
||||||
|
|
||||||
type GetUsers200JSONResponse []User
|
type CreateUser200JSONResponse User
|
||||||
|
|
||||||
func (response GetUsers200JSONResponse) VisitGetUsersResponse(ctx *fiber.Ctx) error {
|
func (response CreateUser200JSONResponse) VisitCreateUserResponse(ctx *fiber.Ctx) error {
|
||||||
ctx.Response().Header.Set("Content-Type", "application/json")
|
ctx.Response().Header.Set("Content-Type", "application/json")
|
||||||
ctx.Status(200)
|
ctx.Status(200)
|
||||||
|
|
||||||
return ctx.JSON(&response)
|
return ctx.JSON(&response)
|
||||||
}
|
}
|
||||||
|
|
||||||
type PostUsersRequestObject struct {
|
type GetUserByIdRequestObject struct {
|
||||||
Body *PostUsersJSONRequestBody
|
|
||||||
}
|
|
||||||
|
|
||||||
type PostUsersResponseObject interface {
|
|
||||||
VisitPostUsersResponse(ctx *fiber.Ctx) error
|
|
||||||
}
|
|
||||||
|
|
||||||
type PostUsers201JSONResponse User
|
|
||||||
|
|
||||||
func (response PostUsers201JSONResponse) VisitPostUsersResponse(ctx *fiber.Ctx) error {
|
|
||||||
ctx.Response().Header.Set("Content-Type", "application/json")
|
|
||||||
ctx.Status(201)
|
|
||||||
|
|
||||||
return ctx.JSON(&response)
|
|
||||||
}
|
|
||||||
|
|
||||||
type DeleteUsersUserIdRequestObject struct {
|
|
||||||
UserId string `json:"userId"`
|
UserId string `json:"userId"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type DeleteUsersUserIdResponseObject interface {
|
type GetUserByIdResponseObject interface {
|
||||||
VisitDeleteUsersUserIdResponse(ctx *fiber.Ctx) error
|
VisitGetUserByIdResponse(ctx *fiber.Ctx) error
|
||||||
}
|
}
|
||||||
|
|
||||||
type DeleteUsersUserId204Response struct {
|
type GetUserById200JSONResponse struct {
|
||||||
|
User User `json:"user"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (response DeleteUsersUserId204Response) VisitDeleteUsersUserIdResponse(ctx *fiber.Ctx) error {
|
func (response GetUserById200JSONResponse) VisitGetUserByIdResponse(ctx *fiber.Ctx) error {
|
||||||
ctx.Status(204)
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
type DeleteUsersUserId404Response struct {
|
|
||||||
}
|
|
||||||
|
|
||||||
func (response DeleteUsersUserId404Response) VisitDeleteUsersUserIdResponse(ctx *fiber.Ctx) error {
|
|
||||||
ctx.Status(404)
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
type GetUsersUserIdRequestObject struct {
|
|
||||||
UserId string `json:"userId"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type GetUsersUserIdResponseObject interface {
|
|
||||||
VisitGetUsersUserIdResponse(ctx *fiber.Ctx) error
|
|
||||||
}
|
|
||||||
|
|
||||||
type GetUsersUserId200JSONResponse User
|
|
||||||
|
|
||||||
func (response GetUsersUserId200JSONResponse) VisitGetUsersUserIdResponse(ctx *fiber.Ctx) error {
|
|
||||||
ctx.Response().Header.Set("Content-Type", "application/json")
|
ctx.Response().Header.Set("Content-Type", "application/json")
|
||||||
ctx.Status(200)
|
ctx.Status(200)
|
||||||
|
|
||||||
return ctx.JSON(&response)
|
return ctx.JSON(&response)
|
||||||
}
|
}
|
||||||
|
|
||||||
type GetUsersUserId404Response struct {
|
type GetUserById404JSONResponse struct {
|
||||||
|
Message string `json:"message"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (response GetUsersUserId404Response) VisitGetUsersUserIdResponse(ctx *fiber.Ctx) error {
|
func (response GetUserById404JSONResponse) VisitGetUserByIdResponse(ctx *fiber.Ctx) error {
|
||||||
ctx.Status(404)
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
type PutUsersUserIdRequestObject struct {
|
|
||||||
UserId string `json:"userId"`
|
|
||||||
Body *PutUsersUserIdJSONRequestBody
|
|
||||||
}
|
|
||||||
|
|
||||||
type PutUsersUserIdResponseObject interface {
|
|
||||||
VisitPutUsersUserIdResponse(ctx *fiber.Ctx) error
|
|
||||||
}
|
|
||||||
|
|
||||||
type PutUsersUserId200JSONResponse User
|
|
||||||
|
|
||||||
func (response PutUsersUserId200JSONResponse) VisitPutUsersUserIdResponse(ctx *fiber.Ctx) error {
|
|
||||||
ctx.Response().Header.Set("Content-Type", "application/json")
|
ctx.Response().Header.Set("Content-Type", "application/json")
|
||||||
ctx.Status(200)
|
ctx.Status(404)
|
||||||
|
|
||||||
return ctx.JSON(&response)
|
return ctx.JSON(&response)
|
||||||
}
|
}
|
||||||
|
|
||||||
type PutUsersUserId404Response struct {
|
|
||||||
}
|
|
||||||
|
|
||||||
func (response PutUsersUserId404Response) VisitPutUsersUserIdResponse(ctx *fiber.Ctx) error {
|
|
||||||
ctx.Status(404)
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// StrictServerInterface represents all server handlers.
|
// StrictServerInterface represents all server handlers.
|
||||||
type StrictServerInterface interface {
|
type StrictServerInterface interface {
|
||||||
// Get all users
|
// Create a new user with phone number
|
||||||
// (GET /users)
|
|
||||||
GetUsers(ctx context.Context, request GetUsersRequestObject) (GetUsersResponseObject, error)
|
|
||||||
// Create a new user
|
|
||||||
// (POST /users)
|
// (POST /users)
|
||||||
PostUsers(ctx context.Context, request PostUsersRequestObject) (PostUsersResponseObject, error)
|
CreateUser(ctx context.Context, request CreateUserRequestObject) (CreateUserResponseObject, error)
|
||||||
// Delete a user by ID
|
|
||||||
// (DELETE /users/{userId})
|
|
||||||
DeleteUsersUserId(ctx context.Context, request DeleteUsersUserIdRequestObject) (DeleteUsersUserIdResponseObject, error)
|
|
||||||
// Get a user by ID
|
// Get a user by ID
|
||||||
// (GET /users/{userId})
|
// (GET /users/{userId})
|
||||||
GetUsersUserId(ctx context.Context, request GetUsersUserIdRequestObject) (GetUsersUserIdResponseObject, error)
|
GetUserById(ctx context.Context, request GetUserByIdRequestObject) (GetUserByIdResponseObject, error)
|
||||||
// Update a user by ID
|
|
||||||
// (PUT /users/{userId})
|
|
||||||
PutUsersUserId(ctx context.Context, request PutUsersUserIdRequestObject) (PutUsersUserIdResponseObject, error)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
type StrictHandlerFunc func(ctx *fiber.Ctx, args interface{}) (interface{}, error)
|
type StrictHandlerFunc func(ctx *fiber.Ctx, args interface{}) (interface{}, error)
|
||||||
@ -297,54 +161,29 @@ type strictHandler struct {
|
|||||||
middlewares []StrictMiddlewareFunc
|
middlewares []StrictMiddlewareFunc
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetUsers operation middleware
|
// CreateUser operation middleware
|
||||||
func (sh *strictHandler) GetUsers(ctx *fiber.Ctx) error {
|
func (sh *strictHandler) CreateUser(ctx *fiber.Ctx) error {
|
||||||
var request GetUsersRequestObject
|
var request CreateUserRequestObject
|
||||||
|
|
||||||
handler := func(ctx *fiber.Ctx, request interface{}) (interface{}, error) {
|
var body CreateUserJSONRequestBody
|
||||||
return sh.ssi.GetUsers(ctx.UserContext(), request.(GetUsersRequestObject))
|
|
||||||
}
|
|
||||||
for _, middleware := range sh.middlewares {
|
|
||||||
handler = middleware(handler, "GetUsers")
|
|
||||||
}
|
|
||||||
|
|
||||||
response, err := handler(ctx, request)
|
|
||||||
|
|
||||||
if err != nil {
|
|
||||||
return fiber.NewError(fiber.StatusBadRequest, err.Error())
|
|
||||||
} else if validResponse, ok := response.(GetUsersResponseObject); ok {
|
|
||||||
if err := validResponse.VisitGetUsersResponse(ctx); err != nil {
|
|
||||||
return fiber.NewError(fiber.StatusBadRequest, err.Error())
|
|
||||||
}
|
|
||||||
} else if response != nil {
|
|
||||||
return fmt.Errorf("unexpected response type: %T", response)
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// PostUsers operation middleware
|
|
||||||
func (sh *strictHandler) PostUsers(ctx *fiber.Ctx) error {
|
|
||||||
var request PostUsersRequestObject
|
|
||||||
|
|
||||||
var body PostUsersJSONRequestBody
|
|
||||||
if err := ctx.BodyParser(&body); err != nil {
|
if err := ctx.BodyParser(&body); err != nil {
|
||||||
return fiber.NewError(fiber.StatusBadRequest, err.Error())
|
return fiber.NewError(fiber.StatusBadRequest, err.Error())
|
||||||
}
|
}
|
||||||
request.Body = &body
|
request.Body = &body
|
||||||
|
|
||||||
handler := func(ctx *fiber.Ctx, request interface{}) (interface{}, error) {
|
handler := func(ctx *fiber.Ctx, request interface{}) (interface{}, error) {
|
||||||
return sh.ssi.PostUsers(ctx.UserContext(), request.(PostUsersRequestObject))
|
return sh.ssi.CreateUser(ctx.UserContext(), request.(CreateUserRequestObject))
|
||||||
}
|
}
|
||||||
for _, middleware := range sh.middlewares {
|
for _, middleware := range sh.middlewares {
|
||||||
handler = middleware(handler, "PostUsers")
|
handler = middleware(handler, "CreateUser")
|
||||||
}
|
}
|
||||||
|
|
||||||
response, err := handler(ctx, request)
|
response, err := handler(ctx, request)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fiber.NewError(fiber.StatusBadRequest, err.Error())
|
return fiber.NewError(fiber.StatusBadRequest, err.Error())
|
||||||
} else if validResponse, ok := response.(PostUsersResponseObject); ok {
|
} else if validResponse, ok := response.(CreateUserResponseObject); ok {
|
||||||
if err := validResponse.VisitPostUsersResponse(ctx); err != nil {
|
if err := validResponse.VisitCreateUserResponse(ctx); err != nil {
|
||||||
return fiber.NewError(fiber.StatusBadRequest, err.Error())
|
return fiber.NewError(fiber.StatusBadRequest, err.Error())
|
||||||
}
|
}
|
||||||
} else if response != nil {
|
} else if response != nil {
|
||||||
@ -353,85 +192,25 @@ func (sh *strictHandler) PostUsers(ctx *fiber.Ctx) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// DeleteUsersUserId operation middleware
|
// GetUserById operation middleware
|
||||||
func (sh *strictHandler) DeleteUsersUserId(ctx *fiber.Ctx, userId string) error {
|
func (sh *strictHandler) GetUserById(ctx *fiber.Ctx, userId string) error {
|
||||||
var request DeleteUsersUserIdRequestObject
|
var request GetUserByIdRequestObject
|
||||||
|
|
||||||
request.UserId = userId
|
request.UserId = userId
|
||||||
|
|
||||||
handler := func(ctx *fiber.Ctx, request interface{}) (interface{}, error) {
|
handler := func(ctx *fiber.Ctx, request interface{}) (interface{}, error) {
|
||||||
return sh.ssi.DeleteUsersUserId(ctx.UserContext(), request.(DeleteUsersUserIdRequestObject))
|
return sh.ssi.GetUserById(ctx.UserContext(), request.(GetUserByIdRequestObject))
|
||||||
}
|
}
|
||||||
for _, middleware := range sh.middlewares {
|
for _, middleware := range sh.middlewares {
|
||||||
handler = middleware(handler, "DeleteUsersUserId")
|
handler = middleware(handler, "GetUserById")
|
||||||
}
|
}
|
||||||
|
|
||||||
response, err := handler(ctx, request)
|
response, err := handler(ctx, request)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fiber.NewError(fiber.StatusBadRequest, err.Error())
|
return fiber.NewError(fiber.StatusBadRequest, err.Error())
|
||||||
} else if validResponse, ok := response.(DeleteUsersUserIdResponseObject); ok {
|
} else if validResponse, ok := response.(GetUserByIdResponseObject); ok {
|
||||||
if err := validResponse.VisitDeleteUsersUserIdResponse(ctx); err != nil {
|
if err := validResponse.VisitGetUserByIdResponse(ctx); err != nil {
|
||||||
return fiber.NewError(fiber.StatusBadRequest, err.Error())
|
|
||||||
}
|
|
||||||
} else if response != nil {
|
|
||||||
return fmt.Errorf("unexpected response type: %T", response)
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// GetUsersUserId operation middleware
|
|
||||||
func (sh *strictHandler) GetUsersUserId(ctx *fiber.Ctx, userId string) error {
|
|
||||||
var request GetUsersUserIdRequestObject
|
|
||||||
|
|
||||||
request.UserId = userId
|
|
||||||
|
|
||||||
handler := func(ctx *fiber.Ctx, request interface{}) (interface{}, error) {
|
|
||||||
return sh.ssi.GetUsersUserId(ctx.UserContext(), request.(GetUsersUserIdRequestObject))
|
|
||||||
}
|
|
||||||
for _, middleware := range sh.middlewares {
|
|
||||||
handler = middleware(handler, "GetUsersUserId")
|
|
||||||
}
|
|
||||||
|
|
||||||
response, err := handler(ctx, request)
|
|
||||||
|
|
||||||
if err != nil {
|
|
||||||
return fiber.NewError(fiber.StatusBadRequest, err.Error())
|
|
||||||
} else if validResponse, ok := response.(GetUsersUserIdResponseObject); ok {
|
|
||||||
if err := validResponse.VisitGetUsersUserIdResponse(ctx); err != nil {
|
|
||||||
return fiber.NewError(fiber.StatusBadRequest, err.Error())
|
|
||||||
}
|
|
||||||
} else if response != nil {
|
|
||||||
return fmt.Errorf("unexpected response type: %T", response)
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// PutUsersUserId operation middleware
|
|
||||||
func (sh *strictHandler) PutUsersUserId(ctx *fiber.Ctx, userId string) error {
|
|
||||||
var request PutUsersUserIdRequestObject
|
|
||||||
|
|
||||||
request.UserId = userId
|
|
||||||
|
|
||||||
var body PutUsersUserIdJSONRequestBody
|
|
||||||
if err := ctx.BodyParser(&body); err != nil {
|
|
||||||
return fiber.NewError(fiber.StatusBadRequest, err.Error())
|
|
||||||
}
|
|
||||||
request.Body = &body
|
|
||||||
|
|
||||||
handler := func(ctx *fiber.Ctx, request interface{}) (interface{}, error) {
|
|
||||||
return sh.ssi.PutUsersUserId(ctx.UserContext(), request.(PutUsersUserIdRequestObject))
|
|
||||||
}
|
|
||||||
for _, middleware := range sh.middlewares {
|
|
||||||
handler = middleware(handler, "PutUsersUserId")
|
|
||||||
}
|
|
||||||
|
|
||||||
response, err := handler(ctx, request)
|
|
||||||
|
|
||||||
if err != nil {
|
|
||||||
return fiber.NewError(fiber.StatusBadRequest, err.Error())
|
|
||||||
} else if validResponse, ok := response.(PutUsersUserIdResponseObject); ok {
|
|
||||||
if err := validResponse.VisitPutUsersUserIdResponse(ctx); err != nil {
|
|
||||||
return fiber.NewError(fiber.StatusBadRequest, err.Error())
|
return fiber.NewError(fiber.StatusBadRequest, err.Error())
|
||||||
}
|
}
|
||||||
} else if response != nil {
|
} else if response != nil {
|
||||||
|
|||||||
@ -1,3 +1,3 @@
|
|||||||
package handler
|
package handler
|
||||||
|
|
||||||
//go:generate go tool oapi-codegen -config ../../../../api/user/cfg.yaml ../../../../api/user/user.yaml
|
//go:generate go tool oapi-codegen -config ../../../../api/user/cfg.yaml ../../../../api/user/api.yaml
|
||||||
|
|||||||
@ -2,46 +2,45 @@ package handler
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
|
||||||
|
"git.logidex.ru/fakz9/logidex-id/internal/api/user/service"
|
||||||
"github.com/gofiber/fiber/v2"
|
"github.com/gofiber/fiber/v2"
|
||||||
|
"github.com/jinzhu/copier"
|
||||||
)
|
)
|
||||||
|
|
||||||
type UserHandler struct {
|
type UserHandler struct {
|
||||||
|
service service.UserService
|
||||||
|
}
|
||||||
|
|
||||||
|
func (h UserHandler) CreateUser(ctx context.Context, request CreateUserRequestObject) (CreateUserResponseObject, error) {
|
||||||
|
//TODO implement me
|
||||||
|
panic("implement me")
|
||||||
|
}
|
||||||
|
|
||||||
|
func (h UserHandler) GetUserById(ctx context.Context, request GetUserByIdRequestObject) (GetUserByIdResponseObject, error) {
|
||||||
|
user, err := h.service.GetUserByUuid(ctx, request.UserId)
|
||||||
|
if err != nil {
|
||||||
|
return GetUserById404JSONResponse{
|
||||||
|
Message: err.Error(),
|
||||||
|
}, nil
|
||||||
|
}
|
||||||
|
var responseUser User
|
||||||
|
err = copier.Copy(&responseUser, user)
|
||||||
|
if err != nil {
|
||||||
|
return GetUserById404JSONResponse{Message: err.Error()}, nil
|
||||||
|
}
|
||||||
|
return GetUserById200JSONResponse{User: responseUser}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
var _ StrictServerInterface = (*UserHandler)(nil)
|
var _ StrictServerInterface = (*UserHandler)(nil)
|
||||||
|
|
||||||
func (u UserHandler) GetUsers(ctx context.Context, request GetUsersRequestObject) (GetUsersResponseObject, error) {
|
func NewUserHandler(
|
||||||
var response = make([]User, 0)
|
service service.UserService,
|
||||||
|
) *UserHandler {
|
||||||
return GetUsers200JSONResponse(response), nil
|
return &UserHandler{service: service}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (u UserHandler) PostUsers(ctx context.Context, request PostUsersRequestObject) (PostUsersResponseObject, error) {
|
func (h UserHandler) RegisterRoutes(router fiber.Router) {
|
||||||
//TODO implement me
|
server := NewStrictHandler(h, nil)
|
||||||
panic("implement me")
|
|
||||||
}
|
|
||||||
|
|
||||||
func (u UserHandler) DeleteUsersUserId(ctx context.Context, request DeleteUsersUserIdRequestObject) (DeleteUsersUserIdResponseObject, error) {
|
|
||||||
//TODO implement me
|
|
||||||
panic("implement me")
|
|
||||||
}
|
|
||||||
|
|
||||||
func (u UserHandler) GetUsersUserId(ctx context.Context, request GetUsersUserIdRequestObject) (GetUsersUserIdResponseObject, error) {
|
|
||||||
//TODO implement me
|
|
||||||
panic("implement me")
|
|
||||||
}
|
|
||||||
|
|
||||||
func (u UserHandler) PutUsersUserId(ctx context.Context, request PutUsersUserIdRequestObject) (PutUsersUserIdResponseObject, error) {
|
|
||||||
//TODO implement me
|
|
||||||
panic("implement me")
|
|
||||||
}
|
|
||||||
|
|
||||||
func NewUserHandler() *UserHandler {
|
|
||||||
return &UserHandler{}
|
|
||||||
}
|
|
||||||
|
|
||||||
func RegisterApp(router fiber.Router) {
|
|
||||||
server := NewStrictHandler(NewUserHandler(), nil)
|
|
||||||
RegisterHandlers(router, server)
|
RegisterHandlers(router, server)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
198
internal/api/user/handler/impl_test.go
Normal file
198
internal/api/user/handler/impl_test.go
Normal file
@ -0,0 +1,198 @@
|
|||||||
|
package handler
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"testing"
|
||||||
|
|
||||||
|
"git.logidex.ru/fakz9/logidex-id/internal/api/user/domain"
|
||||||
|
"github.com/stretchr/testify/assert"
|
||||||
|
"github.com/stretchr/testify/mock"
|
||||||
|
)
|
||||||
|
|
||||||
|
// MockUserService implements service.UserService
|
||||||
|
type MockUserService struct {
|
||||||
|
mock.Mock
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *MockUserService) GetUserByPhoneNumber(ctx context.Context, phoneNumber string) (*domain.User, error) {
|
||||||
|
args := m.Called(ctx, phoneNumber)
|
||||||
|
if args.Get(0) == nil {
|
||||||
|
return nil, args.Error(1)
|
||||||
|
}
|
||||||
|
return args.Get(0).(*domain.User), args.Error(1)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *MockUserService) GetUserByUuid(ctx context.Context, uuid string) (*domain.User, error) {
|
||||||
|
args := m.Called(ctx, uuid)
|
||||||
|
if args.Get(0) == nil {
|
||||||
|
return nil, args.Error(1)
|
||||||
|
}
|
||||||
|
return args.Get(0).(*domain.User), args.Error(1)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *MockUserService) CreateUser(ctx context.Context, phoneNumber string) (*domain.User, error) {
|
||||||
|
args := m.Called(ctx, phoneNumber)
|
||||||
|
if args.Get(0) == nil {
|
||||||
|
return nil, args.Error(1)
|
||||||
|
}
|
||||||
|
return args.Get(0).(*domain.User), args.Error(1)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *MockUserService) VerifyUser(ctx context.Context, uuid string) (*domain.User, error) {
|
||||||
|
args := m.Called(ctx, uuid)
|
||||||
|
if args.Get(0) == nil {
|
||||||
|
return nil, args.Error(1)
|
||||||
|
}
|
||||||
|
return args.Get(0).(*domain.User), args.Error(1)
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestNewUserHandler(t *testing.T) {
|
||||||
|
mockService := &MockUserService{}
|
||||||
|
handler := NewUserHandler(mockService)
|
||||||
|
|
||||||
|
assert.NotNil(t, handler)
|
||||||
|
assert.Equal(t, mockService, handler.service)
|
||||||
|
assert.Implements(t, (*StrictServerInterface)(nil), handler)
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestUserHandler_GetUserById(t *testing.T) {
|
||||||
|
tests := []struct {
|
||||||
|
name string
|
||||||
|
userId string
|
||||||
|
setupMock func(*MockUserService)
|
||||||
|
expectedStatus int
|
||||||
|
expectError bool
|
||||||
|
expectedMsg string
|
||||||
|
}{
|
||||||
|
{
|
||||||
|
name: "successful user retrieval",
|
||||||
|
userId: "123e4567-e89b-12d3-a456-426614174000",
|
||||||
|
setupMock: func(m *MockUserService) {
|
||||||
|
user := &domain.User{
|
||||||
|
Uuid: "123e4567-e89b-12d3-a456-426614174000",
|
||||||
|
PhoneNumber: "+79161234567",
|
||||||
|
}
|
||||||
|
m.On("GetUserByUuid", mock.Anything, "123e4567-e89b-12d3-a456-426614174000").
|
||||||
|
Return(user, nil).Once()
|
||||||
|
},
|
||||||
|
expectedStatus: 200, // Fixed copier bug
|
||||||
|
expectError: false,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "user not found",
|
||||||
|
userId: "nonexistent-uuid",
|
||||||
|
setupMock: func(m *MockUserService) {
|
||||||
|
m.On("GetUserByUuid", mock.Anything, "nonexistent-uuid").
|
||||||
|
Return(nil, domain.ErrUserNotFound{PhoneNumber: "nonexistent-uuid"}).Once()
|
||||||
|
},
|
||||||
|
expectedStatus: 404,
|
||||||
|
expectError: true,
|
||||||
|
expectedMsg: "User not found with phone number: nonexistent-uuid",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "service error",
|
||||||
|
userId: "error-uuid",
|
||||||
|
setupMock: func(m *MockUserService) {
|
||||||
|
m.On("GetUserByUuid", mock.Anything, "error-uuid").
|
||||||
|
Return(nil, assert.AnError).Once()
|
||||||
|
},
|
||||||
|
expectedStatus: 404,
|
||||||
|
expectError: true,
|
||||||
|
expectedMsg: assert.AnError.Error(),
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, tt := range tests {
|
||||||
|
t.Run(tt.name, func(t *testing.T) {
|
||||||
|
mockService := &MockUserService{}
|
||||||
|
handler := &UserHandler{service: mockService}
|
||||||
|
ctx := context.Background()
|
||||||
|
|
||||||
|
tt.setupMock(mockService)
|
||||||
|
|
||||||
|
request := GetUserByIdRequestObject{
|
||||||
|
UserId: tt.userId,
|
||||||
|
}
|
||||||
|
|
||||||
|
result, err := handler.GetUserById(ctx, request)
|
||||||
|
|
||||||
|
assert.NoError(t, err) // Handler should not return errors, only response objects
|
||||||
|
|
||||||
|
if tt.expectedStatus == 200 {
|
||||||
|
response, ok := result.(GetUserById200JSONResponse)
|
||||||
|
assert.True(t, ok, "Expected 200 response type")
|
||||||
|
_ = response // Just to avoid unused variable error
|
||||||
|
} else {
|
||||||
|
response, ok := result.(GetUserById404JSONResponse)
|
||||||
|
assert.True(t, ok, "Expected 404 response type")
|
||||||
|
assert.Equal(t, tt.expectedMsg, response.Message)
|
||||||
|
_ = response // Use the variable to avoid unused error
|
||||||
|
}
|
||||||
|
|
||||||
|
mockService.AssertExpectations(t)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestUserHandler_CreateUser(t *testing.T) {
|
||||||
|
mockService := &MockUserService{}
|
||||||
|
handler := &UserHandler{service: mockService}
|
||||||
|
ctx := context.Background()
|
||||||
|
|
||||||
|
t.Run("create user not implemented", func(t *testing.T) {
|
||||||
|
request := CreateUserRequestObject{}
|
||||||
|
|
||||||
|
// This should panic as per the current implementation
|
||||||
|
assert.Panics(t, func() {
|
||||||
|
_, _ = handler.CreateUser(ctx, request)
|
||||||
|
}, "CreateUser should panic as it's not implemented")
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestUserHandler_EdgeCases(t *testing.T) {
|
||||||
|
t.Run("empty user ID should be handled gracefully", func(t *testing.T) {
|
||||||
|
mockService := &MockUserService{}
|
||||||
|
handler := &UserHandler{service: mockService}
|
||||||
|
ctx := context.Background()
|
||||||
|
|
||||||
|
mockService.On("GetUserByUuid", mock.Anything, "").
|
||||||
|
Return(nil, domain.ErrUserNotFound{PhoneNumber: ""}).Once()
|
||||||
|
|
||||||
|
request := GetUserByIdRequestObject{
|
||||||
|
UserId: "",
|
||||||
|
}
|
||||||
|
|
||||||
|
result, err := handler.GetUserById(ctx, request)
|
||||||
|
|
||||||
|
assert.NoError(t, err)
|
||||||
|
response, ok := result.(GetUserById404JSONResponse)
|
||||||
|
assert.True(t, ok)
|
||||||
|
assert.Contains(t, response.Message, "User not found")
|
||||||
|
|
||||||
|
mockService.AssertExpectations(t)
|
||||||
|
})
|
||||||
|
|
||||||
|
t.Run("special characters in user ID", func(t *testing.T) {
|
||||||
|
mockService := &MockUserService{}
|
||||||
|
handler := &UserHandler{service: mockService}
|
||||||
|
ctx := context.Background()
|
||||||
|
|
||||||
|
specialUserId := "user@#$%^&*()"
|
||||||
|
|
||||||
|
mockService.On("GetUserByUuid", mock.Anything, specialUserId).
|
||||||
|
Return(nil, domain.ErrUserNotFound{PhoneNumber: specialUserId}).Once()
|
||||||
|
|
||||||
|
request := GetUserByIdRequestObject{
|
||||||
|
UserId: specialUserId,
|
||||||
|
}
|
||||||
|
|
||||||
|
result, err := handler.GetUserById(ctx, request)
|
||||||
|
|
||||||
|
assert.NoError(t, err)
|
||||||
|
response, ok := result.(GetUserById404JSONResponse)
|
||||||
|
assert.True(t, ok)
|
||||||
|
_ = response // Use the variable to avoid unused error
|
||||||
|
|
||||||
|
mockService.AssertExpectations(t)
|
||||||
|
})
|
||||||
|
}
|
||||||
63
internal/api/user/repo/user_repo.go
Normal file
63
internal/api/user/repo/user_repo.go
Normal file
@ -0,0 +1,63 @@
|
|||||||
|
package repo
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
|
||||||
|
"git.logidex.ru/fakz9/logidex-id/internal/api/user/domain"
|
||||||
|
db "git.logidex.ru/fakz9/logidex-id/internal/db/generated"
|
||||||
|
"github.com/google/uuid"
|
||||||
|
)
|
||||||
|
|
||||||
|
type userRepo struct {
|
||||||
|
db db.DBTX
|
||||||
|
}
|
||||||
|
|
||||||
|
func (u userRepo) VerifyUser(ctx context.Context, requestUuid string) (*db.User, error) {
|
||||||
|
//TODO implement me
|
||||||
|
|
||||||
|
queries := db.New(u.db)
|
||||||
|
uuidParsed, err := uuid.Parse(requestUuid)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
dbUser, err := queries.UpdateUserVerified(ctx, uuidParsed)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return &dbUser, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (u userRepo) GetUserByUuid(ctx context.Context, requestUuid string) (*db.User, error) {
|
||||||
|
queries := db.New(u.db)
|
||||||
|
uuidParsed, err := uuid.Parse(requestUuid)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
dbUser, err := queries.GetUserByUUID(ctx, uuidParsed)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return &dbUser, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (u userRepo) CreateUser(ctx context.Context, phoneNumber string) (*db.User, error) {
|
||||||
|
queries := db.New(u.db)
|
||||||
|
user, err := queries.CreateUser(ctx, phoneNumber)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return &user, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (u userRepo) GetUserByPhoneNumber(ctx context.Context, phoneNumber string) (*db.User, error) {
|
||||||
|
queries := db.New(u.db)
|
||||||
|
dbUser, err := queries.GetByPhoneNumber(ctx, phoneNumber)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return &dbUser, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewUserRepo(db db.DBTX) domain.UserRepository {
|
||||||
|
return &userRepo{db: db}
|
||||||
|
}
|
||||||
@ -1,4 +0,0 @@
|
|||||||
package repository
|
|
||||||
|
|
||||||
type UserRepo interface {
|
|
||||||
}
|
|
||||||
@ -1,13 +1,71 @@
|
|||||||
package service
|
package service
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"git.logidex.ru/fakz9/logidex-id/internal/api/user/repository"
|
"context"
|
||||||
|
|
||||||
|
"git.logidex.ru/fakz9/logidex-id/internal/api/user/domain"
|
||||||
)
|
)
|
||||||
|
|
||||||
type UserService struct {
|
type UserService interface {
|
||||||
repo *repository.UserRepo
|
GetUserByPhoneNumber(ctx context.Context, phoneNumber string) (*domain.User, error)
|
||||||
|
GetUserByUuid(ctx context.Context, uuid string) (*domain.User, error)
|
||||||
|
CreateUser(ctx context.Context, phoneNumber string) (*domain.User, error)
|
||||||
|
VerifyUser(ctx context.Context, uuid string) (*domain.User, error)
|
||||||
|
}
|
||||||
|
type userService struct {
|
||||||
|
repo domain.UserRepository
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewUserService(repo *repository.UserRepo) *UserService {
|
func (u userService) GetUserByUuid(ctx context.Context, uuid string) (*domain.User, error) {
|
||||||
return &UserService{repo: repo}
|
dbUser, err := u.repo.GetUserByUuid(ctx, uuid)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
if dbUser == nil {
|
||||||
|
return nil, domain.ErrUserNotFound{PhoneNumber: uuid}
|
||||||
|
}
|
||||||
|
return &domain.User{
|
||||||
|
Uuid: dbUser.Uuid.String(),
|
||||||
|
PhoneNumber: dbUser.PhoneNumber,
|
||||||
|
}, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (u userService) GetUserByPhoneNumber(ctx context.Context, phoneNumber string) (*domain.User, error) {
|
||||||
|
dbUser, err := u.repo.GetUserByPhoneNumber(ctx, phoneNumber)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
if dbUser == nil {
|
||||||
|
return nil, domain.ErrUserNotFound{PhoneNumber: phoneNumber}
|
||||||
|
}
|
||||||
|
return &domain.User{
|
||||||
|
Uuid: dbUser.Uuid.String(),
|
||||||
|
PhoneNumber: dbUser.PhoneNumber,
|
||||||
|
}, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (u userService) CreateUser(ctx context.Context, phoneNumber string) (*domain.User, error) {
|
||||||
|
dbUser, err := u.repo.CreateUser(ctx, phoneNumber)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return &domain.User{
|
||||||
|
Uuid: dbUser.Uuid.String(),
|
||||||
|
PhoneNumber: dbUser.PhoneNumber,
|
||||||
|
}, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (u userService) VerifyUser(ctx context.Context, uuid string) (*domain.User, error) {
|
||||||
|
dbUser, err := u.repo.VerifyUser(ctx, uuid)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return &domain.User{
|
||||||
|
Uuid: dbUser.Uuid.String(),
|
||||||
|
PhoneNumber: dbUser.PhoneNumber,
|
||||||
|
}, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewUserService(repo domain.UserRepository) UserService {
|
||||||
|
return &userService{repo: repo}
|
||||||
}
|
}
|
||||||
|
|||||||
337
internal/api/user/service/user_service_test.go
Normal file
337
internal/api/user/service/user_service_test.go
Normal file
@ -0,0 +1,337 @@
|
|||||||
|
package service
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"testing"
|
||||||
|
|
||||||
|
"git.logidex.ru/fakz9/logidex-id/internal/api/user/domain"
|
||||||
|
db "git.logidex.ru/fakz9/logidex-id/internal/db/generated"
|
||||||
|
"github.com/google/uuid"
|
||||||
|
"github.com/stretchr/testify/assert"
|
||||||
|
"github.com/stretchr/testify/mock"
|
||||||
|
)
|
||||||
|
|
||||||
|
// MockUserRepository implements domain.UserRepository
|
||||||
|
type MockUserRepository struct {
|
||||||
|
mock.Mock
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *MockUserRepository) GetUserByPhoneNumber(ctx context.Context, phoneNumber string) (*db.User, error) {
|
||||||
|
args := m.Called(ctx, phoneNumber)
|
||||||
|
if args.Get(0) == nil {
|
||||||
|
return nil, args.Error(1)
|
||||||
|
}
|
||||||
|
return args.Get(0).(*db.User), args.Error(1)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *MockUserRepository) GetUserByUuid(ctx context.Context, uuid string) (*db.User, error) {
|
||||||
|
args := m.Called(ctx, uuid)
|
||||||
|
if args.Get(0) == nil {
|
||||||
|
return nil, args.Error(1)
|
||||||
|
}
|
||||||
|
return args.Get(0).(*db.User), args.Error(1)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *MockUserRepository) CreateUser(ctx context.Context, phoneNumber string) (*db.User, error) {
|
||||||
|
args := m.Called(ctx, phoneNumber)
|
||||||
|
if args.Get(0) == nil {
|
||||||
|
return nil, args.Error(1)
|
||||||
|
}
|
||||||
|
return args.Get(0).(*db.User), args.Error(1)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *MockUserRepository) VerifyUser(ctx context.Context, uuid string) (*db.User, error) {
|
||||||
|
args := m.Called(ctx, uuid)
|
||||||
|
if args.Get(0) == nil {
|
||||||
|
return nil, args.Error(1)
|
||||||
|
}
|
||||||
|
return args.Get(0).(*db.User), args.Error(1)
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestNewUserService(t *testing.T) {
|
||||||
|
mockRepo := &MockUserRepository{}
|
||||||
|
service := NewUserService(mockRepo)
|
||||||
|
|
||||||
|
assert.NotNil(t, service)
|
||||||
|
assert.Implements(t, (*UserService)(nil), service)
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestUserService_GetUserByPhoneNumber(t *testing.T) {
|
||||||
|
mockRepo := &MockUserRepository{}
|
||||||
|
service := &userService{repo: mockRepo}
|
||||||
|
ctx := context.Background()
|
||||||
|
phoneNumber := "+79161234567"
|
||||||
|
testUuid := uuid.New()
|
||||||
|
|
||||||
|
tests := []struct {
|
||||||
|
name string
|
||||||
|
setupMock func()
|
||||||
|
expectedUser *domain.User
|
||||||
|
wantErr bool
|
||||||
|
errType interface{}
|
||||||
|
}{
|
||||||
|
{
|
||||||
|
name: "user found",
|
||||||
|
setupMock: func() {
|
||||||
|
dbUser := &db.User{
|
||||||
|
Uuid: testUuid,
|
||||||
|
PhoneNumber: phoneNumber,
|
||||||
|
}
|
||||||
|
mockRepo.On("GetUserByPhoneNumber", ctx, phoneNumber).Return(dbUser, nil).Once()
|
||||||
|
},
|
||||||
|
expectedUser: &domain.User{
|
||||||
|
Uuid: testUuid.String(),
|
||||||
|
PhoneNumber: phoneNumber,
|
||||||
|
},
|
||||||
|
wantErr: false,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "user not found",
|
||||||
|
setupMock: func() {
|
||||||
|
mockRepo.On("GetUserByPhoneNumber", ctx, phoneNumber).Return(nil, nil).Once()
|
||||||
|
},
|
||||||
|
wantErr: true,
|
||||||
|
errType: domain.ErrUserNotFound{},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "repository error",
|
||||||
|
setupMock: func() {
|
||||||
|
mockRepo.On("GetUserByPhoneNumber", ctx, phoneNumber).Return(nil, assert.AnError).Once()
|
||||||
|
},
|
||||||
|
wantErr: true,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, tt := range tests {
|
||||||
|
t.Run(tt.name, func(t *testing.T) {
|
||||||
|
// Reset mock
|
||||||
|
mockRepo.ExpectedCalls = nil
|
||||||
|
tt.setupMock()
|
||||||
|
|
||||||
|
result, err := service.GetUserByPhoneNumber(ctx, phoneNumber)
|
||||||
|
|
||||||
|
if tt.wantErr {
|
||||||
|
assert.Error(t, err)
|
||||||
|
assert.Nil(t, result)
|
||||||
|
if tt.errType != nil {
|
||||||
|
assert.IsType(t, tt.errType, err)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
assert.NoError(t, err)
|
||||||
|
assert.Equal(t, tt.expectedUser, result)
|
||||||
|
}
|
||||||
|
|
||||||
|
mockRepo.AssertExpectations(t)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestUserService_GetUserByUuid(t *testing.T) {
|
||||||
|
mockRepo := &MockUserRepository{}
|
||||||
|
service := &userService{repo: mockRepo}
|
||||||
|
ctx := context.Background()
|
||||||
|
testUuid := uuid.New()
|
||||||
|
uuidString := testUuid.String()
|
||||||
|
phoneNumber := "+79161234567"
|
||||||
|
|
||||||
|
tests := []struct {
|
||||||
|
name string
|
||||||
|
setupMock func()
|
||||||
|
expectedUser *domain.User
|
||||||
|
wantErr bool
|
||||||
|
errType interface{}
|
||||||
|
}{
|
||||||
|
{
|
||||||
|
name: "user found",
|
||||||
|
setupMock: func() {
|
||||||
|
dbUser := &db.User{
|
||||||
|
Uuid: testUuid,
|
||||||
|
PhoneNumber: phoneNumber,
|
||||||
|
}
|
||||||
|
mockRepo.On("GetUserByUuid", ctx, uuidString).Return(dbUser, nil).Once()
|
||||||
|
},
|
||||||
|
expectedUser: &domain.User{
|
||||||
|
Uuid: uuidString,
|
||||||
|
PhoneNumber: phoneNumber,
|
||||||
|
},
|
||||||
|
wantErr: false,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "user not found",
|
||||||
|
setupMock: func() {
|
||||||
|
mockRepo.On("GetUserByUuid", ctx, uuidString).Return(nil, nil).Once()
|
||||||
|
},
|
||||||
|
wantErr: true,
|
||||||
|
errType: domain.ErrUserNotFound{},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "repository error",
|
||||||
|
setupMock: func() {
|
||||||
|
mockRepo.On("GetUserByUuid", ctx, uuidString).Return(nil, assert.AnError).Once()
|
||||||
|
},
|
||||||
|
wantErr: true,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, tt := range tests {
|
||||||
|
t.Run(tt.name, func(t *testing.T) {
|
||||||
|
// Reset mock
|
||||||
|
mockRepo.ExpectedCalls = nil
|
||||||
|
tt.setupMock()
|
||||||
|
|
||||||
|
result, err := service.GetUserByUuid(ctx, uuidString)
|
||||||
|
|
||||||
|
if tt.wantErr {
|
||||||
|
assert.Error(t, err)
|
||||||
|
assert.Nil(t, result)
|
||||||
|
if tt.errType != nil {
|
||||||
|
assert.IsType(t, tt.errType, err)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
assert.NoError(t, err)
|
||||||
|
assert.Equal(t, tt.expectedUser, result)
|
||||||
|
}
|
||||||
|
|
||||||
|
mockRepo.AssertExpectations(t)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestUserService_CreateUser(t *testing.T) {
|
||||||
|
mockRepo := &MockUserRepository{}
|
||||||
|
service := &userService{repo: mockRepo}
|
||||||
|
ctx := context.Background()
|
||||||
|
phoneNumber := "+79161234567"
|
||||||
|
testUuid := uuid.New()
|
||||||
|
|
||||||
|
tests := []struct {
|
||||||
|
name string
|
||||||
|
setupMock func()
|
||||||
|
expectedUser *domain.User
|
||||||
|
wantErr bool
|
||||||
|
}{
|
||||||
|
{
|
||||||
|
name: "user created successfully",
|
||||||
|
setupMock: func() {
|
||||||
|
dbUser := &db.User{
|
||||||
|
Uuid: testUuid,
|
||||||
|
PhoneNumber: phoneNumber,
|
||||||
|
}
|
||||||
|
mockRepo.On("CreateUser", ctx, phoneNumber).Return(dbUser, nil).Once()
|
||||||
|
},
|
||||||
|
expectedUser: &domain.User{
|
||||||
|
Uuid: testUuid.String(),
|
||||||
|
PhoneNumber: phoneNumber,
|
||||||
|
},
|
||||||
|
wantErr: false,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "repository error",
|
||||||
|
setupMock: func() {
|
||||||
|
mockRepo.On("CreateUser", ctx, phoneNumber).Return(nil, assert.AnError).Once()
|
||||||
|
},
|
||||||
|
wantErr: true,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, tt := range tests {
|
||||||
|
t.Run(tt.name, func(t *testing.T) {
|
||||||
|
// Reset mock
|
||||||
|
mockRepo.ExpectedCalls = nil
|
||||||
|
tt.setupMock()
|
||||||
|
|
||||||
|
result, err := service.CreateUser(ctx, phoneNumber)
|
||||||
|
|
||||||
|
if tt.wantErr {
|
||||||
|
assert.Error(t, err)
|
||||||
|
assert.Nil(t, result)
|
||||||
|
} else {
|
||||||
|
assert.NoError(t, err)
|
||||||
|
assert.Equal(t, tt.expectedUser, result)
|
||||||
|
}
|
||||||
|
|
||||||
|
mockRepo.AssertExpectations(t)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestUserService_VerifyUser(t *testing.T) {
|
||||||
|
mockRepo := &MockUserRepository{}
|
||||||
|
service := &userService{repo: mockRepo}
|
||||||
|
ctx := context.Background()
|
||||||
|
testUuid := uuid.New()
|
||||||
|
uuidString := testUuid.String()
|
||||||
|
phoneNumber := "+79161234567"
|
||||||
|
|
||||||
|
tests := []struct {
|
||||||
|
name string
|
||||||
|
setupMock func()
|
||||||
|
expectedUser *domain.User
|
||||||
|
wantErr bool
|
||||||
|
}{
|
||||||
|
{
|
||||||
|
name: "user verified successfully",
|
||||||
|
setupMock: func() {
|
||||||
|
dbUser := &db.User{
|
||||||
|
Uuid: testUuid,
|
||||||
|
PhoneNumber: phoneNumber,
|
||||||
|
}
|
||||||
|
mockRepo.On("VerifyUser", ctx, uuidString).Return(dbUser, nil).Once()
|
||||||
|
},
|
||||||
|
expectedUser: &domain.User{
|
||||||
|
Uuid: uuidString,
|
||||||
|
PhoneNumber: phoneNumber,
|
||||||
|
},
|
||||||
|
wantErr: false,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "repository error",
|
||||||
|
setupMock: func() {
|
||||||
|
mockRepo.On("VerifyUser", ctx, uuidString).Return(nil, assert.AnError).Once()
|
||||||
|
},
|
||||||
|
wantErr: true,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, tt := range tests {
|
||||||
|
t.Run(tt.name, func(t *testing.T) {
|
||||||
|
// Reset mock
|
||||||
|
mockRepo.ExpectedCalls = nil
|
||||||
|
tt.setupMock()
|
||||||
|
|
||||||
|
result, err := service.VerifyUser(ctx, uuidString)
|
||||||
|
|
||||||
|
if tt.wantErr {
|
||||||
|
assert.Error(t, err)
|
||||||
|
assert.Nil(t, result)
|
||||||
|
} else {
|
||||||
|
assert.NoError(t, err)
|
||||||
|
assert.Equal(t, tt.expectedUser, result)
|
||||||
|
}
|
||||||
|
|
||||||
|
mockRepo.AssertExpectations(t)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Test edge cases and error scenarios
|
||||||
|
func TestUserService_ErrorMessages(t *testing.T) {
|
||||||
|
mockRepo := &MockUserRepository{}
|
||||||
|
service := &userService{repo: mockRepo}
|
||||||
|
ctx := context.Background()
|
||||||
|
phoneNumber := "+79161234567"
|
||||||
|
|
||||||
|
t.Run("GetUserByPhoneNumber returns proper error message", func(t *testing.T) {
|
||||||
|
mockRepo.On("GetUserByPhoneNumber", ctx, phoneNumber).Return(nil, nil).Once()
|
||||||
|
|
||||||
|
_, err := service.GetUserByPhoneNumber(ctx, phoneNumber)
|
||||||
|
|
||||||
|
assert.Error(t, err)
|
||||||
|
userErr, ok := err.(domain.ErrUserNotFound)
|
||||||
|
assert.True(t, ok)
|
||||||
|
assert.Equal(t, phoneNumber, userErr.PhoneNumber)
|
||||||
|
assert.Contains(t, err.Error(), phoneNumber)
|
||||||
|
|
||||||
|
mockRepo.AssertExpectations(t)
|
||||||
|
})
|
||||||
|
}
|
||||||
58
internal/config/config.go
Normal file
58
internal/config/config.go
Normal file
@ -0,0 +1,58 @@
|
|||||||
|
package config
|
||||||
|
|
||||||
|
import (
|
||||||
|
"log"
|
||||||
|
|
||||||
|
"github.com/joho/godotenv"
|
||||||
|
"github.com/spf13/viper"
|
||||||
|
)
|
||||||
|
|
||||||
|
type Config struct {
|
||||||
|
App struct {
|
||||||
|
Port int
|
||||||
|
}
|
||||||
|
Redis struct {
|
||||||
|
Host string
|
||||||
|
Port int
|
||||||
|
DB int
|
||||||
|
Password string
|
||||||
|
}
|
||||||
|
Hydra struct {
|
||||||
|
Host string
|
||||||
|
Password string
|
||||||
|
}
|
||||||
|
DB struct {
|
||||||
|
Host string
|
||||||
|
Port int
|
||||||
|
User string
|
||||||
|
Password string
|
||||||
|
Dbname string
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewConfig() Config {
|
||||||
|
err := godotenv.Load()
|
||||||
|
if err != nil {
|
||||||
|
log.Println("Error loading .env file")
|
||||||
|
}
|
||||||
|
viper.SetConfigName("config")
|
||||||
|
viper.SetConfigType("yaml")
|
||||||
|
viper.AddConfigPath(".")
|
||||||
|
|
||||||
|
err = viper.ReadInConfig()
|
||||||
|
if err != nil {
|
||||||
|
log.Fatalf("Error reading config file, %s", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
viper.AutomaticEnv()
|
||||||
|
var config Config
|
||||||
|
|
||||||
|
_ = viper.BindEnv("redis.password", "REDIS_PASSWORD")
|
||||||
|
_ = viper.BindEnv("hydra.password", "HYDRA_PASSWORD")
|
||||||
|
|
||||||
|
err = viper.Unmarshal(&config)
|
||||||
|
if err != nil {
|
||||||
|
log.Fatalf("Unable to decode config into struct, %v", err)
|
||||||
|
}
|
||||||
|
return config
|
||||||
|
}
|
||||||
24
internal/db/database.go
Normal file
24
internal/db/database.go
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
package db
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"strconv"
|
||||||
|
|
||||||
|
"git.logidex.ru/fakz9/logidex-id/internal/config"
|
||||||
|
"github.com/jackc/pgx/v5/pgxpool"
|
||||||
|
)
|
||||||
|
|
||||||
|
func NewDatabasePool(cfg config.Config) *pgxpool.Pool {
|
||||||
|
ctx := context.Background()
|
||||||
|
connUrl := "postgresql://" + cfg.DB.User + ":" + cfg.DB.Password + "@" + cfg.DB.Host + ":" + strconv.Itoa(cfg.DB.Port) + "/" + cfg.DB.Dbname
|
||||||
|
|
||||||
|
pool, err := pgxpool.New(ctx, connUrl)
|
||||||
|
if err != nil {
|
||||||
|
panic("Failed to connect to database: " + err.Error())
|
||||||
|
}
|
||||||
|
err = pool.Ping(ctx)
|
||||||
|
if err != nil {
|
||||||
|
panic("Failed to ping database: " + err.Error())
|
||||||
|
}
|
||||||
|
return pool
|
||||||
|
}
|
||||||
15
internal/db/fx.go
Normal file
15
internal/db/fx.go
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
package db
|
||||||
|
|
||||||
|
import (
|
||||||
|
sqlcdb "git.logidex.ru/fakz9/logidex-id/internal/db/generated"
|
||||||
|
"go.uber.org/fx"
|
||||||
|
)
|
||||||
|
|
||||||
|
var Module = fx.Options(
|
||||||
|
fx.Provide(
|
||||||
|
fx.Annotate(
|
||||||
|
NewDatabasePool,
|
||||||
|
fx.As(new(sqlcdb.DBTX)),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
)
|
||||||
32
internal/db/generated/db.go
Normal file
32
internal/db/generated/db.go
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
// Code generated by sqlc. DO NOT EDIT.
|
||||||
|
// versions:
|
||||||
|
// sqlc v1.28.0
|
||||||
|
|
||||||
|
package db
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
|
||||||
|
"github.com/jackc/pgx/v5"
|
||||||
|
"github.com/jackc/pgx/v5/pgconn"
|
||||||
|
)
|
||||||
|
|
||||||
|
type DBTX interface {
|
||||||
|
Exec(context.Context, string, ...interface{}) (pgconn.CommandTag, error)
|
||||||
|
Query(context.Context, string, ...interface{}) (pgx.Rows, error)
|
||||||
|
QueryRow(context.Context, string, ...interface{}) pgx.Row
|
||||||
|
}
|
||||||
|
|
||||||
|
func New(db DBTX) *Queries {
|
||||||
|
return &Queries{db: db}
|
||||||
|
}
|
||||||
|
|
||||||
|
type Queries struct {
|
||||||
|
db DBTX
|
||||||
|
}
|
||||||
|
|
||||||
|
func (q *Queries) WithTx(tx pgx.Tx) *Queries {
|
||||||
|
return &Queries{
|
||||||
|
db: tx,
|
||||||
|
}
|
||||||
|
}
|
||||||
19
internal/db/generated/models.go
Normal file
19
internal/db/generated/models.go
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
// Code generated by sqlc. DO NOT EDIT.
|
||||||
|
// versions:
|
||||||
|
// sqlc v1.28.0
|
||||||
|
|
||||||
|
package db
|
||||||
|
|
||||||
|
import (
|
||||||
|
"time"
|
||||||
|
|
||||||
|
"github.com/google/uuid"
|
||||||
|
)
|
||||||
|
|
||||||
|
type User struct {
|
||||||
|
Uuid uuid.UUID `json:"uuid"`
|
||||||
|
PhoneNumber string `json:"phone_number"`
|
||||||
|
CreatedAt time.Time `json:"created_at"`
|
||||||
|
Verified bool `json:"verified"`
|
||||||
|
VerifiedAt *time.Time `json:"verified_at"`
|
||||||
|
}
|
||||||
20
internal/db/generated/querier.go
Normal file
20
internal/db/generated/querier.go
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
// Code generated by sqlc. DO NOT EDIT.
|
||||||
|
// versions:
|
||||||
|
// sqlc v1.28.0
|
||||||
|
|
||||||
|
package db
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
|
||||||
|
"github.com/google/uuid"
|
||||||
|
)
|
||||||
|
|
||||||
|
type Querier interface {
|
||||||
|
CreateUser(ctx context.Context, phoneNumber string) (User, error)
|
||||||
|
GetByPhoneNumber(ctx context.Context, phoneNumber string) (User, error)
|
||||||
|
GetUserByUUID(ctx context.Context, argUuid uuid.UUID) (User, error)
|
||||||
|
UpdateUserVerified(ctx context.Context, argUuid uuid.UUID) (User, error)
|
||||||
|
}
|
||||||
|
|
||||||
|
var _ Querier = (*Queries)(nil)
|
||||||
92
internal/db/generated/users.sql.go
Normal file
92
internal/db/generated/users.sql.go
Normal file
@ -0,0 +1,92 @@
|
|||||||
|
// Code generated by sqlc. DO NOT EDIT.
|
||||||
|
// versions:
|
||||||
|
// sqlc v1.28.0
|
||||||
|
// source: users.sql
|
||||||
|
|
||||||
|
package db
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
|
||||||
|
"github.com/google/uuid"
|
||||||
|
)
|
||||||
|
|
||||||
|
const createUser = `-- name: CreateUser :one
|
||||||
|
INSERT INTO users (phone_number)
|
||||||
|
VALUES ($1)
|
||||||
|
RETURNING uuid, phone_number, created_at, verified, verified_at
|
||||||
|
`
|
||||||
|
|
||||||
|
func (q *Queries) CreateUser(ctx context.Context, phoneNumber string) (User, error) {
|
||||||
|
row := q.db.QueryRow(ctx, createUser, phoneNumber)
|
||||||
|
var i User
|
||||||
|
err := row.Scan(
|
||||||
|
&i.Uuid,
|
||||||
|
&i.PhoneNumber,
|
||||||
|
&i.CreatedAt,
|
||||||
|
&i.Verified,
|
||||||
|
&i.VerifiedAt,
|
||||||
|
)
|
||||||
|
return i, err
|
||||||
|
}
|
||||||
|
|
||||||
|
const getByPhoneNumber = `-- name: GetByPhoneNumber :one
|
||||||
|
SELECT uuid, phone_number, created_at, verified, verified_at
|
||||||
|
FROM users
|
||||||
|
WHERE phone_number = $1
|
||||||
|
LIMIT 1
|
||||||
|
`
|
||||||
|
|
||||||
|
func (q *Queries) GetByPhoneNumber(ctx context.Context, phoneNumber string) (User, error) {
|
||||||
|
row := q.db.QueryRow(ctx, getByPhoneNumber, phoneNumber)
|
||||||
|
var i User
|
||||||
|
err := row.Scan(
|
||||||
|
&i.Uuid,
|
||||||
|
&i.PhoneNumber,
|
||||||
|
&i.CreatedAt,
|
||||||
|
&i.Verified,
|
||||||
|
&i.VerifiedAt,
|
||||||
|
)
|
||||||
|
return i, err
|
||||||
|
}
|
||||||
|
|
||||||
|
const getUserByUUID = `-- name: GetUserByUUID :one
|
||||||
|
SELECT uuid, phone_number, created_at, verified, verified_at
|
||||||
|
FROM users
|
||||||
|
WHERE uuid = $1
|
||||||
|
LIMIT 1
|
||||||
|
`
|
||||||
|
|
||||||
|
func (q *Queries) GetUserByUUID(ctx context.Context, argUuid uuid.UUID) (User, error) {
|
||||||
|
row := q.db.QueryRow(ctx, getUserByUUID, argUuid)
|
||||||
|
var i User
|
||||||
|
err := row.Scan(
|
||||||
|
&i.Uuid,
|
||||||
|
&i.PhoneNumber,
|
||||||
|
&i.CreatedAt,
|
||||||
|
&i.Verified,
|
||||||
|
&i.VerifiedAt,
|
||||||
|
)
|
||||||
|
return i, err
|
||||||
|
}
|
||||||
|
|
||||||
|
const updateUserVerified = `-- name: UpdateUserVerified :one
|
||||||
|
UPDATE users
|
||||||
|
SET verified = TRUE,
|
||||||
|
verified_at = CURRENT_TIMESTAMP
|
||||||
|
WHERE uuid = $1
|
||||||
|
RETURNING uuid, phone_number, created_at, verified, verified_at
|
||||||
|
`
|
||||||
|
|
||||||
|
func (q *Queries) UpdateUserVerified(ctx context.Context, argUuid uuid.UUID) (User, error) {
|
||||||
|
row := q.db.QueryRow(ctx, updateUserVerified, argUuid)
|
||||||
|
var i User
|
||||||
|
err := row.Scan(
|
||||||
|
&i.Uuid,
|
||||||
|
&i.PhoneNumber,
|
||||||
|
&i.CreatedAt,
|
||||||
|
&i.Verified,
|
||||||
|
&i.VerifiedAt,
|
||||||
|
)
|
||||||
|
return i, err
|
||||||
|
}
|
||||||
9
internal/db/migrations/001_init.sql
Normal file
9
internal/db/migrations/001_init.sql
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
CREATE TABLE IF NOT EXISTS users
|
||||||
|
(
|
||||||
|
uuid UUID PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
|
||||||
|
phone_number VARCHAR(20) NOT NULL CHECK (phone_number ~ '^\+[0-9]{10,15}$'),
|
||||||
|
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP NOT NULL,
|
||||||
|
verified BOOLEAN DEFAULT FALSE NOT NULL,
|
||||||
|
verified_at TIMESTAMP NULL
|
||||||
|
|
||||||
|
);
|
||||||
23
internal/db/queries/users.sql
Normal file
23
internal/db/queries/users.sql
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
-- name: GetByPhoneNumber :one
|
||||||
|
SELECT *
|
||||||
|
FROM users
|
||||||
|
WHERE phone_number = $1
|
||||||
|
LIMIT 1;
|
||||||
|
|
||||||
|
-- name: GetUserByUUID :one
|
||||||
|
SELECT *
|
||||||
|
FROM users
|
||||||
|
WHERE uuid = $1
|
||||||
|
LIMIT 1;
|
||||||
|
|
||||||
|
-- name: CreateUser :one
|
||||||
|
INSERT INTO users (phone_number)
|
||||||
|
VALUES ($1)
|
||||||
|
RETURNING *;
|
||||||
|
|
||||||
|
-- name: UpdateUserVerified :one
|
||||||
|
UPDATE users
|
||||||
|
SET verified = TRUE,
|
||||||
|
verified_at = CURRENT_TIMESTAMP
|
||||||
|
WHERE uuid = $1
|
||||||
|
RETURNING *;
|
||||||
17
internal/hydra_client/hydra_client.go
Normal file
17
internal/hydra_client/hydra_client.go
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
package hydra_client
|
||||||
|
|
||||||
|
import (
|
||||||
|
"git.logidex.ru/fakz9/logidex-id/internal/config"
|
||||||
|
hydraApi "github.com/ory/hydra-client-go"
|
||||||
|
)
|
||||||
|
|
||||||
|
func NewHydraClient(appConfig config.Config) *hydraApi.APIClient {
|
||||||
|
cfg := hydraApi.NewConfiguration()
|
||||||
|
cfg.AddDefaultHeader("X-Secret", appConfig.Hydra.Password)
|
||||||
|
cfg.Servers = []hydraApi.ServerConfiguration{
|
||||||
|
{
|
||||||
|
URL: appConfig.Hydra.Host,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
return hydraApi.NewAPIClient(cfg)
|
||||||
|
}
|
||||||
19
internal/phoneutil/phoneutil.go
Normal file
19
internal/phoneutil/phoneutil.go
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
package phoneutil
|
||||||
|
|
||||||
|
import (
|
||||||
|
"errors"
|
||||||
|
|
||||||
|
"github.com/nyaruka/phonenumbers"
|
||||||
|
)
|
||||||
|
|
||||||
|
func ParseAndFormatPhoneNumber(phoneNumber string) (string, error) {
|
||||||
|
parsedNumber, err := phonenumbers.Parse(phoneNumber, "RU")
|
||||||
|
if err != nil {
|
||||||
|
return "", err
|
||||||
|
}
|
||||||
|
result := phonenumbers.Format(parsedNumber, phonenumbers.E164)
|
||||||
|
if result == "" {
|
||||||
|
return "", errors.New("failed to format phone number")
|
||||||
|
}
|
||||||
|
return result, nil
|
||||||
|
}
|
||||||
129
internal/phoneutil/phoneutil_test.go
Normal file
129
internal/phoneutil/phoneutil_test.go
Normal file
@ -0,0 +1,129 @@
|
|||||||
|
package phoneutil
|
||||||
|
|
||||||
|
import (
|
||||||
|
"testing"
|
||||||
|
|
||||||
|
"github.com/stretchr/testify/assert"
|
||||||
|
)
|
||||||
|
|
||||||
|
func TestParseAndFormatPhoneNumber(t *testing.T) {
|
||||||
|
tests := []struct {
|
||||||
|
name string
|
||||||
|
phoneNumber string
|
||||||
|
want string
|
||||||
|
wantErr bool
|
||||||
|
}{
|
||||||
|
{
|
||||||
|
name: "valid russian phone number with +7",
|
||||||
|
phoneNumber: "+79161234567",
|
||||||
|
want: "+79161234567",
|
||||||
|
wantErr: false,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "valid russian phone number with 8",
|
||||||
|
phoneNumber: "89161234567",
|
||||||
|
want: "+79161234567",
|
||||||
|
wantErr: false,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "valid phone number with spaces",
|
||||||
|
phoneNumber: "+7 916 123 45 67",
|
||||||
|
want: "+79161234567",
|
||||||
|
wantErr: false,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "valid phone number with dashes",
|
||||||
|
phoneNumber: "+7-916-123-45-67",
|
||||||
|
want: "+79161234567",
|
||||||
|
wantErr: false,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "valid phone number with parentheses",
|
||||||
|
phoneNumber: "+7 (916) 123-45-67",
|
||||||
|
want: "+79161234567",
|
||||||
|
wantErr: false,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "valid moscow landline",
|
||||||
|
phoneNumber: "+7 495 123 45 67",
|
||||||
|
want: "+74951234567",
|
||||||
|
wantErr: false,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "russian mobile without country code",
|
||||||
|
phoneNumber: "9161234567",
|
||||||
|
want: "+79161234567",
|
||||||
|
wantErr: false,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "invalid phone number - too short",
|
||||||
|
phoneNumber: "1",
|
||||||
|
want: "",
|
||||||
|
wantErr: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "invalid phone number - too long",
|
||||||
|
phoneNumber: "+712345678901234567890",
|
||||||
|
want: "",
|
||||||
|
wantErr: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "empty phone number",
|
||||||
|
phoneNumber: "",
|
||||||
|
want: "",
|
||||||
|
wantErr: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "invalid characters",
|
||||||
|
phoneNumber: "+7abc1234567",
|
||||||
|
want: "",
|
||||||
|
wantErr: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "only spaces",
|
||||||
|
phoneNumber: " ",
|
||||||
|
want: "",
|
||||||
|
wantErr: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "us phone number should work with ru default",
|
||||||
|
phoneNumber: "+12345678901",
|
||||||
|
want: "+12345678901",
|
||||||
|
wantErr: false,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, tt := range tests {
|
||||||
|
t.Run(tt.name, func(t *testing.T) {
|
||||||
|
got, err := ParseAndFormatPhoneNumber(tt.phoneNumber)
|
||||||
|
|
||||||
|
if tt.wantErr {
|
||||||
|
assert.Error(t, err, "ParseAndFormatPhoneNumber() should return error")
|
||||||
|
assert.Empty(t, got, "ParseAndFormatPhoneNumber() should return empty string on error")
|
||||||
|
} else {
|
||||||
|
assert.NoError(t, err, "ParseAndFormatPhoneNumber() should not return error")
|
||||||
|
assert.Equal(t, tt.want, got, "ParseAndFormatPhoneNumber() result mismatch")
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestParseAndFormatPhoneNumber_ErrorHandling(t *testing.T) {
|
||||||
|
// Test specific error cases
|
||||||
|
testCases := []struct {
|
||||||
|
name string
|
||||||
|
phoneNumber string
|
||||||
|
}{
|
||||||
|
{"nil input", ""},
|
||||||
|
{"invalid format", "not-a-phone-number"},
|
||||||
|
{"incomplete number", "+7"},
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, tc := range testCases {
|
||||||
|
t.Run(tc.name, func(t *testing.T) {
|
||||||
|
result, err := ParseAndFormatPhoneNumber(tc.phoneNumber)
|
||||||
|
assert.Error(t, err)
|
||||||
|
assert.Empty(t, result)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
21
internal/redis/client.go
Normal file
21
internal/redis/client.go
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
package redis
|
||||||
|
|
||||||
|
import (
|
||||||
|
"strconv"
|
||||||
|
|
||||||
|
"git.logidex.ru/fakz9/logidex-id/internal/config"
|
||||||
|
"github.com/redis/rueidis"
|
||||||
|
)
|
||||||
|
|
||||||
|
func NewRedisClient(cfg config.Config) rueidis.Client {
|
||||||
|
var err error
|
||||||
|
client, err := rueidis.NewClient(rueidis.ClientOption{
|
||||||
|
// Set the address of your Redis server
|
||||||
|
InitAddress: []string{cfg.Redis.Host + ":" + strconv.Itoa(cfg.Redis.Port)},
|
||||||
|
Password: cfg.Redis.Password,
|
||||||
|
})
|
||||||
|
if err != nil {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
return client
|
||||||
|
}
|
||||||
12
internal/server/fx.go
Normal file
12
internal/server/fx.go
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
package server
|
||||||
|
|
||||||
|
import "go.uber.org/fx"
|
||||||
|
|
||||||
|
// Module provides the server dependencies and lifecycle management
|
||||||
|
var Module = fx.Options(
|
||||||
|
fx.Provide(
|
||||||
|
NewFiberApp,
|
||||||
|
NewAPIRouter,
|
||||||
|
),
|
||||||
|
fx.Invoke(StartServer),
|
||||||
|
)
|
||||||
75
internal/server/server.go
Normal file
75
internal/server/server.go
Normal file
@ -0,0 +1,75 @@
|
|||||||
|
package server
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"strconv"
|
||||||
|
|
||||||
|
"git.logidex.ru/fakz9/logidex-id/internal/config"
|
||||||
|
"github.com/gofiber/fiber/v2"
|
||||||
|
"github.com/gofiber/fiber/v2/middleware/cors"
|
||||||
|
fiberlogger "github.com/gofiber/fiber/v2/middleware/logger"
|
||||||
|
"github.com/gofiber/fiber/v2/middleware/recover"
|
||||||
|
"go.uber.org/fx"
|
||||||
|
)
|
||||||
|
|
||||||
|
// NewFiberApp creates a new Fiber application with common middleware
|
||||||
|
func NewFiberApp(cfg config.Config) *fiber.App {
|
||||||
|
app := fiber.New(fiber.Config{
|
||||||
|
AppName: "Logidex ID API",
|
||||||
|
ServerHeader: "Logidex ID",
|
||||||
|
ErrorHandler: func(c *fiber.Ctx, err error) error {
|
||||||
|
code := fiber.StatusInternalServerError
|
||||||
|
if e, ok := err.(*fiber.Error); ok {
|
||||||
|
code = e.Code
|
||||||
|
}
|
||||||
|
|
||||||
|
return c.Status(code).JSON(fiber.Map{
|
||||||
|
"error": true,
|
||||||
|
"message": err.Error(),
|
||||||
|
})
|
||||||
|
},
|
||||||
|
})
|
||||||
|
|
||||||
|
// Add middleware
|
||||||
|
app.Use(recover.New())
|
||||||
|
app.Use(fiberlogger.New(fiberlogger.Config{
|
||||||
|
Format: "[${time}] ${status} - ${latency} ${method} ${path}\n",
|
||||||
|
}))
|
||||||
|
app.Use(cors.New(cors.Config{
|
||||||
|
AllowOrigins: "*",
|
||||||
|
AllowMethods: "GET,POST,HEAD,PUT,DELETE,PATCH,OPTIONS",
|
||||||
|
AllowHeaders: "Origin,Content-Type,Accept,Authorization",
|
||||||
|
}))
|
||||||
|
|
||||||
|
// Health check endpoint
|
||||||
|
app.Get("/health", func(c *fiber.Ctx) error {
|
||||||
|
return c.JSON(fiber.Map{
|
||||||
|
"status": "ok",
|
||||||
|
"service": "logidex-id-api",
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
return app
|
||||||
|
}
|
||||||
|
|
||||||
|
// NewAPIRouter creates the main API router group
|
||||||
|
func NewAPIRouter(app *fiber.App) fiber.Router {
|
||||||
|
return app.Group("/api")
|
||||||
|
}
|
||||||
|
|
||||||
|
// StartServer handles the server lifecycle
|
||||||
|
func StartServer(lifecycle fx.Lifecycle, app *fiber.App, cfg config.Config) {
|
||||||
|
lifecycle.Append(fx.Hook{
|
||||||
|
OnStart: func(ctx context.Context) error {
|
||||||
|
go func() {
|
||||||
|
addr := ":" + strconv.Itoa(cfg.App.Port)
|
||||||
|
if err := app.Listen(addr); err != nil {
|
||||||
|
}
|
||||||
|
}()
|
||||||
|
return nil
|
||||||
|
},
|
||||||
|
OnStop: func(ctx context.Context) error {
|
||||||
|
return app.Shutdown()
|
||||||
|
},
|
||||||
|
})
|
||||||
|
}
|
||||||
48
internal/server/server_test.go
Normal file
48
internal/server/server_test.go
Normal file
@ -0,0 +1,48 @@
|
|||||||
|
package server
|
||||||
|
|
||||||
|
import (
|
||||||
|
"net/http/httptest"
|
||||||
|
"testing"
|
||||||
|
|
||||||
|
"git.logidex.ru/fakz9/logidex-id/internal/config"
|
||||||
|
"github.com/gofiber/fiber/v2"
|
||||||
|
"github.com/stretchr/testify/assert"
|
||||||
|
)
|
||||||
|
|
||||||
|
func TestNewFiberApp(t *testing.T) {
|
||||||
|
cfg := config.Config{}
|
||||||
|
cfg.App.Port = 8080
|
||||||
|
|
||||||
|
app := NewFiberApp(cfg)
|
||||||
|
|
||||||
|
assert.NotNil(t, app)
|
||||||
|
|
||||||
|
// Test health check endpoint
|
||||||
|
req := httptest.NewRequest("GET", "/health", nil)
|
||||||
|
resp, err := app.Test(req)
|
||||||
|
|
||||||
|
assert.NoError(t, err)
|
||||||
|
assert.Equal(t, 200, resp.StatusCode)
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestNewAPIRouter(t *testing.T) {
|
||||||
|
cfg := config.Config{}
|
||||||
|
cfg.App.Port = 8080
|
||||||
|
|
||||||
|
app := NewFiberApp(cfg)
|
||||||
|
router := NewAPIRouter(app)
|
||||||
|
|
||||||
|
assert.NotNil(t, router)
|
||||||
|
|
||||||
|
// Test that we can add routes to the router
|
||||||
|
router.Get("/test", func(c *fiber.Ctx) error {
|
||||||
|
return c.JSON(map[string]string{"message": "test"})
|
||||||
|
})
|
||||||
|
|
||||||
|
// Test the route works
|
||||||
|
req := httptest.NewRequest("GET", "/api/test", nil)
|
||||||
|
resp, err := app.Test(req)
|
||||||
|
|
||||||
|
assert.NoError(t, err)
|
||||||
|
assert.Equal(t, 200, resp.StatusCode)
|
||||||
|
}
|
||||||
16
openapi.yaml
Normal file
16
openapi.yaml
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
openapi: 3.0.0
|
||||||
|
info:
|
||||||
|
title: Logidex ID API
|
||||||
|
version: 1.0.0
|
||||||
|
|
||||||
|
paths:
|
||||||
|
$ref: './api/auth/api.yaml#/paths'
|
||||||
|
|
||||||
|
|
||||||
|
components:
|
||||||
|
schemas:
|
||||||
|
$ref: './api/auth/api.yaml#/components/schemas'
|
||||||
|
|
||||||
|
tags:
|
||||||
|
- name: auth
|
||||||
|
description: Authentication operations
|
||||||
35
sqlc.yaml
Normal file
35
sqlc.yaml
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
version: "2"
|
||||||
|
sql:
|
||||||
|
- engine: postgresql
|
||||||
|
schema: "internal/db/migrations"
|
||||||
|
queries: "internal/db/queries"
|
||||||
|
gen:
|
||||||
|
go:
|
||||||
|
package: "db"
|
||||||
|
out: "internal/db/generated"
|
||||||
|
sql_package: "pgx/v5"
|
||||||
|
emit_interface: true
|
||||||
|
emit_json_tags: true
|
||||||
|
emit_pointers_for_null_types: true
|
||||||
|
overrides:
|
||||||
|
# Timestamp
|
||||||
|
- db_type: "pg_catalog.timestamp"
|
||||||
|
nullable: true
|
||||||
|
go_type:
|
||||||
|
import: "time"
|
||||||
|
type: "Time"
|
||||||
|
pointer: true
|
||||||
|
- db_type: "pg_catalog.timestamp"
|
||||||
|
go_type: "time.Time"
|
||||||
|
# UUID
|
||||||
|
- db_type: "uuid"
|
||||||
|
go_type:
|
||||||
|
import: "github.com/google/uuid"
|
||||||
|
type: "UUID"
|
||||||
|
- db_type: "uuid"
|
||||||
|
nullable: true
|
||||||
|
go_type:
|
||||||
|
import: "github.com/google/uuid"
|
||||||
|
type: "UUID"
|
||||||
|
pointer: true
|
||||||
|
|
||||||
44
test.env
Normal file
44
test.env
Normal file
@ -0,0 +1,44 @@
|
|||||||
|
# Test Environment Configuration
|
||||||
|
# This file contains configuration for running tests
|
||||||
|
|
||||||
|
# Test Database Configuration
|
||||||
|
TEST_DB_HOST=localhost
|
||||||
|
TEST_DB_PORT=5432
|
||||||
|
TEST_DB_NAME=logidex_test
|
||||||
|
TEST_DB_USER=test_user
|
||||||
|
TEST_DB_PASSWORD=test_password
|
||||||
|
TEST_DB_SSL_MODE=disable
|
||||||
|
|
||||||
|
# Test Redis Configuration
|
||||||
|
TEST_REDIS_HOST=localhost
|
||||||
|
TEST_REDIS_PORT=6379
|
||||||
|
TEST_REDIS_PASSWORD=
|
||||||
|
TEST_REDIS_DB=1
|
||||||
|
|
||||||
|
# Test Hydra Configuration
|
||||||
|
TEST_HYDRA_ADMIN_URL=http://localhost:4445
|
||||||
|
TEST_HYDRA_PUBLIC_URL=http://localhost:4444
|
||||||
|
|
||||||
|
# Test Environment Settings
|
||||||
|
TEST_LOG_LEVEL=debug
|
||||||
|
TEST_SERVER_PORT=8080
|
||||||
|
TEST_TIMEOUT=30s
|
||||||
|
|
||||||
|
# Mock Settings
|
||||||
|
ENABLE_MOCKS=true
|
||||||
|
MOCK_OTP_CODE=123456
|
||||||
|
MOCK_SMS_PROVIDER=true
|
||||||
|
|
||||||
|
# Test Feature Flags
|
||||||
|
ENABLE_INTEGRATION_TESTS=false
|
||||||
|
ENABLE_E2E_TESTS=false
|
||||||
|
ENABLE_LOAD_TESTS=false
|
||||||
|
|
||||||
|
# Test Timeouts
|
||||||
|
TEST_DEFAULT_TIMEOUT=30s
|
||||||
|
TEST_INTEGRATION_TIMEOUT=60s
|
||||||
|
TEST_E2E_TIMEOUT=120s
|
||||||
|
|
||||||
|
# Coverage Settings
|
||||||
|
TEST_COVERAGE_THRESHOLD=80
|
||||||
|
GENERATE_COVERAGE_REPORT=true
|
||||||
225
test/testutil/test_helpers.go
Normal file
225
test/testutil/test_helpers.go
Normal file
@ -0,0 +1,225 @@
|
|||||||
|
package testutil
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"fmt"
|
||||||
|
"testing"
|
||||||
|
"time"
|
||||||
|
|
||||||
|
"git.logidex.ru/fakz9/logidex-id/internal/api/user/domain"
|
||||||
|
"github.com/google/uuid"
|
||||||
|
"github.com/stretchr/testify/assert"
|
||||||
|
)
|
||||||
|
|
||||||
|
// TestContext creates a context with timeout for tests
|
||||||
|
func TestContext(t *testing.T) context.Context {
|
||||||
|
ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second)
|
||||||
|
t.Cleanup(cancel)
|
||||||
|
return ctx
|
||||||
|
}
|
||||||
|
|
||||||
|
// CreateTestUser creates a test user with default values
|
||||||
|
func CreateTestUser(t *testing.T) *domain.User {
|
||||||
|
return &domain.User{
|
||||||
|
Uuid: uuid.New().String(),
|
||||||
|
PhoneNumber: "+79161234567",
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// CreateTestUserWithPhone creates a test user with specified phone number
|
||||||
|
func CreateTestUserWithPhone(t *testing.T, phoneNumber string) *domain.User {
|
||||||
|
return &domain.User{
|
||||||
|
Uuid: uuid.New().String(),
|
||||||
|
PhoneNumber: phoneNumber,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// AssertValidUUID checks if a string is a valid UUID
|
||||||
|
func AssertValidUUID(t *testing.T, uuidStr string) {
|
||||||
|
_, err := uuid.Parse(uuidStr)
|
||||||
|
assert.NoError(t, err, "Expected valid UUID, got: %s", uuidStr)
|
||||||
|
}
|
||||||
|
|
||||||
|
// AssertValidPhoneNumber checks if a phone number follows expected format
|
||||||
|
func AssertValidPhoneNumber(t *testing.T, phoneNumber string) {
|
||||||
|
assert.NotEmpty(t, phoneNumber)
|
||||||
|
assert.True(t, len(phoneNumber) >= 10, "Phone number should be at least 10 characters")
|
||||||
|
assert.True(t, phoneNumber[0] == '+', "Phone number should start with +")
|
||||||
|
}
|
||||||
|
|
||||||
|
// TimeoutContext creates a context that times out after the specified duration
|
||||||
|
// Note: This function returns a context without a cancel function.
|
||||||
|
// Use TestContext(t) instead for proper cleanup in tests.
|
||||||
|
func TimeoutContext(timeout time.Duration) (context.Context, context.CancelFunc) {
|
||||||
|
return context.WithTimeout(context.Background(), timeout)
|
||||||
|
}
|
||||||
|
|
||||||
|
// ErrorsContain checks if an error contains a specific substring
|
||||||
|
func ErrorsContain(t *testing.T, err error, substring string) {
|
||||||
|
assert.Error(t, err)
|
||||||
|
assert.Contains(t, err.Error(), substring)
|
||||||
|
}
|
||||||
|
|
||||||
|
// AssertNoError is a helper that fails the test if error is not nil
|
||||||
|
func AssertNoError(t *testing.T, err error, msgAndArgs ...interface{}) {
|
||||||
|
assert.NoError(t, err, msgAndArgs...)
|
||||||
|
}
|
||||||
|
|
||||||
|
// AssertError is a helper that fails the test if error is nil
|
||||||
|
func AssertError(t *testing.T, err error, msgAndArgs ...interface{}) {
|
||||||
|
assert.Error(t, err, msgAndArgs...)
|
||||||
|
}
|
||||||
|
|
||||||
|
// StringPtr returns a pointer to a string value
|
||||||
|
func StringPtr(s string) *string {
|
||||||
|
return &s
|
||||||
|
}
|
||||||
|
|
||||||
|
// IntPtr returns a pointer to an int value
|
||||||
|
func IntPtr(i int) *int {
|
||||||
|
return &i
|
||||||
|
}
|
||||||
|
|
||||||
|
// BoolPtr returns a pointer to a bool value
|
||||||
|
func BoolPtr(b bool) *bool {
|
||||||
|
return &b
|
||||||
|
}
|
||||||
|
|
||||||
|
// TestPhoneNumbers contains various phone numbers for testing
|
||||||
|
var TestPhoneNumbers = struct {
|
||||||
|
ValidRussian string
|
||||||
|
ValidUS string
|
||||||
|
ValidUK string
|
||||||
|
Invalid string
|
||||||
|
Empty string
|
||||||
|
TooShort string
|
||||||
|
WithSpaces string
|
||||||
|
WithDashes string
|
||||||
|
WithParentheses string
|
||||||
|
}{
|
||||||
|
ValidRussian: "+79161234567",
|
||||||
|
ValidUS: "+12345678901",
|
||||||
|
ValidUK: "+441234567890",
|
||||||
|
Invalid: "not-a-phone",
|
||||||
|
Empty: "",
|
||||||
|
TooShort: "123",
|
||||||
|
WithSpaces: "+7 916 123 45 67",
|
||||||
|
WithDashes: "+7-916-123-45-67",
|
||||||
|
WithParentheses: "+7 (916) 123-45-67",
|
||||||
|
}
|
||||||
|
|
||||||
|
// TestUUIDs contains various UUIDs for testing
|
||||||
|
var TestUUIDs = struct {
|
||||||
|
Valid1 string
|
||||||
|
Valid2 string
|
||||||
|
Invalid string
|
||||||
|
Empty string
|
||||||
|
}{
|
||||||
|
Valid1: "123e4567-e89b-12d3-a456-426614174000",
|
||||||
|
Valid2: "987fcdeb-51a2-43d1-9f12-345678901234",
|
||||||
|
Invalid: "not-a-uuid",
|
||||||
|
Empty: "",
|
||||||
|
}
|
||||||
|
|
||||||
|
// TestErrors contains common test errors
|
||||||
|
var TestErrors = struct {
|
||||||
|
Generic error
|
||||||
|
NotFound error
|
||||||
|
Invalid error
|
||||||
|
Timeout error
|
||||||
|
}{
|
||||||
|
Generic: assert.AnError,
|
||||||
|
NotFound: domain.ErrUserNotFound{PhoneNumber: "+79161234567"},
|
||||||
|
Invalid: assert.AnError,
|
||||||
|
Timeout: context.DeadlineExceeded,
|
||||||
|
}
|
||||||
|
|
||||||
|
// CleanupFunc is a function that cleans up test resources
|
||||||
|
type CleanupFunc func()
|
||||||
|
|
||||||
|
// SetupTestEnvironment sets up a test environment and returns cleanup function
|
||||||
|
func SetupTestEnvironment(t *testing.T) CleanupFunc {
|
||||||
|
// This could set up test databases, Redis connections, etc.
|
||||||
|
// For now, it's a placeholder for future implementation
|
||||||
|
|
||||||
|
return func() {
|
||||||
|
// Cleanup resources
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// WaitFor waits for a condition to be true or timeout
|
||||||
|
func WaitFor(t *testing.T, condition func() bool, timeout time.Duration, message string) {
|
||||||
|
ticker := time.NewTicker(100 * time.Millisecond)
|
||||||
|
defer ticker.Stop()
|
||||||
|
|
||||||
|
timeoutChan := time.After(timeout)
|
||||||
|
|
||||||
|
for {
|
||||||
|
select {
|
||||||
|
case <-ticker.C:
|
||||||
|
if condition() {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
case <-timeoutChan:
|
||||||
|
t.Fatalf("Timeout waiting for condition: %s", message)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Eventually runs a function until it succeeds or times out
|
||||||
|
func Eventually(t *testing.T, fn func() error, timeout time.Duration, message string) {
|
||||||
|
ticker := time.NewTicker(100 * time.Millisecond)
|
||||||
|
defer ticker.Stop()
|
||||||
|
|
||||||
|
timeoutChan := time.After(timeout)
|
||||||
|
|
||||||
|
var lastErr error
|
||||||
|
for {
|
||||||
|
select {
|
||||||
|
case <-ticker.C:
|
||||||
|
if err := fn(); err == nil {
|
||||||
|
return
|
||||||
|
} else {
|
||||||
|
lastErr = err
|
||||||
|
}
|
||||||
|
case <-timeoutChan:
|
||||||
|
t.Fatalf("Timeout waiting for function to succeed: %s. Last error: %v", message, lastErr)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// ParallelTest runs a test function in parallel multiple times
|
||||||
|
func ParallelTest(t *testing.T, fn func(*testing.T), count int) {
|
||||||
|
for i := 0; i < count; i++ {
|
||||||
|
i := i // capture loop variable
|
||||||
|
t.Run(fmt.Sprintf("parallel_%d", i), func(t *testing.T) {
|
||||||
|
t.Parallel()
|
||||||
|
fn(t)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// BenchmarkHelper provides utilities for benchmark tests
|
||||||
|
type BenchmarkHelper struct {
|
||||||
|
b *testing.B
|
||||||
|
}
|
||||||
|
|
||||||
|
// NewBenchmarkHelper creates a new benchmark helper
|
||||||
|
func NewBenchmarkHelper(b *testing.B) *BenchmarkHelper {
|
||||||
|
return &BenchmarkHelper{b: b}
|
||||||
|
}
|
||||||
|
|
||||||
|
// ResetTimer resets the benchmark timer
|
||||||
|
func (bh *BenchmarkHelper) ResetTimer() {
|
||||||
|
bh.b.ResetTimer()
|
||||||
|
}
|
||||||
|
|
||||||
|
// StopTimer stops the benchmark timer
|
||||||
|
func (bh *BenchmarkHelper) StopTimer() {
|
||||||
|
bh.b.StopTimer()
|
||||||
|
}
|
||||||
|
|
||||||
|
// StartTimer starts the benchmark timer
|
||||||
|
func (bh *BenchmarkHelper) StartTimer() {
|
||||||
|
bh.b.StartTimer()
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user