-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add tests of the bundle web server with no auth and with a 'fixed' auth configuration. Exercise cases where the user provides no credentials, incorrect credentials, and correct credentials and the expected bundle server responses for each. Signed-off-by: Victoria Dye <[email protected]>
- Loading branch information
Showing
5 changed files
with
113 additions
and
3 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
Feature: Auth configuration on the web server | ||
|
||
Background: The bundle server has an initialized route | ||
Given no bundle server repository exists at route 'integration/auth' | ||
Given a new remote repository with main branch 'main' | ||
Given the remote is cloned | ||
Given 5 commits are pushed to the remote branch 'main' | ||
Given a bundle server repository is created at route 'integration/auth' for the remote | ||
|
||
Scenario: With no auth config, bundle list can be accessed anonymously | ||
Given the bundle web server was started at port 8080 | ||
When I request the bundle list | ||
Then the response code is 200 | ||
Then the response is a valid bundle list | ||
|
||
Scenario: If basic auth is required but none is sent, get a 401 | ||
Given an auth config with username 'my_username' and password 'p4sSW0rD!' | ||
Given the bundle web server was started at port 8080 with auth config | ||
When I request the bundle list | ||
Then the response code is 401 | ||
Then the response is empty | ||
|
||
Scenario: If basic auth is required and we send bad credentials, get a 404 | ||
Given an auth config with username 'my_username' and password 'p4sSW0rD!' | ||
Given the bundle web server was started at port 8080 with auth config | ||
When I request the bundle list with username 'my_userName' and password 'password!' | ||
Then the response code is 404 | ||
Then the response is empty | ||
|
||
Scenario: If basic auth is required and we send the right credentials, can access the bundle list | ||
Given an auth config with username 'my_username' and password 'p4sSW0rD!' | ||
Given the bundle web server was started at port 8080 with auth config | ||
When I request the bundle list with username 'my_username' and password 'p4sSW0rD!' | ||
Then the response code is 200 | ||
Then the response is a valid bundle list |
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,24 @@ | ||
import { IntegrationBundleServerWorld } from '../support/world' | ||
import { Given } from '@cucumber/cucumber' | ||
import * as fs from 'fs' | ||
import * as path from 'path' | ||
import * as crypto from 'crypto'; | ||
|
||
Given('an auth config with username {string} and password {string}', | ||
async function (this: IntegrationBundleServerWorld, user: string, pass: string) { | ||
const config = { | ||
"mode": "fixed", | ||
"parameters": { | ||
"username": user, | ||
"passwordHash": crypto.createHash('sha256').update(pass).digest('hex') | ||
} | ||
} | ||
fs.writeFileSync(path.join(this.trashDirectory, "auth-config.json"), JSON.stringify(config)) | ||
} | ||
) | ||
|
||
Given('the bundle web server was started at port {int} with auth config', | ||
async function (this: IntegrationBundleServerWorld, port: number) { | ||
await this.bundleServer.startWebServer(port, path.join(this.trashDirectory, "auth-config.json")) | ||
} | ||
) |
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