-
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
9 changed files
with
197 additions
and
34 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 |
---|---|---|
|
@@ -29,4 +29,4 @@ jobs: | |
${{ runner.os }}-go- | ||
- name: Run tests | ||
run: make test | ||
run: make test test-e2e |
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,59 @@ | ||
#!/usr/bin/env expect -f | ||
|
||
source ./lib/common.tcl | ||
|
||
set timeout 60 | ||
|
||
set cluster_id "c-appuio-lab-cloudscale-rma-0" | ||
set api_endpoint "https://api.lab-cloudscale-rma-0.appuio.cloud:6443" | ||
|
||
set passphrase [getenv_or_die "E2E_PASSBOLT_PASSPHRASE"] | ||
set private_key [getenv_or_die "E2E_PASSBOLT_PRIVATE_KEY"] | ||
|
||
proc expect_prompt {prompt} { | ||
expect -exact "$prompt" | ||
expect -exact "> " | ||
sleep .5 | ||
} | ||
|
||
# The script assumes vi is used to enter the provate key | ||
set ::env(EDITOR) "vi" | ||
file delete -force config.yaml | ||
set ::env(EMR_CONFIG_DIR) [pwd] | ||
|
||
log "Starting tool" | ||
spawn ../emergency-credentials-receive | ||
expect -exact "Welcome" | ||
|
||
log "Expecting private key prompt in editor" | ||
expect -exact "Paste your Passbolt private key" | ||
sleep .1 | ||
send -- "i" | ||
send -- "$private_key" | ||
# Escape key | ||
send -- "\x1b" | ||
send -- ":x\r" | ||
|
||
log "Expecting passphrase prompt" | ||
expect_prompt "Passbolt passphrase" | ||
send -- "$passphrase" | ||
send -- "\r" | ||
|
||
log "Expecting cluster ID prompt" | ||
expect_prompt "Enter your cluster ID" | ||
send -- "$cluster_id" | ||
send -- "\r" | ||
|
||
log "Expecting to valid credentials" | ||
expect -exact "2 buckets with credentials found" | ||
expect -exact "Emergency credentials found" | ||
|
||
log "Expecting API endpoint prompt" | ||
expect_prompt "Provide API endpoint" | ||
send "$api_endpoint" | ||
send -- "\r" | ||
expect eof | ||
|
||
test_kubeconfig "em-$cluster_id" | ||
|
||
log "Test successful" |
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,26 @@ | ||
|
||
proc log {msg} { | ||
send_user "\n\[TEST\]\t$msg...\n" | ||
} | ||
|
||
proc test_kubeconfig {kubeconfig} { | ||
log "Testing kubeconfig $kubeconfig" | ||
set ::env(KUBECONFIG) "$kubeconfig" | ||
|
||
log "Testing kubeconfig is allowed to get nodes" | ||
spawn kubectl get nodes | ||
expect -- "master*Ready*master" | ||
expect eof | ||
|
||
log "Testing kubeconfig is allowed to delete nodes" | ||
spawn kubectl auth can-i delete nodes | ||
expect -- "yes" | ||
expect eof | ||
} | ||
|
||
proc getenv_or_die {var} { | ||
if {![info exists ::env($var)]} { | ||
error "Missing environment variable $var" | ||
} | ||
return "$::env($var)" | ||
} |
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
Oops, something went wrong.