-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1671 from weather-gov/jt/outside-testing
"outside" testing proof of concept
- Loading branch information
Showing
6 changed files
with
149 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
services: | ||
drupal-test: | ||
extends: | ||
file: ./docker-compose.yml | ||
service: drupal | ||
ports: !override | ||
- 9080:80 | ||
links: !override | ||
- database-test | ||
- api-proxy-test | ||
environment: # we want to extend, not override | ||
API_URL: http://api-proxy-test:9081 | ||
DRUPAL_DB_HOST: database-test | ||
profiles: !override ["test"] | ||
|
||
database-test: | ||
extends: | ||
file: ./docker-compose.yml | ||
service: database | ||
ports: !override | ||
- 4306:3306 | ||
profiles: !override ["test"] | ||
|
||
api-proxy-test: | ||
extends: | ||
file: ./docker-compose.yml | ||
service: api-proxy | ||
ports: !override | ||
- 9081:8081 | ||
profiles: !override ["test"] | ||
|
||
spatial-test: | ||
extends: | ||
file: ./docker-compose.yml | ||
service: spatial | ||
links: !override | ||
- database-test | ||
environment: | ||
DB_HOST: database-test | ||
profiles: !override ["test"] | ||
|
||
networks: | ||
weather.gov: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
const { test, expect } = require("@playwright/test"); | ||
|
||
const { describe } = test; | ||
|
||
const API_ENDPOINT = "http://localhost:9080/jsonapi"; | ||
|
||
describe("API tests", () => { | ||
test("users without credentials cannot get an API listing", async ({ | ||
request, | ||
}) => { | ||
const response = await request.get(API_ENDPOINT); | ||
expect(response.ok()).not.toBeTruthy(); | ||
const json = await response.json(); | ||
expect(json).toHaveProperty("errors"); | ||
expect(json).toMatchObject({ | ||
errors: [ | ||
{ | ||
detail: "No authentication credentials provided.", | ||
title: "Unauthorized", | ||
status: "401", | ||
}, | ||
], | ||
}); | ||
}); | ||
|
||
test("anonymous users cannot get an API listing", async ({ request }) => { | ||
const response = await request.get(API_ENDPOINT, { | ||
headers: { | ||
Authorization: `Basic ${btoa("foo:foo")}`, | ||
}, | ||
}); | ||
expect(response.ok()).not.toBeTruthy(); | ||
const json = await response.json(); | ||
expect(json).toHaveProperty("errors"); | ||
expect(json).toMatchObject({ | ||
errors: [ | ||
{ | ||
title: "Forbidden", | ||
status: "403", | ||
}, | ||
], | ||
}); | ||
}); | ||
|
||
test("uploader can see the API listing", async ({ request }) => { | ||
const response = await request.get(API_ENDPOINT, { | ||
headers: { | ||
Authorization: `Basic ${btoa("uploader:testpass")}`, | ||
}, | ||
}); | ||
expect(response.ok()).toBeTruthy(); | ||
const json = await response.json(); | ||
expect(json).not.toHaveProperty("errors"); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -euxo pipefail | ||
|
||
docker compose exec drupal-test drush user:create uploader --mail='testuser@noaa.com' --password='testpass' | ||
docker compose exec drupal-test drush user:role:add 'uploader' uploader |