Skip to content

Commit

Permalink
client test depends on mock-api
Browse files Browse the repository at this point in the history
  • Loading branch information
gkostin1966 committed Nov 10, 2023
1 parent 4b5d541 commit 0629fcf
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 5 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ jobs:
fail-fast: false
matrix:
suite:
- 'app'
# - 'app'
- 'client-tests'
- 'test'
# - 'test'
ruby:
- '3.2.2'
# - '3.1.4'
Expand Down
4 changes: 4 additions & 0 deletions apache/client/test/lauth/api_client_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ TEST(ApiClient, allowed_by_mock_http_client) {
ApiClient api_client(std::move(client));

Request req {
.ip = "",
.uri = "",
.user = "authorized",
};

Expand All @@ -30,6 +32,8 @@ TEST(ApiClient, denied_by_mock_http_client) {
ApiClient api_client(std::move(client));

Request req {
.ip = "",
.uri = "",
.user = "unauthorized",
};

Expand Down
8 changes: 6 additions & 2 deletions apache/client/test/lauth/authorizer_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@ TEST(AuthorizerTest, AllowsAccessWhenApiSaysAuthorized) {
Authorizer authorizer(std::move(client));

Request req {
.user = "lauth-allowed"
.ip = "",
.uri = "",
.user = "lauth-allowed",
};
auto allowed = authorizer.isAllowed(req);

Expand All @@ -35,7 +37,9 @@ TEST(AuthorizerTest, DeniesAccessWhenApiSaysUnauthorized) {
Authorizer authorizer(std::move(client));

Request req {
.user = "lauth-denied"
.ip = "",
.uri = "",
.user = "lauth-denied",
};
auto allowed = authorizer.isAllowed(req);

Expand Down
13 changes: 12 additions & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -88,17 +88,28 @@ services:
- build_cache:/lauth/apache/build

mock-api:
profiles: [ "integration" ]
profiles: [ "test", "integration" ]
build:
context: ./
dockerfile: ./apache/Dockerfile
target: tests
ports:
- "127.0.0.1:9000:9000"
healthcheck:
test: [ "CMD", "curl", "--fail", "http://127.0.0.1:9000", "--output", "/dev/null", "--silent" ]
interval: "10s"
timeout: "10s"
retries: 3
start_period: "2s"
start_interval: "1s"
command: ["./http-service", "9000"]

client-tests:
profiles: [ "test" ]
depends_on:
mock-api:
condition:
"service_healthy"
build:
context: ./
dockerfile: ./apache/Dockerfile
Expand Down

0 comments on commit 0629fcf

Please sign in to comment.