Skip to content

Commit

Permalink
Update e2e tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Zorin95670 committed Aug 28, 2024
1 parent 763bc2e commit 1d93e05
Show file tree
Hide file tree
Showing 6 changed files with 75 additions and 7 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ jobs:
- name: Build application
run: docker build -t leto-modelizer-api .
- name: Run application
run: docker compose up -d
run: docker compose up -f docker-compose-e2e.yml -d
env:
GITHUB_CLIENT_ID: test
GITHUB_CLIENT_SECRET: test
Expand Down
54 changes: 54 additions & 0 deletions docker-compose-e2e.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
services:
libraries:
image: nginx:latest
ports:
- "8000:80"
volumes:
- ./src/test/resources/libraries:/usr/share/nginx/html:ro
- ./nginx_lib_dev.conf:/etc/nginx/conf.d/default.conf:ro
restart: always
ai:
build: ./src/test/resources/ai
ports:
- "8001:80"
volumes:
- ./src/test/resources/ai:/var/www/html
restart: always
db:
image: cockroachdb/cockroach:v23.1.15
command: start-single-node --certs-dir=/certs --advertise-addr=db
volumes:
- ./init-db.sql:/docker-entrypoint-initdb.d/init-db.sql
- ./cockroach-certs:/certs
ports:
- "26257:26257"
- "8081:8080"
restart: always
api:
restart: always
image: leto-modelizer-api:latest
environment:
DATABASE_HOST: db:26257
AI_HOST: http://ai/api/
GITHUB_CLIENT_ID: ${GITHUB_CLIENT_ID}
GITHUB_CLIENT_SECRET: ${GITHUB_CLIENT_SECRET}
LIBRARY_HOST_WHITELIST: http://libraries/
SUPER_ADMINISTRATOR_LOGIN: ${SUPER_ADMINISTRATOR_LOGIN}
POSTGRES_DB: ${POSTGRES_DB:-leto_db}
POSTGRES_USER: ${POSTGRES_USER:-leto_admin}
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:-password}
DATABASE_NAME: ${DATABASE_NAME:-leto_db}
DATABASE_USER: ${DATABASE_USER:-leto_admin}
DATABASE_PASSWORD: ${DATABASE_PASSWORD:-password}
SSL_KEY_STORE: ${SSL_KEY_STORE:-classpath:keystore.jks}
SSL_KEY_STORE_PASSWORD: ${SSL_KEY_STORE_PASSWORD:-password}
SSL_KEY_PASSWORD: ${SSL_KEY_PASSWORD:-password}
LETO_MODELIZER_URL: ${LETO_MODELIZER_URL:-http://localhost:8080/}
LETO_ADMIN_URL: ${LETO_ADMIN_URL:-http://localhost:9000/}
CSRF_TOKEN_TIMEOUT: ${CSRF_TOKEN_TIMEOUT:-3600}
USER_SESSION_TIMEOUT: ${USER_SESSION_TIMEOUT:-3600}

ports:
- "8443:8443"
depends_on:
- db
Original file line number Diff line number Diff line change
Expand Up @@ -359,6 +359,11 @@ public void expectResponseTypeIs(String type) {
}
}

@Then("I expect response is {string}")
public void expectResponseIsEqualsTo(String value) {
assertEquals(json.toString(), value);
}

@Then("I expect response resources value is {string}")
public void expectResponseIs(String value) {
assertEquals(resources.toString(), value);
Expand Down
5 changes: 1 addition & 4 deletions src/test/resources/ai/diagram_terrator-plugin.json
Original file line number Diff line number Diff line change
@@ -1,4 +1 @@
[{
"name": "main.tf",
"content": "provider \"aws\" {\n region = \"us-west-2\"\n}\n\nresource \"aws_instance\" \"example\" {\n ami = \"ami-0c55b159cbfafe1f0\"\n instance_type = \"t2.micro\"\n}"
}]
[{"name":"main.tf","content":"provider \"aws\" {}"}]
4 changes: 2 additions & 2 deletions src/test/resources/ai/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
error_log($type);
error_log(file_get_contents('php://input'));

if ($type && isset($requestBody['plugin'])) {
$fileName = "{$type}_{$requestBody['plugin']}.json";
if ($type && isset($requestBody['pluginName'])) {
$fileName = "{$type}_{$requestBody['pluginName']}.json";
error_log($fileName);

if (file_exists($fileName)) {
Expand Down
12 changes: 12 additions & 0 deletions src/test/resources/features/AI.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
Feature: ai feature

Scenario: Should return 201 on a valid ai diagram creation
Given I initialize the admin user

When I request "/ai" with method "POST" with json
| key | value |
| plugin | terrator-plugin |
| type | diagram |
| description | Test diagram creation |
Then I expect "201" as status code
And I expect response is '[{"name":"main.tf","content":"provider \\"aws\\" {}"}]'

0 comments on commit 1d93e05

Please sign in to comment.