From c8700ee8cd5fec6691a74b8db3052330155f9fd8 Mon Sep 17 00:00:00 2001 From: Reuben Miller Date: Wed, 24 Jan 2024 16:21:05 +0100 Subject: [PATCH 1/5] fix(cli profile): avoid exiting from set-session so current session does not exit the whole console session --- pkg/cmd/cli/profile/scripts/plugin.fish | 2 +- pkg/cmd/cli/profile/scripts/plugin.sh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/pkg/cmd/cli/profile/scripts/plugin.fish b/pkg/cmd/cli/profile/scripts/plugin.fish index 5f2789c92..308b18b78 100644 --- a/pkg/cmd/cli/profile/scripts/plugin.fish +++ b/pkg/cmd/cli/profile/scripts/plugin.fish @@ -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 diff --git a/pkg/cmd/cli/profile/scripts/plugin.sh b/pkg/cmd/cli/profile/scripts/plugin.sh index bde10eebf..4d94e624c 100644 --- a/pkg/cmd/cli/profile/scripts/plugin.sh +++ b/pkg/cmd/cli/profile/scripts/plugin.sh @@ -117,7 +117,7 @@ set-session() { code=$? if [ $code -ne 0 ]; then echo "Set session failed" - exit $code + return 1 fi eval "$c8yenv" } From c2683a70cd9ec43beff1747c3c1d4c549d15c1bc Mon Sep 17 00:00:00 2001 From: Reuben Miller Date: Wed, 24 Jan 2024 16:59:30 +0100 Subject: [PATCH 2/5] test: update trusted certificate --- .../certificates/trustedcert.pem | 29 ++++++++++++------- tests/testdata/trustedcert.pem | 29 ++++++++++++------- 2 files changed, 38 insertions(+), 20 deletions(-) diff --git a/tests/manual/devicemanagement/certificates/trustedcert.pem b/tests/manual/devicemanagement/certificates/trustedcert.pem index 018d003cd..10bd7038f 100644 --- a/tests/manual/devicemanagement/certificates/trustedcert.pem +++ b/tests/manual/devicemanagement/certificates/trustedcert.pem @@ -1,11 +1,20 @@ -----BEGIN CERTIFICATE----- -MIIBoTCCAUegAwIB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+LJpPX40JOHDF8EuS26qGhX1I3X1iE52YsjqceO2YLXJdFF+SS +b2ACRLF8LOuEDBm7Z2vyvIGL6h4eSntKAZOELX9ZAuutxU2ZtfiHi3JnkqP1D7ta +qfsSZyyvpzyjvRoICz9vAfO2G91fAgMBAAGjUzBRMB0GA1UdDgQWBBSpzH4gxnFr +dbL8wF6Tl+Z+RSrqMjAfBgNVHSMEGDAWgBSpzH4gxnFrdbL8wF6Tl+Z+RSrqMjAP +BgNVHRMBAf8EBTADAQH/MA0GCSqGSIb3DQEBCwUAA4IBAQAosBPGTnHfJMovgSj9 +DdMOL4i9lArmXrp4dS4/7MbnTERlTqbtYCAtAzXMtSHpIfj0MUxCY2kdLeC8pbzx +QQieELEYiDS4wt7PkvjDdcPA14K9nIsFXhH8AiiI544qf6ltTHHyIwqzy6RBYGxL +1DsaJyRREcx6jIzw0xc0jtuapL5F5XgT/Sx91MCA0nHERLNMaOZ76BWJTYu8w8Sq +MKSZ3PCKQjEPVgWHxwtvHMmHzH7cmBGvPiD5btNQJ5+AiZOJVVOOfhebMWp+gMt/ +E6IpofzBjUWHr1DXciKtKBdgsB+msC3F9mMsLNQlryUvbS3vqYmukTiViiHuCX5C +tNsR +-----END CERTIFICATE----- diff --git a/tests/testdata/trustedcert.pem b/tests/testdata/trustedcert.pem index 7e28cfa26..10bd7038f 100644 --- a/tests/testdata/trustedcert.pem +++ b/tests/testdata/trustedcert.pem @@ -1,11 +1,20 @@ -----BEGIN CERTIFICATE----- -MIIBoDCCAUagAwIBAgIISOLoBRYAHmwwCgYIKoZIzj0EAwIwPDEQMA4GA1UEAwwH -dGVkZ2UwNDESMBAGA1UECgwJVGhpbiBFZGdlMRQwEgYDVQQLDAtUZXN0IERldmlj -ZTAeFw0yMjA2MTcxMzQ3MzNaFw0yMzA2MTcxMzQ3MzNaMDwxEDAOBgNVBAMMB3Rl -ZGdlMDQxEjAQBgNVBAoMCVRoaW4gRWRnZTEUMBIGA1UECwwLVGVzdCBEZXZpY2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HRMBAf8EBTADAQH/MA0GCSqGSIb3DQEBCwUAA4IBAQAosBPGTnHfJMovgSj9 +DdMOL4i9lArmXrp4dS4/7MbnTERlTqbtYCAtAzXMtSHpIfj0MUxCY2kdLeC8pbzx +QQieELEYiDS4wt7PkvjDdcPA14K9nIsFXhH8AiiI544qf6ltTHHyIwqzy6RBYGxL +1DsaJyRREcx6jIzw0xc0jtuapL5F5XgT/Sx91MCA0nHERLNMaOZ76BWJTYu8w8Sq +MKSZ3PCKQjEPVgWHxwtvHMmHzH7cmBGvPiD5btNQJ5+AiZOJVVOOfhebMWp+gMt/ +E6IpofzBjUWHr1DXciKtKBdgsB+msC3F9mMsLNQlryUvbS3vqYmukTiViiHuCX5C +tNsR +-----END CERTIFICATE----- From fc4913f25685dadec632e83b3997f86b202781f2 Mon Sep 17 00:00:00 2001 From: Reuben Miller Date: Wed, 24 Jan 2024 17:26:15 +0100 Subject: [PATCH 3/5] test: fix setup script which silently failed to create some items --- tests/scripts/setup.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/scripts/setup.sh b/tests/scripts/setup.sh index 044a6f205..5bcac838a 100755 --- a/tests/scripts/setup.sh +++ b/tests/scripts/setup.sh @@ -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" \ @@ -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" } From e031fe83ed2c1268b45d54563965d95b5b530c30 Mon Sep 17 00:00:00 2001 From: Reuben Miller Date: Wed, 24 Jan 2024 17:31:54 +0100 Subject: [PATCH 4/5] test: use pattern matching when checking certificate fingerprint --- api/spec/json/devicecertificates.json | 2 +- api/spec/yaml/devicecertificates.yaml | 2 +- .../tests/devicemanagement/certificates_update.yaml | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/api/spec/json/devicecertificates.json b/api/spec/json/devicecertificates.json index 24c1e59e4..7dacce374 100644 --- a/api/spec/json/devicecertificates.json +++ b/api/spec/json/devicecertificates.json @@ -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]+$" } } } diff --git a/api/spec/yaml/devicecertificates.yaml b/api/spec/yaml/devicecertificates.yaml index 0dfce9b3a..00c45f8b4 100644 --- a/api/spec/yaml/devicecertificates.yaml +++ b/api/spec/yaml/devicecertificates.yaml @@ -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 diff --git a/tests/auto/devicecertificates/tests/devicemanagement/certificates_update.yaml b/tests/auto/devicecertificates/tests/devicemanagement/certificates_update.yaml index b9e47119a..d0a1341c4 100644 --- a/tests/auto/devicecertificates/tests/devicemanagement/certificates_update.yaml +++ b/tests/auto/devicecertificates/tests/devicemanagement/certificates_update.yaml @@ -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]+$ From b41d939944e94288a98460cf43672b4549ddac09 Mon Sep 17 00:00:00 2001 From: Reuben Miller Date: Wed, 24 Jan 2024 17:46:12 +0100 Subject: [PATCH 5/5] tests: fix device certificate expected values after updating test cert --- .../devicemanagement/certificates/certificates_create.yaml | 2 +- tests/manual/extensions/example/body_cumulocity_tests.yaml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/manual/devicemanagement/certificates/certificates_create.yaml b/tests/manual/devicemanagement/certificates/certificates_create.yaml index ad7e01f33..d92e33687 100644 --- a/tests/manual/devicemanagement/certificates/certificates_create.yaml +++ b/tests/manual/devicemanagement/certificates/certificates_create.yaml @@ -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 diff --git a/tests/manual/extensions/example/body_cumulocity_tests.yaml b/tests/manual/extensions/example/body_cumulocity_tests.yaml index d0d3b0ae4..af085c57e 100644 --- a/tests/manual/extensions/example/body_cumulocity_tests.yaml +++ b/tests/manual/extensions/example/body_cumulocity_tests.yaml @@ -142,7 +142,7 @@ tests: c8y kitchensink body_complex certificatefile --file testdata/trustedcert.pem stdout: json: - body.file: MIIBoDCCAUagAwIBAgIISOLoBRYAHmwwCgYIKoZIzj0EAwIwPDEQMA4GA1UEAwwHdGVkZ2UwNDESMBAGA1UECgwJVGhpbiBFZGdlMRQwEgYDVQQLDAtUZXN0IERldmljZTAeFw0yMjA2MTcxMzQ3MzNaFw0yMzA2MTcxMzQ3MzNaMDwxEDAOBgNVBAMMB3RlZGdlMDQxEjAQBgNVBAoMCVRoaW4gRWRnZTEUMBIGA1UECwwLVGVzdCBEZXZpY2UwWTATBgcqhkjOPQIBBggqhkjOPQMBBwNCAASw2fovoPAzOtH8qH0KiAycbssZkuW0kRBXxLzp2XlBX7RFuXz9iATdANGIbhruG9AfwFu5Bm+5YDGEMfF9q/TWozIwMDAdBgNVHQ4EFgQUbB4AFgXo4kirlR9b4UVQ0DhcLC0wDwYDVR0TAQH/BAUwAwEB/zAKBggqhkjOPQQDAgNIADBFAiAwByF4Si/A6aUzmKdq5Ehj6ViAXrMtqN4MquxCZt5w6gIhAMNRdQZTFFocbI+Ybok+Gb35043kXLtQK7YgbQB/mYre + body.file: MIIDLzCCAhegAwIBAgIUa6ENd40V0oXKs+5TIHtQjlfM66UwDQYJKoZIhvcNAQELBQAwJzESMBAGA1UECgwJdGhpbi1lZGdlMREwDwYDVQQDDAh0ZWRnZS1jYTAeFw0yNDAxMjQxNTU4MjhaFw0yNjEwMTkxNTU4MjhaMCcxEjAQBgNVBAoMCXRoaW4tZWRnZTERMA8GA1UEAwwIdGVkZ2UtY2EwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQCWiC56sM9LwOma34LlRbkXIZwF1SaaDnUj+EE5oufZ2Tf/++dnuVWEVyRfg0YiudH1cmmTmxqAY/huHOAFY/OJmcsCy6ugjShD/uCj2+vpOKwY1Pw6hNg75gFrz3c8SCnMJk+Os2Bez0+r2rUEk+0H4KXDbXyE4kMFMpSxahuEidHacg4nruJ+3/7G0t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