-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ci: defer setup to ctfer-io/ctfd-setup action
- Loading branch information
Showing
2 changed files
with
26 additions
and
27 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 |
---|---|---|
|
@@ -17,6 +17,9 @@ jobs: | |
image: ctfd/ctfd:3.7.0@sha256:e4e886aa8f1051eeddcabe2115bc9a5f380be2b54034d5a119c44b177d6b8c57 | ||
ports: | ||
- 8000:8000 | ||
env: | ||
NAME: ctfer | ||
PASSWORD: password | ||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6 | ||
|
@@ -52,9 +55,22 @@ jobs: | |
fi | ||
- name: Setup CTFd | ||
run: go run cmd/setup/main.go | ||
uses: ctfer-io/ctfd-setup@dc0b1f042a99b5a4abc04e69e850f483ca139557 # v1.1.8 | ||
with: | ||
url: http://localhost:8000 | ||
appearance_name: TFP-CTFd | ||
appearance_description: Terraform Provider CTFd. | ||
mode: teams | ||
admin_name: ${{ env.NAME }} | ||
admin_email: [email protected] | ||
admin_password: ${{ env.PASSWORD }} | ||
|
||
- name: Generate token | ||
run: go run cmd/token/main.go | ||
env: | ||
CTFD_URL: http://localhost:8000 | ||
CTFD_NAME: ${{ env.NAME }} | ||
CTFD_PASSWORD: ${{ env.PASSWORD }} | ||
|
||
- name: Run go acceptance tests | ||
run: make test-acc | ||
|
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 |
---|---|---|
|
@@ -8,44 +8,27 @@ import ( | |
"github.com/ctfer-io/go-ctfd/api" | ||
) | ||
|
||
// This utility setup a brand new CTFd instance for acceptance testing of the provider, | ||
// This utility login to a CTFd instance for acceptance testing of the provider, | ||
// and creates an API key ready to work. | ||
|
||
func main() { | ||
url := os.Getenv("CTFD_URL") | ||
name := os.Getenv("CTFD_NAME") | ||
password := os.Getenv("CTFD_PASSWORD") | ||
|
||
// Note: add /setup so won't have to follow redirect | ||
fmt.Println("[+] Getting initial nonce and session values") | ||
nonce, session, err := api.GetNonceAndSession(url) | ||
if err != nil { | ||
log.Fatalf("Getting nonce and session: %s", err) | ||
} | ||
|
||
// Setup CTFd | ||
fmt.Println("[+] Setting up CTFd") | ||
client := api.NewClient(url, nonce, session, "") | ||
if err := client.Setup(&api.SetupParams{ | ||
CTFName: "TFP-CTFd", | ||
CTFDescription: "Terraform Provider CTFd.", | ||
UserMode: "teams", | ||
Name: "ctfer", | ||
Email: "[email protected]", | ||
Password: "ctfer", | ||
ChallengeVisibility: "public", | ||
AccountVisibility: "public", | ||
ScoreVisibility: "public", | ||
RegistrationVisibility: "public", | ||
VerifyEmails: false, | ||
TeamSize: nil, | ||
CTFLogo: nil, | ||
CTFBanner: nil, | ||
CTFSmallIcon: nil, | ||
CTFTheme: "core", | ||
ThemeColor: "", | ||
Start: "", | ||
End: "", | ||
|
||
fmt.Println("[+] Logging in") | ||
if err := client.Login(&api.LoginParams{ | ||
Name: name, | ||
Password: password, | ||
}); err != nil { | ||
log.Fatalf("Setting up CTFd: %s", err) | ||
log.Fatalf("Logging in: %s", err) | ||
} | ||
|
||
// Create API Key | ||
|