Skip to content

Commit

Permalink
test: try fix generate keys script
Browse files Browse the repository at this point in the history
  • Loading branch information
dmyger committed Dec 27, 2024
1 parent 1ffdb70 commit 903da6a
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 9 deletions.
10 changes: 6 additions & 4 deletions cli/console/console.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,13 +64,16 @@ func NewConsole(opts ConsoleOpts) (Console, error) {
return c, nil
}

func (c *Console) runOnPipe() {
log.Debugf("Processing piped input")
func (c *Console) runOnPipe() error {
pipe := bufio.NewScanner(os.Stdin)
log.Infof("Processing piped input")
for pipe.Scan() {
line := pipe.Text()
c.execute(line)
}
err := pipe.Err()
log.Warnf("Exit from runOnPipe() with error=%s", err)
return err
}

// Run starts console.
Expand All @@ -79,8 +82,7 @@ func (c *Console) Run() error {
return errors.New("can't run on stopped console")
}
if !term.IsTerminal(syscall.Stdin) {
c.runOnPipe()
return nil
return c.runOnPipe()
}

log.Infof("Connected to %s\n", c.title())
Expand Down
6 changes: 3 additions & 3 deletions test/integration/aeon/generate-keys.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ EOF
### Server .key&.crt and ca.crt required for Server-Side TLS mode.

# 1. Generate CA's private key and self-signed certificate
openssl req -new -x509 -days 1 -noenc -keyout ca.key -out ca.crt -subj "${CA_SUBJ}" -quiet
openssl req -new -x509 -days 1 -noenc -keyout ca.key -out ca.crt -subj "${CA_SUBJ}"

# 2. Generate web server's private key and certificate signing request (CSR)
openssl req -new -noenc -keyout server.key -out server.csr -subj "${CA_SUBJ}" -quiet
openssl req -new -noenc -keyout server.key -out server.csr -subj "${CA_SUBJ}"

# 3. Use CA's private key to sign web server's CSR and get back the signed certificate
openssl x509 -req -in server.csr -days 1 -CA ca.crt -CAkey ca.key -CAcreateserial \
Expand All @@ -30,7 +30,7 @@ openssl x509 -req -in server.csr -days 1 -CA ca.crt -CAkey ca.key -CAcreateseria
### Client .key & .crt required for Mutual TSL mode.

# 4. Generate client's private key and certificate signing request (CSR)
openssl req -new -noenc -keyout client.key -out client.csr -subj "$CA_SUBJ" -quiet
openssl req -new -noenc -keyout client.key -out client.csr -subj "$CA_SUBJ"

# 5. Use CA's private key to sign client's CSR and get back the signed certificate
openssl x509 -req -in client.csr -days 1 -CA ca.crt -CAkey ca.key -CAcreateserial \
Expand Down
9 changes: 7 additions & 2 deletions test/integration/aeon/test_aeon.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#!/usr/bin/env python3
from subprocess import PIPE, STDOUT, Popen, run
from time import sleep

import pytest

Expand Down Expand Up @@ -39,12 +40,14 @@ def test_cli_plain_arguments_success(tt_cmd, aeon_plain, certificates, args):
text=True,
encoding="utf-8",
)
wait_for_lines_in_output(tt.stderr, ["Aeon responses at"])
wait_for_lines_in_output(tt.stderr, ["Aeon responses at", "Processing piped input"])
sleep(0.5)

# Terminate tt with "^D" input, as (EOF) signal.
tt.stdin.close()
tt.wait(timeout=2)
assert tt.poll() is not None
print(tt.stderr)
assert tt.returncode == 0


Expand All @@ -69,12 +72,14 @@ def test_cli_ssl_arguments_success(tt_cmd, aeon_ssl, certificates):
text=True,
encoding="utf-8",
)
wait_for_lines_in_output(tt.stderr, ["Aeon responses at"])
wait_for_lines_in_output(tt.stderr, ["Aeon responses at", "Processing piped input"])
sleep(0.5)

# Terminate tt with "^D" input, as (EOF) signal.
tt.stdin.close()
tt.wait(timeout=2)
assert tt.poll() is not None
print(tt.stderr)
assert tt.returncode == 0


Expand Down

0 comments on commit 903da6a

Please sign in to comment.