Skip to content

Commit

Permalink
Merge pull request #342 from reubenmiller/fix-shell-profile-set-sessi…
Browse files Browse the repository at this point in the history
…on-exit

fix(cli profile): avoid exiting from set-session so current session does not exit the whole console session
  • Loading branch information
reubenmiller authored Jan 24, 2024
2 parents 5e37c2b + b41d939 commit 93a2327
Show file tree
Hide file tree
Showing 10 changed files with 47 additions and 29 deletions.
2 changes: 1 addition & 1 deletion api/spec/json/devicecertificates.json
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@
"command": "c8y devicemanagement certificates update --id MyCert --status DISABLED",
"assertStdOut": {
"json": {
"path": "r//tenant/tenants/t\\d+/trusted-certificates/4fd8df0378f2cafd5e322c1aaa8b87300704e9a5"
"path": "r//tenant/tenants/t\\d+/trusted-certificates/[0-9a-f]+$"
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion api/spec/yaml/devicecertificates.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ commands:
command: c8y devicemanagement certificates update --id MyCert --status DISABLED
assertStdOut:
json:
path: r//tenant/tenants/t\d+/trusted-certificates/4fd8df0378f2cafd5e322c1aaa8b87300704e9a5
path: r//tenant/tenants/t\d+/trusted-certificates/[0-9a-f]+$

pathParameters:
- name: id
Expand Down
2 changes: 1 addition & 1 deletion pkg/cmd/cli/profile/scripts/plugin.fish
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ function set-session --description "Switch Cumulocity session interactively"
set c8yenv ( c8y sessions set --noColor=false $argv )
if test $status -ne 0
echo "Set session failed"
return
return 1
end
echo "$c8yenv" | source
end
Expand Down
2 changes: 1 addition & 1 deletion pkg/cmd/cli/profile/scripts/plugin.sh
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ set-session() {
code=$?
if [ $code -ne 0 ]; then
echo "Set session failed"
exit $code
return 1
fi
eval "$c8yenv"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@ tests:
json:
body.status: DISABLED
method: PUT
path: r//tenant/tenants/t\d+/trusted-certificates/4fd8df0378f2cafd5e322c1aaa8b87300704e9a5
path: r//tenant/tenants/t\d+/trusted-certificates/[0-9a-f]+$
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ tests:
exit-code: 0
stdout:
json:
body.certInPemFormat: MIIBoTCCAUegAwIBAgIJAM8wtTHqatq4MAoGCCqGSM49BAMCMDwxEDAOBgNVBAMMB3RlZGdlMDQxEjAQBgNVBAoMCVRoaW4gRWRnZTEUMBIGA1UECwwLVGVzdCBEZXZpY2UwHhcNMjIwNjE4MDgzNDU5WhcNMjMwNjE4MDgzNDU5WjA8MRAwDgYDVQQDDAd0ZWRnZTA0MRIwEAYDVQQKDAlUaGluIEVkZ2UxFDASBgNVBAsMC1Rlc3QgRGV2aWNlMFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEFMUs3ArUHUXv9c9hHK8u+vMsaT/jSyJw28HcE1wmcC8Hjj+axkcvYo3ppl52LceCtbtIJ2yLyGqTIkY2rn13q6MyMDAwHQYDVR0OBBYEFLjaauoxtTDPuSj6gmcg284CXS8rMA8GA1UdEwEB/wQFMAMBAf8wCgYIKoZIzj0EAwIDSAAwRQIgCJxir9JtcwQ8QDacjYz989BQK3lQ3xFRIbqZ6+B39ZMCIQDnTi8824HSF/YGM6VcWuXAHtViv72WIKmXnJ9ygRZdsw==
body.certInPemFormat: MIIDLzCCAhegAwIBAgIUa6ENd40V0oXKs+5TIHtQjlfM66UwDQYJKoZIhvcNAQELBQAwJzESMBAGA1UECgwJdGhpbi1lZGdlMREwDwYDVQQDDAh0ZWRnZS1jYTAeFw0yNDAxMjQxNTU4MjhaFw0yNjEwMTkxNTU4MjhaMCcxEjAQBgNVBAoMCXRoaW4tZWRnZTERMA8GA1UEAwwIdGVkZ2UtY2EwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQCWiC56sM9LwOma34LlRbkXIZwF1SaaDnUj+EE5oufZ2Tf/++dnuVWEVyRfg0YiudH1cmmTmxqAY/huHOAFY/OJmcsCy6ugjShD/uCj2+vpOKwY1Pw6hNg75gFrz3c8SCnMJk+Os2Bez0+r2rUEk+0H4KXDbXyE4kMFMpSxahuEidHacg4nruJ+3/7G0tkO0oy1KLqGiQ+LJpPX40JOHDF8EuS26qGhX1I3X1iE52YsjqceO2YLXJdFF+SSb2ACRLF8LOuEDBm7Z2vyvIGL6h4eSntKAZOELX9ZAuutxU2ZtfiHi3JnkqP1D7taqfsSZyyvpzyjvRoICz9vAfO2G91fAgMBAAGjUzBRMB0GA1UdDgQWBBSpzH4gxnFrdbL8wF6Tl+Z+RSrqMjAfBgNVHSMEGDAWgBSpzH4gxnFrdbL8wF6Tl+Z+RSrqMjAPBgNVHRMBAf8EBTADAQH/MA0GCSqGSIb3DQEBCwUAA4IBAQAosBPGTnHfJMovgSj9DdMOL4i9lArmXrp4dS4/7MbnTERlTqbtYCAtAzXMtSHpIfj0MUxCY2kdLeC8pbzxQQieELEYiDS4wt7PkvjDdcPA14K9nIsFXhH8AiiI544qf6ltTHHyIwqzy6RBYGxL1DsaJyRREcx6jIzw0xc0jtuapL5F5XgT/Sx91MCA0nHERLNMaOZ76BWJTYu8w8SqMKSZ3PCKQjEPVgWHxwtvHMmHzH7cmBGvPiD5btNQJ5+AiZOJVVOOfhebMWp+gMt/E6IpofzBjUWHr1DXciKtKBdgsB+msC3F9mMsLNQlryUvbS3vqYmukTiViiHuCX5CtNsR
body.name: MyCert
method: POST
path: /tenant/tenants/$C8Y_TENANT/trusted-certificates
29 changes: 19 additions & 10 deletions tests/manual/devicemanagement/certificates/trustedcert.pem
Original file line number Diff line number Diff line change
@@ -1,11 +1,20 @@
-----BEGIN CERTIFICATE-----
MIIBoTCCAUegAwIBAgIJAM8wtTHqatq4MAoGCCqGSM49BAMCMDwxEDAOBgNVBAMM
B3RlZGdlMDQxEjAQBgNVBAoMCVRoaW4gRWRnZTEUMBIGA1UECwwLVGVzdCBEZXZp
Y2UwH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oICz9vAfO2G91fAgMBAAGjUzBRMB0GA1UdDgQWBBSpzH4gxnFr
dbL8wF6Tl+Z+RSrqMjAfBgNVHSMEGDAWgBSpzH4gxnFrdbL8wF6Tl+Z+RSrqMjAP
BgNVHRMBAf8EBTADAQH/MA0GCSqGSIb3DQEBCwUAA4IBAQAosBPGTnHfJMovgSj9
DdMOL4i9lArmXrp4dS4/7MbnTERlTqbtYCAtAzXMtSHpIfj0MUxCY2kdLeC8pbzx
QQieELEYiDS4wt7PkvjDdcPA14K9nIsFXhH8AiiI544qf6ltTHHyIwqzy6RBYGxL
1DsaJyRREcx6jIzw0xc0jtuapL5F5XgT/Sx91MCA0nHERLNMaOZ76BWJTYu8w8Sq
MKSZ3PCKQjEPVgWHxwtvHMmHzH7cmBGvPiD5btNQJ5+AiZOJVVOOfhebMWp+gMt/
E6IpofzBjUWHr1DXciKtKBdgsB+msC3F9mMsLNQlryUvbS3vqYmukTiViiHuCX5C
tNsR
-----END CERTIFICATE-----
2 changes: 1 addition & 1 deletion tests/manual/extensions/example/body_cumulocity_tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ tests:
c8y kitchensink body_complex certificatefile --file testdata/trustedcert.pem
stdout:
json:
body.file: MIIBoDCCAUagAwIBAgIISOLoBRYAHmwwCgYIKoZIzj0EAwIwPDEQMA4GA1UEAwwHdGVkZ2UwNDESMBAGA1UECgwJVGhpbiBFZGdlMRQwEgYDVQQLDAtUZXN0IERldmljZTAeFw0yMjA2MTcxMzQ3MzNaFw0yMzA2MTcxMzQ3MzNaMDwxEDAOBgNVBAMMB3RlZGdlMDQxEjAQBgNVBAoMCVRoaW4gRWRnZTEUMBIGA1UECwwLVGVzdCBEZXZpY2UwWTATBgcqhkjOPQIBBggqhkjOPQMBBwNCAASw2fovoPAzOtH8qH0KiAycbssZkuW0kRBXxLzp2XlBX7RFuXz9iATdANGIbhruG9AfwFu5Bm+5YDGEMfF9q/TWozIwMDAdBgNVHQ4EFgQUbB4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xL1DsaJyRREcx6jIzw0xc0jtuapL5F5XgT/Sx91MCA0nHERLNMaOZ76BWJTYu8w8SqMKSZ3PCKQjEPVgWHxwtvHMmHzH7cmBGvPiD5btNQJ5+AiZOJVVOOfhebMWp+gMt/E6IpofzBjUWHr1DXciKtKBdgsB+msC3F9mMsLNQlryUvbS3vqYmukTiViiHuCX5CtNsR

#
# Device management
Expand Down
4 changes: 2 additions & 2 deletions tests/scripts/setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ create_usergroup () {
create_app () {
local name="$1"
c8y applications get -n --id "$name" --silentStatusCodes 404 ||
c8y applications create \
c8y applications create -n \
--name "$name" \
--type HOSTED \
--key "$name-key" \
Expand All @@ -85,7 +85,7 @@ create_service_user () {

local tenant=$(c8y currenttenant get -n --select name -o csv)
c8y microservices get -n --id "$appname" --silentStatusCodes 404 ||
c8y microservices serviceusers create \
c8y microservices serviceusers create -n \
--name "$appname" \
--tenants "$tenant"
}
Expand Down
29 changes: 19 additions & 10 deletions tests/testdata/trustedcert.pem
Original file line number Diff line number Diff line change
@@ -1,11 +1,20 @@
-----BEGIN CERTIFICATE-----
MIIBoDCCAUagAwIBAgIISOLoBRYAHmwwCgYIKoZIzj0EAwIwPDEQMA4GA1UEAwwH
dGVkZ2UwNDESMBAGA1UECgwJVGhpbiBFZGdlMRQwEgYDVQQLDAtUZXN0IERldmlj
ZTAeFw0yMjA2MTcxMzQ3MzNaFw0yMzA2MTcxMzQ3MzNaMDwxEDAOBgNVBAMMB3Rl
ZGdlMDQxEjAQBgNVBAoMCVRoaW4gRWRnZTEUMBIGA1UECwwLVGVzdCBEZXZpY2Uw
WTATBgcqhkjOPQIBBggqhkjOPQMBBwNCAASw2fovoPAzOtH8qH0KiAycbssZkuW0
kRBXxLzp2XlBX7RFuXz9iATdANGIbhruG9AfwFu5Bm+5YDGEMfF9q/TWozIwMDAd
BgNVHQ4EFgQUbB4AFgXo4kirlR9b4UVQ0DhcLC0wDwYDVR0TA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