From e9f4a7729a5a4baba9fe2acd59d2a784cee5f6eb Mon Sep 17 00:00:00 2001 From: Reuben Miller Date: Thu, 16 May 2024 11:25:12 +0200 Subject: [PATCH] update remote access examples --- api/spec/json/remoteAccessConfigurations.json | 156 +++++++++++++----- api/spec/yaml/remoteAccessConfigurations.yaml | 104 +++++++++--- .../create_telnet/create_telnet.auto.go | 4 +- .../create_vnc/create_vnc.auto.go | 6 +- .../create_webssh/create_webssh.auto.go | 18 +- .../configurations/update/update.auto.go | 2 +- .../configurations_create-passthrough.yaml | 4 +- .../configurations_create-telnet.yaml | 4 +- .../configurations_create-vnc.yaml | 8 +- .../configurations_create-webssh.yaml | 17 +- .../remoteaccess/configurations_delete.yaml | 2 +- .../remoteaccess/configurations_get.yaml | 2 +- .../remoteaccess/configurations_list.yaml | 2 +- .../remoteaccess/configurations_update.yaml | 6 +- .../New-RemoteAccessTelnetConfiguration.ps1 | 4 +- .../New-RemoteAccessVNCConfiguration.ps1 | 6 +- .../New-RemoteAccessWebSSHConfiguration.ps1 | 12 +- ...t-RemoteAccessConfiguration.auto.Tests.ps1 | 2 +- ...cessConfigurationCollection.auto.Tests.ps1 | 2 +- ...essPassthroughConfiguration.auto.Tests.ps1 | 4 +- ...teAccessTelnetConfiguration.auto.Tests.ps1 | 4 +- ...emoteAccessVNCConfiguration.auto.Tests.ps1 | 8 +- ...teAccessWebSSHConfiguration.auto.Tests.ps1 | 8 +- ...e-RemoteAccessConfiguration.auto.Tests.ps1 | 2 +- 24 files changed, 258 insertions(+), 129 deletions(-) diff --git a/api/spec/json/remoteAccessConfigurations.json b/api/spec/json/remoteAccessConfigurations.json index 09e00690e..d1118202e 100644 --- a/api/spec/json/remoteAccessConfigurations.json +++ b/api/spec/json/remoteAccessConfigurations.json @@ -19,13 +19,19 @@ "go": [ { "command": "c8y remoteaccess configurations list --device device01", - "description": "List remote access configurations for a given device" + "description": "List remote access configurations for a given device", + "assertStdOut": { + "json": { + "path": "r//service/remoteaccess/devices/\\d+/configurations$" + } + } } ], "powershell": [ { "command": "Get-RemoteAccessConfigurationCollection -Device device01", - "description": "List remote access configurations for a given device" + "description": "List remote access configurations for a given device", + "skipTest": true } ] }, @@ -53,13 +59,19 @@ "go": [ { "command": "c8y remoteaccess configurations get --device device01 --id 1", - "description": "Get existing remote access configuration" + "description": "Get existing remote access configuration", + "assertStdOut": { + "json": { + "path": "r//service/remoteaccess/devices/\\d+/configurations/1$" + } + } } ], "powershell": [ { "command": "Get-RemoteAccessConfiguration -Device device01 -Id 1", - "description": "Get existing remote access configuration" + "description": "Get existing remote access configuration", + "skipTest": true } ] }, @@ -90,14 +102,21 @@ "examples": { "go": [ { - "command": "c8y remoteaccess configurations update --device device01 --id 1", - "description": "Update an existing remote access configuration" + "command": "c8y remoteaccess configurations update --device device01 --id 1 --name hello", + "description": "Update an existing remote access configuration", + "assertStdOut": { + "json": { + "path": "r//service/remoteaccess/devices/\\d+/configurations/1$" + } + }, + "skipTest": true } ], "powershell": [ { - "command": "Update-RemoteAccessConfiguration -Device device01 -Id 1", - "description": "Update an existing remote access configuration" + "command": "Update-RemoteAccessConfiguration -Device device01 -Id 1 -Name hello", + "description": "Update an existing remote access configuration", + "skipTest": true } ] }, @@ -138,13 +157,19 @@ "go": [ { "command": "c8y remoteaccess configurations delete --device device01 --id 1", - "description": "Delete an existing remote access configuration" + "description": "Delete an existing remote access configuration", + "assertStdOut": { + "json": { + "path": "r//service/remoteaccess/devices/\\d+/configurations/1$" + } + } } ], "powershell": [ { "command": "Remove-RemoteAccessConfiguration -Device device01 -Id 1", - "description": "Delete an existing remote access configuration" + "description": "Delete an existing remote access configuration", + "skipTest": true } ] }, @@ -179,21 +204,33 @@ "go": [ { "command": "c8y remoteaccess configurations create-passthrough --device device01\n", - "description": "Create a SSH passthrough configuration to the localhost" + "description": "Create a SSH passthrough configuration to the localhost", + "assertStdOut": { + "json": { + "path": "r//service/remoteaccess/devices/\\d+/configurations$" + } + } }, { "command": "c8y remoteaccess configurations create-passthrough --device device01 --hostname customhost --port 1234 --name \"My custom configuration\"\n", - "description": "Create a SSH passthrough configuration with custom details" + "description": "Create a SSH passthrough configuration with custom details", + "assertStdOut": { + "json": { + "path": "r//service/remoteaccess/devices/\\d+/configurations$" + } + } } ], "powershell": [ { "command": "New-RemoteAccessPassthroughConfiguration -Device device01\n", - "description": "Create a SSH passthrough configuration to the localhost" + "description": "Create a SSH passthrough configuration to the localhost", + "skipTest": true }, { "command": "New-RemoteAccessPassthroughConfiguration -Device device01 -Hostname customhost -Port 1234 -Name \"My custom configuration\"\n", - "description": "Create a SSH passthrough configuration with custom details" + "description": "Create a SSH passthrough configuration with custom details", + "skipTest": true } ] }, @@ -260,22 +297,34 @@ "examples": { "go": [ { - "command": "c8y remoteaccess configurations create-webssh\n", - "description": "Create a webssh configuration" + "command": "c8y remoteaccess configurations create-webssh --device device01 --username admin --password \"3Xz7cEj%oAmt#dnUMP*N\"\n", + "description": "Create a webssh configuration (with username/password authentication)", + "assertStdOut": { + "json": { + "path": "r//service/remoteaccess/devices/\\d+/configurations$" + } + } }, { - "command": "c8y remoteaccess configurations create-webssh --hostname 127.0.0.1 --port 2222", - "description": "Create a webssh configuration with a custom hostname and port" + "command": "c8y remoteaccess configurations create-webssh --device device01 --hostname 127.0.0.1 --port 2222 --username admin --privateKey \"xxxx\" --publicKey \"yyyyy\"", + "description": "Create a webssh configuration with a custom hostname and port (with ssh key authentication)", + "assertStdOut": { + "json": { + "path": "r//service/remoteaccess/devices/\\d+/configurations$" + } + } } ], "powershell": [ { - "command": "New-RemoteAccessWebSSHConfiguration\n", - "description": "Create a webssh configuration" + "command": "New-RemoteAccessWebSSHConfiguration -Device device01 -Username admin -Password \"3Xz7cEj%oAmt#dnUMP*N\"\n", + "description": "Create a webssh configuration (with username/password authentication)", + "skipTest": true }, { - "command": "New-RemoteAccessWebSSHConfiguration -Hostname 127.0.0.1 -Port 2222", - "description": "Create a webssh configuration with a custom hostname and port" + "command": "New-RemoteAccessWebSSHConfiguration -Device device01 -Hostname 127.0.0.1 -Port 2222 -Username admin -PrivateKey \"xxxx\" -PublicKey \"yyyyy\"", + "description": "Create a webssh configuration with a custom hostname and port (with ssh key authentication)", + "skipTest": true } ] }, @@ -297,12 +346,14 @@ { "name": "hostname", "type": "string", - "description": "Hostname" + "description": "Hostname", + "default": "127.0.0.1" }, { "name": "port", "type": "integer", - "description": "Port" + "description": "Port", + "default": "22" }, { "name": "credentialsType", @@ -310,7 +361,9 @@ "description": "Credentials type", "default": "USER_PASS", "validationSet": [ - "USER_PASS" + "USER_PASS", + "KEY_PAIR", + "CERTIFICATE" ] }, { @@ -338,7 +391,6 @@ "type": "string", "default": "SSH", "validationSet": [ - "PASSTHROUGH", "SSH" ], "description": "Protocol" @@ -348,7 +400,8 @@ "hostname", "port", "protocol", - "name" + "name", + "credentialsType" ] }, { @@ -364,22 +417,34 @@ "examples": { "go": [ { - "command": "c8y remoteaccess configurations create-vnc\n", - "description": "Create a VNC configuration that does not require a password" + "command": "c8y remoteaccess configurations create-vnc --device device01\n", + "description": "Create a VNC configuration that does not require a password", + "assertStdOut": { + "json": { + "path": "r//service/remoteaccess/devices/\\d+/configurations$" + } + } }, { - "command": "c8y remoteaccess configurations create-vnc --password 'asd08dcj23dsf{@#9}'", - "description": "Create a VNC configuration that requires a password" + "command": "c8y remoteaccess configurations create-vnc --device device01 --password 'asd08dcj23dsf{@#9}'", + "description": "Create a VNC configuration that requires a password", + "assertStdOut": { + "json": { + "path": "r//service/remoteaccess/devices/\\d+/configurations$" + } + } } ], "powershell": [ { - "command": "New-RemoteAccessVNCConfiguration\n", - "description": "Create a VNC configuration that does not require a password" + "command": "New-RemoteAccessVNCConfiguration -Device device01\n", + "description": "Create a VNC configuration that does not require a password", + "skipTest": true }, { - "command": "New-RemoteAccessVNCConfiguration -Password 'asd08dcj23dsf{@#9}'", - "description": "Create a VNC configuration that requires a password" + "command": "New-RemoteAccessVNCConfiguration -Device device01 -Password 'asd08dcj23dsf{@#9}'", + "description": "Create a VNC configuration that requires a password", + "skipTest": true } ] }, @@ -420,8 +485,6 @@ "type": "string", "default": "VNC", "validationSet": [ - "PASSTHROUGH", - "SSH", "VNC" ], "description": "Protocol" @@ -454,14 +517,20 @@ "examples": { "go": [ { - "command": "c8y remoteaccess configurations create-telnet\n", - "description": "Create a telnet configuration" + "command": "c8y remoteaccess configurations create-telnet --device device01\n", + "description": "Create a telnet configuration", + "assertStdOut": { + "json": { + "path": "r//service/remoteaccess/devices/\\d+/configurations$" + } + } } ], "powershell": [ { - "command": "New-RemoteAccessTelnetConfiguration\n", - "description": "Create a telnet configuration" + "command": "New-RemoteAccessTelnetConfiguration -Device device01\n", + "description": "Create a telnet configuration", + "skipTest": true } ] }, @@ -504,10 +573,7 @@ "type": "string", "default": "TELNET", "validationSet": [ - "TELNET", - "PASSTHROUGH", - "SSH", - "VNC" + "TELNET" ], "description": "Protocol" } diff --git a/api/spec/yaml/remoteAccessConfigurations.yaml b/api/spec/yaml/remoteAccessConfigurations.yaml index 8e19cb07b..11af89368 100644 --- a/api/spec/yaml/remoteAccessConfigurations.yaml +++ b/api/spec/yaml/remoteAccessConfigurations.yaml @@ -19,9 +19,13 @@ commands: go: - command: c8y remoteaccess configurations list --device device01 description: List remote access configurations for a given device + assertStdOut: + json: + path: r//service/remoteaccess/devices/\d+/configurations$ powershell: - command: Get-RemoteAccessConfigurationCollection -Device device01 description: List remote access configurations for a given device + skipTest: true path: /service/remoteaccess/devices/{device}/configurations pathParameters: @@ -42,9 +46,13 @@ commands: go: - command: c8y remoteaccess configurations get --device device01 --id 1 description: Get existing remote access configuration + assertStdOut: + json: + path: r//service/remoteaccess/devices/\d+/configurations/1$ powershell: - command: Get-RemoteAccessConfiguration -Device device01 -Id 1 description: Get existing remote access configuration + skipTest: true pathParameters: - name: device type: device[] @@ -65,11 +73,16 @@ commands: powershell: Update-RemoteAccessConfiguration examples: go: - - command: c8y remoteaccess configurations update --device device01 --id 1 + - command: c8y remoteaccess configurations update --device device01 --id 1 --name hello description: Update an existing remote access configuration + assertStdOut: + json: + path: r//service/remoteaccess/devices/\d+/configurations/1$ + skipTest: true powershell: - - command: Update-RemoteAccessConfiguration -Device device01 -Id 1 + - command: Update-RemoteAccessConfiguration -Device device01 -Id 1 -Name hello description: Update an existing remote access configuration + skipTest: true method: PUT path: /service/remoteaccess/devices/{device}/configurations/{id} pathParameters: @@ -98,9 +111,13 @@ commands: go: - command: c8y remoteaccess configurations delete --device device01 --id 1 description: Delete an existing remote access configuration + assertStdOut: + json: + path: r//service/remoteaccess/devices/\d+/configurations/1$ powershell: - command: Remove-RemoteAccessConfiguration -Device device01 -Id 1 description: Delete an existing remote access configuration + skipTest: true method: DELETE path: /service/remoteaccess/devices/{device}/configurations/{id} pathParameters: @@ -136,16 +153,25 @@ commands: - command: | c8y remoteaccess configurations create-passthrough --device device01 description: Create a SSH passthrough configuration to the localhost + assertStdOut: + json: + path: r//service/remoteaccess/devices/\d+/configurations$ + - command: | c8y remoteaccess configurations create-passthrough --device device01 --hostname customhost --port 1234 --name "My custom configuration" description: Create a SSH passthrough configuration with custom details + assertStdOut: + json: + path: r//service/remoteaccess/devices/\d+/configurations$ powershell: - command: | New-RemoteAccessPassthroughConfiguration -Device device01 description: Create a SSH passthrough configuration to the localhost + skipTest: true - command: | New-RemoteAccessPassthroughConfiguration -Device device01 -Hostname customhost -Port 1234 -Name "My custom configuration" description: Create a SSH passthrough configuration with custom details + skipTest: true pathParameters: - name: device @@ -198,18 +224,26 @@ commands: examples: go: - command: | - c8y remoteaccess configurations create-webssh - description: Create a webssh configuration - - - command: c8y remoteaccess configurations create-webssh --hostname 127.0.0.1 --port 2222 - description: Create a webssh configuration with a custom hostname and port + c8y remoteaccess configurations create-webssh --device device01 --username admin --password "3Xz7cEj%oAmt#dnUMP*N" + description: Create a webssh configuration (with username/password authentication) + assertStdOut: + json: + path: r//service/remoteaccess/devices/\d+/configurations$ + + - command: c8y remoteaccess configurations create-webssh --device device01 --hostname 127.0.0.1 --port 2222 --username admin --privateKey "xxxx" --publicKey "yyyyy" + description: Create a webssh configuration with a custom hostname and port (with ssh key authentication) + assertStdOut: + json: + path: r//service/remoteaccess/devices/\d+/configurations$ powershell: - command: | - New-RemoteAccessWebSSHConfiguration - description: Create a webssh configuration + New-RemoteAccessWebSSHConfiguration -Device device01 -Username admin -Password "3Xz7cEj%oAmt#dnUMP*N" + description: Create a webssh configuration (with username/password authentication) + skipTest: true - - command: New-RemoteAccessWebSSHConfiguration -Hostname 127.0.0.1 -Port 2222 - description: Create a webssh configuration with a custom hostname and port + - command: New-RemoteAccessWebSSHConfiguration -Device device01 -Hostname 127.0.0.1 -Port 2222 -Username admin -PrivateKey "xxxx" -PublicKey "yyyyy" + description: Create a webssh configuration with a custom hostname and port (with ssh key authentication) + skipTest: true pathParameters: - name: device type: device[] @@ -224,10 +258,12 @@ commands: - name: hostname type: string description: Hostname + default: "127.0.0.1" - name: port type: integer description: Port + default: "22" - name: credentialsType type: string @@ -235,7 +271,9 @@ commands: default: USER_PASS validationSet: - USER_PASS - + - KEY_PAIR + - CERTIFICATE + - name: privateKey type: string description: Private ssh key @@ -256,7 +294,6 @@ commands: type: string default: SSH validationSet: - - PASSTHROUGH - SSH description: Protocol @@ -265,6 +302,18 @@ commands: - port - protocol - name + - credentialsType + # bodyTemplates: + # - type: jsonnet + # template: | + + # { + # local credType = if std.objectHas($, "privateKey") && std.objectHas($, "publicKey") then "USER_PASS" else if std.objectHas($, "password") else, + # local credValue = { + + # }, + # credentialsType: credType + # } - name: create-vnc description: Create vnc configuration @@ -279,18 +328,26 @@ commands: examples: go: - command: | - c8y remoteaccess configurations create-vnc + c8y remoteaccess configurations create-vnc --device device01 description: Create a VNC configuration that does not require a password + assertStdOut: + json: + path: r//service/remoteaccess/devices/\d+/configurations$ - - command: c8y remoteaccess configurations create-vnc --password 'asd08dcj23dsf{@#9}' + - command: c8y remoteaccess configurations create-vnc --device device01 --password 'asd08dcj23dsf{@#9}' description: Create a VNC configuration that requires a password + assertStdOut: + json: + path: r//service/remoteaccess/devices/\d+/configurations$ powershell: - command: | - New-RemoteAccessVNCConfiguration + New-RemoteAccessVNCConfiguration -Device device01 description: Create a VNC configuration that does not require a password + skipTest: true - - command: New-RemoteAccessVNCConfiguration -Password 'asd08dcj23dsf{@#9}' + - command: New-RemoteAccessVNCConfiguration -Device device01 -Password 'asd08dcj23dsf{@#9}' description: Create a VNC configuration that requires a password + skipTest: true pathParameters: - name: device type: device[] @@ -320,8 +377,6 @@ commands: type: string default: VNC validationSet: - - PASSTHROUGH - - SSH - VNC description: Protocol @@ -349,12 +404,16 @@ commands: examples: go: - command: | - c8y remoteaccess configurations create-telnet + c8y remoteaccess configurations create-telnet --device device01 description: Create a telnet configuration + assertStdOut: + json: + path: r//service/remoteaccess/devices/\d+/configurations$ powershell: - command: | - New-RemoteAccessTelnetConfiguration + New-RemoteAccessTelnetConfiguration -Device device01 description: Create a telnet configuration + skipTest: true pathParameters: - name: device @@ -388,9 +447,6 @@ commands: default: TELNET validationSet: - TELNET - - PASSTHROUGH - - SSH - - VNC description: Protocol bodyRequiredKeys: diff --git a/pkg/cmd/remoteaccess/configurations/create_telnet/create_telnet.auto.go b/pkg/cmd/remoteaccess/configurations/create_telnet/create_telnet.auto.go index 70b46f4ed..e8f2e4ea6 100644 --- a/pkg/cmd/remoteaccess/configurations/create_telnet/create_telnet.auto.go +++ b/pkg/cmd/remoteaccess/configurations/create_telnet/create_telnet.auto.go @@ -36,7 +36,7 @@ func NewCreateTelnetCmd(f *cmdutil.Factory) *CreateTelnetCmd { then sensible defaults will be used. `, Example: heredoc.Doc(` -$ c8y remoteaccess configurations create-telnet +$ c8y remoteaccess configurations create-telnet --device device01 Create a telnet configuration `), PreRunE: func(cmd *cobra.Command, args []string) error { @@ -57,7 +57,7 @@ Create a telnet configuration completion.WithOptions( cmd, completion.WithDevice("device", func() (*c8y.Client, error) { return ccmd.factory.Client() }), - completion.WithValidateSet("protocol", "TELNET", "PASSTHROUGH", "SSH", "VNC"), + completion.WithValidateSet("protocol", "TELNET"), ) flags.WithOptions( diff --git a/pkg/cmd/remoteaccess/configurations/create_vnc/create_vnc.auto.go b/pkg/cmd/remoteaccess/configurations/create_vnc/create_vnc.auto.go index fbc7f3ec3..058340d2e 100644 --- a/pkg/cmd/remoteaccess/configurations/create_vnc/create_vnc.auto.go +++ b/pkg/cmd/remoteaccess/configurations/create_vnc/create_vnc.auto.go @@ -36,10 +36,10 @@ func NewCreateVncCmd(f *cmdutil.Factory) *CreateVncCmd { then sensible defaults will be used. `, Example: heredoc.Doc(` -$ c8y remoteaccess configurations create-vnc +$ c8y remoteaccess configurations create-vnc --device device01 Create a VNC configuration that does not require a password -$ c8y remoteaccess configurations create-vnc --password 'asd08dcj23dsf{@#9}' +$ c8y remoteaccess configurations create-vnc --device device01 --password 'asd08dcj23dsf{@#9}' Create a VNC configuration that requires a password `), PreRunE: func(cmd *cobra.Command, args []string) error { @@ -60,7 +60,7 @@ Create a VNC configuration that requires a password completion.WithOptions( cmd, completion.WithDevice("device", func() (*c8y.Client, error) { return ccmd.factory.Client() }), - completion.WithValidateSet("protocol", "PASSTHROUGH", "SSH", "VNC"), + completion.WithValidateSet("protocol", "VNC"), ) flags.WithOptions( diff --git a/pkg/cmd/remoteaccess/configurations/create_webssh/create_webssh.auto.go b/pkg/cmd/remoteaccess/configurations/create_webssh/create_webssh.auto.go index cef989488..7e4d6b33e 100644 --- a/pkg/cmd/remoteaccess/configurations/create_webssh/create_webssh.auto.go +++ b/pkg/cmd/remoteaccess/configurations/create_webssh/create_webssh.auto.go @@ -36,11 +36,11 @@ func NewCreateWebsshCmd(f *cmdutil.Factory) *CreateWebsshCmd { then sensible defaults will be used. `, Example: heredoc.Doc(` -$ c8y remoteaccess configurations create-webssh -Create a webssh configuration +$ c8y remoteaccess configurations create-webssh --device device01 --username admin --password "3Xz7cEj%oAmt#dnUMP*N" +Create a webssh configuration (with username/password authentication) -$ c8y remoteaccess configurations create-webssh --hostname 127.0.0.1 --port 2222 -Create a webssh configuration with a custom hostname and port +$ c8y remoteaccess configurations create-webssh --device device01 --hostname 127.0.0.1 --port 2222 --username admin --privateKey "xxxx" --publicKey "yyyyy" +Create a webssh configuration with a custom hostname and port (with ssh key authentication) `), PreRunE: func(cmd *cobra.Command, args []string) error { return f.CreateModeEnabled() @@ -52,8 +52,8 @@ Create a webssh configuration with a custom hostname and port cmd.Flags().StringSlice("device", []string{""}, "Device (accepts pipeline)") cmd.Flags().String("name", "webssh", "Connection name") - cmd.Flags().String("hostname", "", "Hostname") - cmd.Flags().Int("port", 0, "Port") + cmd.Flags().String("hostname", "127.0.0.1", "Hostname") + cmd.Flags().Int("port", 22, "Port") cmd.Flags().String("credentialsType", "USER_PASS", "Credentials type") cmd.Flags().String("privateKey", "", "Private ssh key") cmd.Flags().String("publicKey", "", "Public ssh key") @@ -64,8 +64,8 @@ Create a webssh configuration with a custom hostname and port completion.WithOptions( cmd, completion.WithDevice("device", func() (*c8y.Client, error) { return ccmd.factory.Client() }), - completion.WithValidateSet("credentialsType", "USER_PASS"), - completion.WithValidateSet("protocol", "PASSTHROUGH", "SSH"), + completion.WithValidateSet("credentialsType", "USER_PASS", "KEY_PAIR", "CERTIFICATE"), + completion.WithValidateSet("protocol", "SSH"), ) flags.WithOptions( @@ -163,7 +163,7 @@ func (n *CreateWebsshCmd) RunE(cmd *cobra.Command, args []string) error { flags.WithStringValue("protocol", "protocol"), cmdutil.WithTemplateValue(n.factory), flags.WithTemplateVariablesValue(), - flags.WithRequiredProperties("hostname", "port", "protocol", "name"), + flags.WithRequiredProperties("hostname", "port", "protocol", "name", "credentialsType"), ) if err != nil { return cmderrors.NewUserError(err) diff --git a/pkg/cmd/remoteaccess/configurations/update/update.auto.go b/pkg/cmd/remoteaccess/configurations/update/update.auto.go index e2afe4149..f8a2644b3 100644 --- a/pkg/cmd/remoteaccess/configurations/update/update.auto.go +++ b/pkg/cmd/remoteaccess/configurations/update/update.auto.go @@ -36,7 +36,7 @@ func NewUpdateCmd(f *cmdutil.Factory) *UpdateCmd { Hidden: true, Example: heredoc.Doc(` -$ c8y remoteaccess configurations update --device device01 --id 1 +$ c8y remoteaccess configurations update --device device01 --id 1 --name hello Update an existing remote access configuration `), PreRunE: func(cmd *cobra.Command, args []string) error { diff --git a/tests/auto/remoteaccessconfigurations/tests/remoteaccess/configurations_create-passthrough.yaml b/tests/auto/remoteaccessconfigurations/tests/remoteaccess/configurations_create-passthrough.yaml index 9b8464029..32a2ae477 100644 --- a/tests/auto/remoteaccessconfigurations/tests/remoteaccess/configurations_create-passthrough.yaml +++ b/tests/auto/remoteaccessconfigurations/tests/remoteaccess/configurations_create-passthrough.yaml @@ -6,7 +6,7 @@ tests: stdout: json: method: POST - path: /service/remoteaccess/devices/device01/configurations + path: r//service/remoteaccess/devices/\d+/configurations$ remoteaccess/configurations_create-passthrough_Create a SSH passthrough configuration with custom details: command: | c8y remoteaccess configurations create-passthrough --device device01 --hostname customhost --port 1234 --name "My custom configuration" @@ -17,4 +17,4 @@ tests: body.name: My custom configuration body.port: "1234" method: POST - path: /service/remoteaccess/devices/device01/configurations + path: r//service/remoteaccess/devices/\d+/configurations$ diff --git a/tests/auto/remoteaccessconfigurations/tests/remoteaccess/configurations_create-telnet.yaml b/tests/auto/remoteaccessconfigurations/tests/remoteaccess/configurations_create-telnet.yaml index f4eb9fbc4..9b7f8b807 100644 --- a/tests/auto/remoteaccessconfigurations/tests/remoteaccess/configurations_create-telnet.yaml +++ b/tests/auto/remoteaccessconfigurations/tests/remoteaccess/configurations_create-telnet.yaml @@ -1,9 +1,9 @@ tests: remoteaccess/configurations_create-telnet_Create a telnet configuration: command: | - c8y remoteaccess configurations create-telnet + c8y remoteaccess configurations create-telnet --device device01 exit-code: 0 stdout: json: method: POST - path: /service/remoteaccess/devices/{device}/configurations + path: r//service/remoteaccess/devices/\d+/configurations$ diff --git a/tests/auto/remoteaccessconfigurations/tests/remoteaccess/configurations_create-vnc.yaml b/tests/auto/remoteaccessconfigurations/tests/remoteaccess/configurations_create-vnc.yaml index d6944e056..71806b70d 100644 --- a/tests/auto/remoteaccessconfigurations/tests/remoteaccess/configurations_create-vnc.yaml +++ b/tests/auto/remoteaccessconfigurations/tests/remoteaccess/configurations_create-vnc.yaml @@ -1,17 +1,17 @@ tests: remoteaccess/configurations_create-vnc_Create a VNC configuration that does not require a password: command: | - c8y remoteaccess configurations create-vnc + c8y remoteaccess configurations create-vnc --device device01 exit-code: 0 stdout: json: method: POST - path: /service/remoteaccess/devices/{device}/configurations + path: r//service/remoteaccess/devices/\d+/configurations$ remoteaccess/configurations_create-vnc_Create a VNC configuration that requires a password: - command: c8y remoteaccess configurations create-vnc --password 'asd08dcj23dsf{@#9}' + command: c8y remoteaccess configurations create-vnc --device device01 --password 'asd08dcj23dsf{@#9}' exit-code: 0 stdout: json: body.password: asd08dcj23dsf{@#9} method: POST - path: /service/remoteaccess/devices/{device}/configurations + path: r//service/remoteaccess/devices/\d+/configurations$ diff --git a/tests/auto/remoteaccessconfigurations/tests/remoteaccess/configurations_create-webssh.yaml b/tests/auto/remoteaccessconfigurations/tests/remoteaccess/configurations_create-webssh.yaml index 20262713f..ebcf5d295 100644 --- a/tests/auto/remoteaccessconfigurations/tests/remoteaccess/configurations_create-webssh.yaml +++ b/tests/auto/remoteaccessconfigurations/tests/remoteaccess/configurations_create-webssh.yaml @@ -1,18 +1,23 @@ tests: - remoteaccess/configurations_create-webssh_Create a webssh configuration: + remoteaccess/configurations_create-webssh_Create a webssh configuration (with username/password authentication): command: | - c8y remoteaccess configurations create-webssh + c8y remoteaccess configurations create-webssh --device device01 --username admin --password "3Xz7cEj%oAmt#dnUMP*N" exit-code: 0 stdout: json: + body.password: 3Xz7cEj%oAmt#dnUMP*N + body.username: admin method: POST - path: /service/remoteaccess/devices/{device}/configurations - remoteaccess/configurations_create-webssh_Create a webssh configuration with a custom hostname and port: - command: c8y remoteaccess configurations create-webssh --hostname 127.0.0.1 --port 2222 + path: r//service/remoteaccess/devices/\d+/configurations$ + ? remoteaccess/configurations_create-webssh_Create a webssh configuration with a custom hostname and port (with ssh key authentication) + : command: c8y remoteaccess configurations create-webssh --device device01 --hostname 127.0.0.1 --port 2222 --username admin --privateKey "xxxx" --publicKey "yyyyy" exit-code: 0 stdout: json: body.hostname: 127.0.0.1 body.port: "2222" + body.privateKey: xxxx + body.publicKey: yyyyy + body.username: admin method: POST - path: /service/remoteaccess/devices/{device}/configurations + path: r//service/remoteaccess/devices/\d+/configurations$ diff --git a/tests/auto/remoteaccessconfigurations/tests/remoteaccess/configurations_delete.yaml b/tests/auto/remoteaccessconfigurations/tests/remoteaccess/configurations_delete.yaml index 84a487cd2..d250e06b4 100644 --- a/tests/auto/remoteaccessconfigurations/tests/remoteaccess/configurations_delete.yaml +++ b/tests/auto/remoteaccessconfigurations/tests/remoteaccess/configurations_delete.yaml @@ -5,4 +5,4 @@ tests: stdout: json: method: DELETE - path: /service/remoteaccess/devices/device01/configurations/1 + path: r//service/remoteaccess/devices/\d+/configurations/1$ diff --git a/tests/auto/remoteaccessconfigurations/tests/remoteaccess/configurations_get.yaml b/tests/auto/remoteaccessconfigurations/tests/remoteaccess/configurations_get.yaml index 962ca9d53..906730817 100644 --- a/tests/auto/remoteaccessconfigurations/tests/remoteaccess/configurations_get.yaml +++ b/tests/auto/remoteaccessconfigurations/tests/remoteaccess/configurations_get.yaml @@ -5,4 +5,4 @@ tests: stdout: json: method: GET - path: /service/remoteaccess/devices/device01/configurations/1 + path: r//service/remoteaccess/devices/\d+/configurations/1$ diff --git a/tests/auto/remoteaccessconfigurations/tests/remoteaccess/configurations_list.yaml b/tests/auto/remoteaccessconfigurations/tests/remoteaccess/configurations_list.yaml index 38c49b8e6..e27aa7e88 100644 --- a/tests/auto/remoteaccessconfigurations/tests/remoteaccess/configurations_list.yaml +++ b/tests/auto/remoteaccessconfigurations/tests/remoteaccess/configurations_list.yaml @@ -5,4 +5,4 @@ tests: stdout: json: method: GET - path: /service/remoteaccess/devices/device01/configurations + path: r//service/remoteaccess/devices/\d+/configurations$ diff --git a/tests/auto/remoteaccessconfigurations/tests/remoteaccess/configurations_update.yaml b/tests/auto/remoteaccessconfigurations/tests/remoteaccess/configurations_update.yaml index d97cea95f..13f48141c 100644 --- a/tests/auto/remoteaccessconfigurations/tests/remoteaccess/configurations_update.yaml +++ b/tests/auto/remoteaccessconfigurations/tests/remoteaccess/configurations_update.yaml @@ -1,8 +1,10 @@ tests: remoteaccess/configurations_update_Update an existing remote access configuration: - command: c8y remoteaccess configurations update --device device01 --id 1 + command: c8y remoteaccess configurations update --device device01 --id 1 --name hello exit-code: 0 + skip: true stdout: json: + body.name: hello method: PUT - path: /service/remoteaccess/devices/device01/configurations/1 + path: r//service/remoteaccess/devices/\d+/configurations/1$ diff --git a/tools/PSc8y/Public/New-RemoteAccessTelnetConfiguration.ps1 b/tools/PSc8y/Public/New-RemoteAccessTelnetConfiguration.ps1 index 93ceafca9..d5241c5dd 100644 --- a/tools/PSc8y/Public/New-RemoteAccessTelnetConfiguration.ps1 +++ b/tools/PSc8y/Public/New-RemoteAccessTelnetConfiguration.ps1 @@ -13,7 +13,7 @@ then sensible defaults will be used. https://reubenmiller.github.io/go-c8y-cli/docs/cli/c8y/remoteaccess_configurations_create-telnet .EXAMPLE -PS> New-RemoteAccessTelnetConfiguration +PS> New-RemoteAccessTelnetConfiguration -Device device01 Create a telnet configuration @@ -53,7 +53,7 @@ Create a telnet configuration # Protocol [Parameter()] - [ValidateSet('TELNET','PASSTHROUGH','SSH','VNC')] + [ValidateSet('TELNET')] [string] $Protocol ) diff --git a/tools/PSc8y/Public/New-RemoteAccessVNCConfiguration.ps1 b/tools/PSc8y/Public/New-RemoteAccessVNCConfiguration.ps1 index 5f5179ef9..739001ba6 100644 --- a/tools/PSc8y/Public/New-RemoteAccessVNCConfiguration.ps1 +++ b/tools/PSc8y/Public/New-RemoteAccessVNCConfiguration.ps1 @@ -13,13 +13,13 @@ then sensible defaults will be used. https://reubenmiller.github.io/go-c8y-cli/docs/cli/c8y/remoteaccess_configurations_create-vnc .EXAMPLE -PS> New-RemoteAccessVNCConfiguration +PS> New-RemoteAccessVNCConfiguration -Device device01 Create a VNC configuration that does not require a password .EXAMPLE -PS> New-RemoteAccessVNCConfiguration -Password 'asd08dcj23dsf{@#9}' +PS> New-RemoteAccessVNCConfiguration -Device device01 -Password 'asd08dcj23dsf{@#9}' Create a VNC configuration that requires a password @@ -58,7 +58,7 @@ Create a VNC configuration that requires a password # Protocol [Parameter()] - [ValidateSet('PASSTHROUGH','SSH','VNC')] + [ValidateSet('VNC')] [string] $Protocol ) diff --git a/tools/PSc8y/Public/New-RemoteAccessWebSSHConfiguration.ps1 b/tools/PSc8y/Public/New-RemoteAccessWebSSHConfiguration.ps1 index 57a902122..5e91a5310 100644 --- a/tools/PSc8y/Public/New-RemoteAccessWebSSHConfiguration.ps1 +++ b/tools/PSc8y/Public/New-RemoteAccessWebSSHConfiguration.ps1 @@ -13,15 +13,15 @@ then sensible defaults will be used. https://reubenmiller.github.io/go-c8y-cli/docs/cli/c8y/remoteaccess_configurations_create-webssh .EXAMPLE -PS> New-RemoteAccessWebSSHConfiguration +PS> New-RemoteAccessWebSSHConfiguration -Device device01 -Username admin -Password "3Xz7cEj%oAmt#dnUMP*N" -Create a webssh configuration +Create a webssh configuration (with username/password authentication) .EXAMPLE -PS> New-RemoteAccessWebSSHConfiguration -Hostname 127.0.0.1 -Port 2222 +PS> New-RemoteAccessWebSSHConfiguration -Device device01 -Hostname 127.0.0.1 -Port 2222 -Username admin -PrivateKey "xxxx" -PublicKey "yyyyy" -Create a webssh configuration with a custom hostname and port +Create a webssh configuration with a custom hostname and port (with ssh key authentication) #> @@ -53,7 +53,7 @@ Create a webssh configuration with a custom hostname and port # Credentials type [Parameter()] - [ValidateSet('USER_PASS')] + [ValidateSet('USER_PASS','KEY_PAIR','CERTIFICATE')] [string] $CredentialsType, @@ -79,7 +79,7 @@ Create a webssh configuration with a custom hostname and port # Protocol [Parameter()] - [ValidateSet('PASSTHROUGH','SSH')] + [ValidateSet('SSH')] [string] $Protocol ) diff --git a/tools/PSc8y/Tests/Get-RemoteAccessConfiguration.auto.Tests.ps1 b/tools/PSc8y/Tests/Get-RemoteAccessConfiguration.auto.Tests.ps1 index 37359bff8..d0528840b 100644 --- a/tools/PSc8y/Tests/Get-RemoteAccessConfiguration.auto.Tests.ps1 +++ b/tools/PSc8y/Tests/Get-RemoteAccessConfiguration.auto.Tests.ps1 @@ -5,7 +5,7 @@ Describe -Name "Get-RemoteAccessConfiguration" { } - It "Get existing remote access configuration" { + It -Skip "Get existing remote access configuration" { $Response = PSc8y\Get-RemoteAccessConfiguration -Device device01 -Id 1 $LASTEXITCODE | Should -Be 0 } diff --git a/tools/PSc8y/Tests/Get-RemoteAccessConfigurationCollection.auto.Tests.ps1 b/tools/PSc8y/Tests/Get-RemoteAccessConfigurationCollection.auto.Tests.ps1 index 70b424838..103c6dd81 100644 --- a/tools/PSc8y/Tests/Get-RemoteAccessConfigurationCollection.auto.Tests.ps1 +++ b/tools/PSc8y/Tests/Get-RemoteAccessConfigurationCollection.auto.Tests.ps1 @@ -5,7 +5,7 @@ Describe -Name "Get-RemoteAccessConfigurationCollection" { } - It "List remote access configurations for a given device" { + It -Skip "List remote access configurations for a given device" { $Response = PSc8y\Get-RemoteAccessConfigurationCollection -Device device01 $LASTEXITCODE | Should -Be 0 } diff --git a/tools/PSc8y/Tests/New-RemoteAccessPassthroughConfiguration.auto.Tests.ps1 b/tools/PSc8y/Tests/New-RemoteAccessPassthroughConfiguration.auto.Tests.ps1 index 17214481c..99b13a7a9 100644 --- a/tools/PSc8y/Tests/New-RemoteAccessPassthroughConfiguration.auto.Tests.ps1 +++ b/tools/PSc8y/Tests/New-RemoteAccessPassthroughConfiguration.auto.Tests.ps1 @@ -5,13 +5,13 @@ Describe -Name "New-RemoteAccessPassthroughConfiguration" { } - It "Create a SSH passthrough configuration to the localhost" { + It -Skip "Create a SSH passthrough configuration to the localhost" { $Response = PSc8y\New-RemoteAccessPassthroughConfiguration -Device device01 $LASTEXITCODE | Should -Be 0 } - It "Create a SSH passthrough configuration with custom details" { + It -Skip "Create a SSH passthrough configuration with custom details" { $Response = PSc8y\New-RemoteAccessPassthroughConfiguration -Device device01 -Hostname customhost -Port 1234 -Name "My custom configuration" $LASTEXITCODE | Should -Be 0 diff --git a/tools/PSc8y/Tests/New-RemoteAccessTelnetConfiguration.auto.Tests.ps1 b/tools/PSc8y/Tests/New-RemoteAccessTelnetConfiguration.auto.Tests.ps1 index d9368a988..f8a6fa68f 100644 --- a/tools/PSc8y/Tests/New-RemoteAccessTelnetConfiguration.auto.Tests.ps1 +++ b/tools/PSc8y/Tests/New-RemoteAccessTelnetConfiguration.auto.Tests.ps1 @@ -5,8 +5,8 @@ Describe -Name "New-RemoteAccessTelnetConfiguration" { } - It "Create a telnet configuration" { - $Response = PSc8y\New-RemoteAccessTelnetConfiguration + It -Skip "Create a telnet configuration" { + $Response = PSc8y\New-RemoteAccessTelnetConfiguration -Device device01 $LASTEXITCODE | Should -Be 0 } diff --git a/tools/PSc8y/Tests/New-RemoteAccessVNCConfiguration.auto.Tests.ps1 b/tools/PSc8y/Tests/New-RemoteAccessVNCConfiguration.auto.Tests.ps1 index 91deb8e8e..af77901f2 100644 --- a/tools/PSc8y/Tests/New-RemoteAccessVNCConfiguration.auto.Tests.ps1 +++ b/tools/PSc8y/Tests/New-RemoteAccessVNCConfiguration.auto.Tests.ps1 @@ -5,14 +5,14 @@ Describe -Name "New-RemoteAccessVNCConfiguration" { } - It "Create a VNC configuration that does not require a password" { - $Response = PSc8y\New-RemoteAccessVNCConfiguration + It -Skip "Create a VNC configuration that does not require a password" { + $Response = PSc8y\New-RemoteAccessVNCConfiguration -Device device01 $LASTEXITCODE | Should -Be 0 } - It "Create a VNC configuration that requires a password" { - $Response = PSc8y\New-RemoteAccessVNCConfiguration -Password 'asd08dcj23dsf{@#9}' + It -Skip "Create a VNC configuration that requires a password" { + $Response = PSc8y\New-RemoteAccessVNCConfiguration -Device device01 -Password 'asd08dcj23dsf{@#9}' $LASTEXITCODE | Should -Be 0 } diff --git a/tools/PSc8y/Tests/New-RemoteAccessWebSSHConfiguration.auto.Tests.ps1 b/tools/PSc8y/Tests/New-RemoteAccessWebSSHConfiguration.auto.Tests.ps1 index 2a40a444b..81af93841 100644 --- a/tools/PSc8y/Tests/New-RemoteAccessWebSSHConfiguration.auto.Tests.ps1 +++ b/tools/PSc8y/Tests/New-RemoteAccessWebSSHConfiguration.auto.Tests.ps1 @@ -5,14 +5,14 @@ Describe -Name "New-RemoteAccessWebSSHConfiguration" { } - It "Create a webssh configuration" { - $Response = PSc8y\New-RemoteAccessWebSSHConfiguration + It -Skip "Create a webssh configuration (with username/password authentication)" { + $Response = PSc8y\New-RemoteAccessWebSSHConfiguration -Device device01 -Username admin -Password "3Xz7cEj%oAmt#dnUMP*N" $LASTEXITCODE | Should -Be 0 } - It "Create a webssh configuration with a custom hostname and port" { - $Response = PSc8y\New-RemoteAccessWebSSHConfiguration -Hostname 127.0.0.1 -Port 2222 + It -Skip "Create a webssh configuration with a custom hostname and port (with ssh key authentication)" { + $Response = PSc8y\New-RemoteAccessWebSSHConfiguration -Device device01 -Hostname 127.0.0.1 -Port 2222 -Username admin -PrivateKey "xxxx" -PublicKey "yyyyy" $LASTEXITCODE | Should -Be 0 } diff --git a/tools/PSc8y/Tests/Remove-RemoteAccessConfiguration.auto.Tests.ps1 b/tools/PSc8y/Tests/Remove-RemoteAccessConfiguration.auto.Tests.ps1 index 59b5fd322..a8079fcf5 100644 --- a/tools/PSc8y/Tests/Remove-RemoteAccessConfiguration.auto.Tests.ps1 +++ b/tools/PSc8y/Tests/Remove-RemoteAccessConfiguration.auto.Tests.ps1 @@ -5,7 +5,7 @@ Describe -Name "Remove-RemoteAccessConfiguration" { } - It "Delete an existing remote access configuration" { + It -Skip "Delete an existing remote access configuration" { $Response = PSc8y\Remove-RemoteAccessConfiguration -Device device01 -Id 1 $LASTEXITCODE | Should -Be 0 }