Skip to content

Commit

Permalink
aeon:added the ability to connect from the config Closes #TNTP-1073
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexandrLitkevich committed Feb 1, 2025
1 parent ef41fff commit fa3db16
Show file tree
Hide file tree
Showing 2 changed files with 115 additions and 119 deletions.
4 changes: 2 additions & 2 deletions cli/cmd/aeon.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@ func newAeonConnectCmd() *cobra.Command {
Short: "Connect to the aeon instance",
Long: `Connect to the aeon instance.
tt aeon connect localhost:50051
tt aeon connect unix://<socket-path>`,
tt aeon connect unix://<socket-path>
tt aeon connect -c path instanceName>`,
PreRunE: func(cmd *cobra.Command, args []string) error {
err := aeonConnectValidateArgs(cmd, args)
util.HandleCmdErr(cmd, err)
Expand All @@ -48,7 +49,6 @@ tt aeon connect unix://<socket-path>`,
internalAeonConnect, args)
util.HandleCmdErr(cmd, err)
},
// Args: cobra.ExactArgs(1),
}

aeonCmd.Flags().StringVar(&connectCtx.Ssl.KeyFile, "sslkeyfile", "",
Expand Down
230 changes: 113 additions & 117 deletions test/integration/aeon/test_aeon.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/usr/bin/env python3
from subprocess import run
from subprocess import PIPE, STDOUT, run

import pytest

Expand Down Expand Up @@ -81,119 +81,115 @@ def test_cli_ssl_arguments_success(tt_cmd, aeon_ssl, certificates):
assert tt.returncode == 0


# @pytest.mark.parametrize(
# "args, error",
# [
# ((), "Error: accepts 1 arg(s), received 0"),
# # (
# # ("localhost:50051", "@aeon_unix_socket"),
# # "Error: accepts 1 arg(s), received 2",
# # ),
# (
# (
# "--transport",
# "mode",
# "localhost:50051",
# ),
# 'Error: invalid argument "mode" for "--transport" flag',
# ),
# (
# (
# "--transport=ssl",
# "--sslkeyfile=not-exits.key",
# "--sslcertfile={c_public}",
# "--sslcafile={ca}",
# "localhost:50051",
# ),
# 'not valid path to a private SSL key file="not-exits.key"',
# ),
# (
# (
# "--transport=ssl",
# "--sslkeyfile={c_private}",
# "--sslcertfile=not-exits.key",
# "--sslcafile={ca}",
# "localhost:50051",
# ),
# 'not valid path to an SSL certificate file="not-exits.key"',
# ),
# (
# (
# "--transport=ssl",
# "--sslkeyfile={c_private}",
# "--sslcertfile={c_public}",
# "--sslcafile=not-exits.key",
# "localhost:50051",
# ),
# 'not valid path to trusted certificate authorities (CA) file="not-exits.key"',
# ),
# (
# (
# "--sslcafile=not-exits.key",
# "localhost:50051",
# ),
# 'not valid path to trusted certificate authorities (CA) file="not-exits.key"',
# ),
# (
# (
# "--transport=ssl",
# "--sslcertfile={c_public}",
# "--sslcafile={ca}",
# "localhost:50051",
# ),
# "files Key and Cert must be specified both",
# ),
# (
# (
# "--transport=ssl",
# "--sslkeyfile={c_private}",
# "--sslcafile={ca}",
# "localhost:50051",
# ),
# "files Key and Cert must be specified both",
# ),
# (
# (
# "localhost:50051",
# "--transport=ssl",
# "--sslcertfile={c_public}",
# "--sslcafile={ca}",
# "--sslkeyfile",
# ),
# "flag needs an argument: --sslkeyfile",
# ),
# (
# (
# "localhost:50051",
# "--transport=ssl",
# "--sslkeyfile={c_private}",
# "--sslcafile={ca}",
# "--sslcertfile",
# ),
# "flag needs an argument: --sslcertfile",
# ),
# (
# (
# "localhost:50051",
# "--transport=ssl",
# "--sslkeyfile={c_private}",
# "--sslcertfile={c_public}",
# "--sslcafile",
# ),
# "flag needs an argument: --sslcafile",
# ),
# ],
# )
# def test_cli_arguments_fail(tt_cmd, certificates, args, error):
# cmd = [str(tt_cmd), *AeonConnectCommand]
# cmd += (a.format(**certificates) for a in args)

# print(f"Run: {' '.join(cmd)}")
# result = run(
# cmd,
# stderr=STDOUT,
# stdout=PIPE,
# text=True,
# )
# assert result.returncode != 0
# assert error in result.stdout
@pytest.mark.parametrize(
"args, error",
[
(
(
"--transport",
"mode",
"localhost:50051",
),
'Error: invalid argument "mode" for "--transport" flag',
),
(
(
"--transport=ssl",
"--sslkeyfile=not-exits.key",
"--sslcertfile={c_public}",
"--sslcafile={ca}",
"localhost:50051",
),
'not valid path to a private SSL key file="not-exits.key"',
),
(
(
"--transport=ssl",
"--sslkeyfile={c_private}",
"--sslcertfile=not-exits.key",
"--sslcafile={ca}",
"localhost:50051",
),
'not valid path to an SSL certificate file="not-exits.key"',
),
(
(
"--transport=ssl",
"--sslkeyfile={c_private}",
"--sslcertfile={c_public}",
"--sslcafile=not-exits.key",
"localhost:50051",
),
'not valid path to trusted certificate authorities (CA) file="not-exits.key"',
),
(
(
"--sslcafile=not-exits.key",
"localhost:50051",
),
'not valid path to trusted certificate authorities (CA) file="not-exits.key"',
),
(
(
"--transport=ssl",
"--sslcertfile={c_public}",
"--sslcafile={ca}",
"localhost:50051",
),
"files Key and Cert must be specified both",
),
(
(
"--transport=ssl",
"--sslkeyfile={c_private}",
"--sslcafile={ca}",
"localhost:50051",
),
"files Key and Cert must be specified both",
),
(
(
"localhost:50051",
"--transport=ssl",
"--sslcertfile={c_public}",
"--sslcafile={ca}",
"--sslkeyfile",
),
"flag needs an argument: --sslkeyfile",
),
(
(
"localhost:50051",
"--transport=ssl",
"--sslkeyfile={c_private}",
"--sslcafile={ca}",
"--sslcertfile",
),
"flag needs an argument: --sslcertfile",
),
(
(
"localhost:50051",
"--transport=ssl",
"--sslkeyfile={c_private}",
"--sslcertfile={c_public}",
"--sslcafile",
),
"flag needs an argument: --sslcafile",
),
],
)

def test_cli_arguments_fail(tt_cmd, certificates, args, error):
cmd = [str(tt_cmd), *AeonConnectCommand]
cmd += (a.format(**certificates) for a in args)

print(f"Run: {' '.join(cmd)}")
result = run(
cmd,
stderr=STDOUT,
stdout=PIPE,
text=True,
)
assert result.returncode != 0
assert error in result.stdout

0 comments on commit fa3db16

Please sign in to comment.