-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
14 changed files
with
599 additions
and
32 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 |
---|---|---|
|
@@ -10,6 +10,24 @@ jobs: | |
PASSWORD: ctfer | ||
|
||
services: | ||
# chall-manager: | ||
# image: registry.dev1.ctfer-io.lab/ctferio/chall-manager:ci | ||
# ports: | ||
# - 9090:9090 | ||
# - 8081:8081 | ||
# credentials: | ||
# username: ${{ secrets.registry_user }} | ||
# password: ${{ secrets.registry_pass }} | ||
|
||
chall-manager: | ||
image: nicofgrx/chall-manager:ci | ||
ports: | ||
- 9090:9090 | ||
- 8081:8081 | ||
credentials: | ||
username: ${{ secrets.docker_username }} | ||
password: ${{ secrets.docker_password }} | ||
|
||
mariadb: | ||
image: mariadb:10.7.8 | ||
ports: | ||
|
@@ -46,19 +64,47 @@ jobs: | |
echo "Server did not respond within the allotted time. Exiting..." | ||
exit 1 | ||
fi | ||
- name: Wait for Chall-Manager server | ||
run: | | ||
max_attempts=60 | ||
base_url="http://localhost:9090/api/v1/challenge" | ||
for ((i=0; i<$max_attempts; i++)); do | ||
if curl --fail --silent --show-error "$base_url" >/dev/null; then | ||
echo "Server is up and running!" | ||
break | ||
else | ||
echo "Waiting for the server to respond... (attempt $((i+1)))" | ||
sleep 5 | ||
fi | ||
done | ||
if [ $i -eq $max_attempts ]; then | ||
echo "Server did not respond within the allotted time. Exiting..." | ||
exit 1 | ||
fi | ||
- name: Setup CTFd | ||
uses: ctfer-io/ctfd-setup@6184bab99f91c895dae9172ba30bce87ef10a120 # v1.1.9 | ||
with: | ||
url: 'http://ctfd:8000' | ||
appearance_name: CTFer.io | ||
appearance_description: CTFer.io plugin tests | ||
mode: teams | ||
mode: users # TODO add tests with teams | ||
admin_name: ${{ env.NAME }} | ||
admin_email: [email protected] | ||
admin_password: ${{ env.PASSWORD }} | ||
|
||
- name: Generate demo-deploy.zip for tests | ||
run: | | ||
cd hack | ||
zip -r ${{ github.workspace }}/demo-deploy.zip deploy | ||
- name: tests with cypress | ||
uses: cypress-io/github-action@f88a151c986cab2e339cdbede6a5c4468bb62c17 # v6.7.0 | ||
with: | ||
env: CTFD_NAME=${{ env.NAME }},CTFD_PASSWORD=${{ env.PASSWORD }},CTFD_URL="http://localhost:8000" | ||
uses: cypress-io/github-action@f88a151c986cab2e339cdbede6a5c4468bb62c17 # v6.7.0 | ||
env: | ||
CYPRESS_CTFD_NAME: ${{ env.NAME }} | ||
CYPRESS_CTFD_PASSWORD: ${{ env.PASSWORD }} | ||
CYPRESS_CTFD_URL: "http://localhost:8000" | ||
CYPRESS_SCENARIO_PATH: "${{ github.workspace }}/demo-deploy.zip" | ||
CYPRESS_PLUGIN_SETTINGS_CM_API_URL: "http://chall-manager:9090/api/v1" | ||
CYPRESS_PLUGIN_SETTINGS_CM_MANA_TOTAL: "50" |
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 |
---|---|---|
@@ -1,2 +1,3 @@ | ||
__pycache__ | ||
node_modules/ | ||
node_modules/ | ||
*.zip |
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
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,25 @@ | ||
describe('Verify that admin pages is available', () => { | ||
|
||
beforeEach(() => { | ||
cy.login(Cypress.env('CTFD_NAME'), Cypress.env('CTFD_PASSWORD')) | ||
}) | ||
|
||
it('Admin available', () => { | ||
cy.visit(`${Cypress.env("CTFD_URL")}/plugins/ctfd-chall-manager/admin/settings`) | ||
cy.visit(`${Cypress.env("CTFD_URL")}/plugins/ctfd-chall-manager/admin/instances`) | ||
cy.visit(`${Cypress.env("CTFD_URL")}/plugins/ctfd-chall-manager/admin/mana`) | ||
}) | ||
|
||
it('Configure CM', () => { | ||
cy.visit(`${Cypress.env("CTFD_URL")}/plugins/ctfd-chall-manager/admin/settings`) | ||
cy.get('[data-test-id="chall-manager:chall-manager_api_url"]') | ||
.clear() | ||
.type(Cypress.env("PLUGIN_SETTINGS_CM_API_URL")) | ||
|
||
cy.get('[data-test-id="chall-manager:chall-manager_mana_total"]') | ||
.clear() | ||
.type(Cypress.env("PLUGIN_SETTINGS_CM_MANA_TOTAL")) | ||
|
||
cy.get('[data-test-id="plugin-settings-submit"]').click() | ||
}) | ||
}) |
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,29 @@ | ||
describe('Dynamic IaC Challenge', () => { | ||
|
||
beforeEach(() => { | ||
cy.login(Cypress.env('CTFD_NAME'), Cypress.env('CTFD_PASSWORD')) | ||
}) | ||
|
||
|
||
it('Test all buttons for Users', () => { | ||
let label = generateRandomString(10) | ||
cy.create_challenge(label, "1", "Recreate", "timeout", "300", Cypress.env('SCENARIO_PATH')) | ||
cy.wait(5000) // wait ctfd to create challenge and redirect to edit sections | ||
cy.visit(`${Cypress.env("CTFD_URL")}/challenges`) | ||
cy.get("button").contains(label).click() | ||
|
||
// launch instance | ||
cy.get('[data-test-id="cm-button-boot"]').click() | ||
|
||
|
||
}) | ||
}) | ||
|
||
function generateRandomString(length) { | ||
const characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789'; | ||
let result = ''; | ||
for (let i = 0; i < length; i++) { | ||
result += characters.charAt(Math.floor(Math.random() * characters.length)); | ||
} | ||
return result; | ||
} |
This file was deleted.
Oops, something went wrong.
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,3 @@ | ||
name: no-sdk | ||
runtime: go | ||
description: A challenge scenario written without the SDK, while still compliant with the chall-manager API. |
Oops, something went wrong.