|
|
057568 |
From 34f32d66ba1224a8c2ccdae27c1bc7f8c97840b2 Mon Sep 17 00:00:00 2001
|
|
|
057568 |
From: Matej Habrnal <mhabrnal@redhat.com>
|
|
|
057568 |
Date: Wed, 27 May 2015 14:58:55 +0200
|
|
|
057568 |
Subject: [PATCH] testsuite: fix test for ureport
|
|
|
057568 |
|
|
|
057568 |
The fix is related to change in the use of rhsm certificate from
|
|
|
057568 |
entitiement to consumer and URL where the uReports are sended.
|
|
|
057568 |
|
|
|
057568 |
Signed-off-by: Matej Habrnal <mhabrnal@redhat.com>
|
|
|
057568 |
---
|
|
|
057568 |
tests/ureport.at | 83 ++++++++++------------
|
|
|
057568 |
tests/ureport/certs/correct/cert-key.pem | 5 --
|
|
|
057568 |
tests/ureport/certs/correct/key.pem | 0
|
|
|
057568 |
tests/ureport/certs/incorrect_content/cert-key.pem | 5 --
|
|
|
057568 |
tests/ureport/certs/incorrect_content/cert.pem | 0
|
|
|
057568 |
tests/ureport/certs/only_cert/cert.pem | 0
|
|
|
057568 |
tests/ureport/certs/only_key/key.pem | 0
|
|
|
057568 |
7 files changed, 36 insertions(+), 57 deletions(-)
|
|
|
057568 |
delete mode 100644 tests/ureport/certs/correct/cert-key.pem
|
|
|
057568 |
create mode 100644 tests/ureport/certs/correct/key.pem
|
|
|
057568 |
delete mode 100644 tests/ureport/certs/incorrect_content/cert-key.pem
|
|
|
057568 |
delete mode 100644 tests/ureport/certs/incorrect_content/cert.pem
|
|
|
057568 |
create mode 100644 tests/ureport/certs/only_cert/cert.pem
|
|
|
057568 |
create mode 100644 tests/ureport/certs/only_key/key.pem
|
|
|
057568 |
|
|
|
057568 |
diff --git a/tests/ureport.at b/tests/ureport.at
|
|
|
057568 |
index 3a824a2..b5f79df 100644
|
|
|
057568 |
--- a/tests/ureport.at
|
|
|
057568 |
+++ b/tests/ureport.at
|
|
|
057568 |
@@ -261,7 +261,7 @@ int main(void)
|
|
|
057568 |
setenv("uReport_HTTPAuth", "username:password", 1);
|
|
|
057568 |
setenv("uReport_AuthDataItems", "hostname, time", 1);
|
|
|
057568 |
|
|
|
057568 |
- setenv("LIBREPORT_DEBUG_RHSMENT_PEM_DIR_PATH", TESTING_CERTS_CORRECT_DIR_PATH, 1);
|
|
|
057568 |
+ setenv("LIBREPORT_DEBUG_RHSMCON_PEM_DIR_PATH", TESTING_CERTS_CORRECT_DIR_PATH, 1);
|
|
|
057568 |
|
|
|
057568 |
ureport_server_config_load(&config, settings);
|
|
|
057568 |
|
|
|
057568 |
@@ -276,7 +276,7 @@ int main(void)
|
|
|
057568 |
assert(strcmp(l->data, "hostname") == 0);
|
|
|
057568 |
assert(strcmp(l->next->data, "time") == 0);
|
|
|
057568 |
|
|
|
057568 |
- unsetenv("LIBREPORT_DEBUG_RHSMENT_PEM_DIR_PATH");
|
|
|
057568 |
+ unsetenv("LIBREPORT_DEBUG_RHSMCON_PEM_DIR_PATH");
|
|
|
057568 |
|
|
|
057568 |
unsetenv("uReport_SSLClientAuth");
|
|
|
057568 |
unsetenv("uReport_HTTPAuth");
|
|
|
057568 |
@@ -296,7 +296,7 @@ int main(void)
|
|
|
057568 |
insert_map_string(settings, xstrdup("HTTPAuth"), xstrdup("rhn-username:rhn-password"));
|
|
|
057568 |
insert_map_string(settings, xstrdup("AuthDataItems"), xstrdup("hostname, type"));
|
|
|
057568 |
|
|
|
057568 |
- setenv("LIBREPORT_DEBUG_RHSMENT_PEM_DIR_PATH", TESTING_CERTS_CORRECT_DIR_PATH, 1);
|
|
|
057568 |
+ setenv("LIBREPORT_DEBUG_RHSMCON_PEM_DIR_PATH", TESTING_CERTS_CORRECT_DIR_PATH, 1);
|
|
|
057568 |
|
|
|
057568 |
ureport_server_config_load(&config, settings);
|
|
|
057568 |
|
|
|
057568 |
@@ -311,7 +311,7 @@ int main(void)
|
|
|
057568 |
assert(strcmp(l->data, "hostname") == 0);
|
|
|
057568 |
assert(strcmp(l->next->data, "type") == 0);
|
|
|
057568 |
|
|
|
057568 |
- unsetenv("LIBREPORT_DEBUG_RHSMENT_PEM_DIR_PATH");
|
|
|
057568 |
+ unsetenv("LIBREPORT_DEBUG_RHSMCON_PEM_DIR_PATH");
|
|
|
057568 |
|
|
|
057568 |
free_map_string(settings);
|
|
|
057568 |
|
|
|
057568 |
@@ -366,19 +366,17 @@ AT_TESTFUN([ureport_server_config_set_client_auth],
|
|
|
057568 |
#include <assert.h>
|
|
|
057568 |
|
|
|
057568 |
#define DESTROYED_POINTER (void *)0xdeadbeef
|
|
|
057568 |
-#define RHSM_WEB_SERVICE_URL "https://api.access.redhat.com/rs/telemetry/abrt"
|
|
|
057568 |
+#define RHSM_WEB_SERVICE_URL "https://cert-api.access.redhat.com/rs/telemetry/abrt"
|
|
|
057568 |
|
|
|
057568 |
#define TESTING_CERTS_CORRECT_DIR_PATH "../../ureport/certs/correct"
|
|
|
057568 |
-#define TESTING_CERTS_INCORRECT_CONTENT_DIR_PATH "../../ureport/certs/incorrect_content"
|
|
|
057568 |
+#define TESTING_CERTS_INCORRECT_ONLY_CERT_DIR_PATH "../../ureport/certs/only_cert"
|
|
|
057568 |
+#define TESTING_CERTS_INCORRECT_ONLY_KEY_DIR_PATH "../../ureport/certs/only_key"
|
|
|
057568 |
#define TESTING_PYTHONPATH "../../ureport/"
|
|
|
057568 |
#define WRONG_TESTING_PYTHONPATH "../../ureportxxxxxx/"
|
|
|
057568 |
|
|
|
057568 |
-#define RHSMENT_PEM_DIR_PATH "/etc/pki/entitlement"
|
|
|
057568 |
-
|
|
|
057568 |
-#define RHSMENT_ENT_DATA_BEGIN_TAG "-----BEGIN ENTITLEMENT DATA-----"
|
|
|
057568 |
-#define RHSMENT_ENT_DATA_END_TAG "-----END ENTITLEMENT DATA-----"
|
|
|
057568 |
-#define RHSMENT_SIG_DATA_BEGIN_TAG "-----BEGIN RSA SIGNATURE-----"
|
|
|
057568 |
-#define RHSMENT_SIG_DATA_END_TAG "-----END RSA SIGNATURE-----"
|
|
|
057568 |
+#define RHSMCON_PEM_DIR_PATH "/etc/pki/consumer"
|
|
|
057568 |
+#define RHSMCON_CERT_NAME "cert.pem"
|
|
|
057568 |
+#define RHSMCON_KEY_NAME "key.pem"
|
|
|
057568 |
|
|
|
057568 |
char *my_strdup(const char *str)
|
|
|
057568 |
{
|
|
|
057568 |
@@ -507,7 +505,7 @@ int main(void)
|
|
|
057568 |
/* no certs */
|
|
|
057568 |
char *empty_cert_dir = mkdtemp(strdup("/tmp/cert_XXXXXX"));
|
|
|
057568 |
assert(empty_cert_dir);
|
|
|
057568 |
- setenv("LIBREPORT_DEBUG_RHSMENT_PEM_DIR_PATH", empty_cert_dir, 1);
|
|
|
057568 |
+ setenv("LIBREPORT_DEBUG_RHSMCON_PEM_DIR_PATH", empty_cert_dir, 1);
|
|
|
057568 |
|
|
|
057568 |
int status = test_ureport_server_config_set_client_auth_exit_code_ext(&config, "rhsm", NULL, NULL);
|
|
|
057568 |
assert(status == 0);
|
|
|
057568 |
@@ -516,9 +514,18 @@ int main(void)
|
|
|
057568 |
|
|
|
057568 |
/* client_auth == rhsm */
|
|
|
057568 |
/* ur_url == NULL */
|
|
|
057568 |
- /* certs exists (incorrect content) */
|
|
|
057568 |
+ /* certs exists (only RHSMCON_CERT_NAME exists) */
|
|
|
057568 |
|
|
|
057568 |
- setenv("LIBREPORT_DEBUG_RHSMENT_PEM_DIR_PATH", TESTING_CERTS_INCORRECT_CONTENT_DIR_PATH, 1);
|
|
|
057568 |
+ setenv("LIBREPORT_DEBUG_RHSMCON_PEM_DIR_PATH", TESTING_CERTS_INCORRECT_ONLY_CERT_DIR_PATH, 1);
|
|
|
057568 |
+
|
|
|
057568 |
+ status = test_ureport_server_config_set_client_auth_exit_code_ext(&config, "rhsm", NULL, NULL);
|
|
|
057568 |
+ assert(status == 0);
|
|
|
057568 |
+
|
|
|
057568 |
+ /* client_auth == rhsm */
|
|
|
057568 |
+ /* ur_url == NULL */
|
|
|
057568 |
+ /* certs exists (only RHSMCON_KEY_NAME exists) */
|
|
|
057568 |
+
|
|
|
057568 |
+ setenv("LIBREPORT_DEBUG_RHSMCON_PEM_DIR_PATH", TESTING_CERTS_INCORRECT_ONLY_KEY_DIR_PATH, 1);
|
|
|
057568 |
|
|
|
057568 |
status = test_ureport_server_config_set_client_auth_exit_code_ext(&config, "rhsm", NULL, NULL);
|
|
|
057568 |
assert(status == 0);
|
|
|
057568 |
@@ -528,25 +535,15 @@ int main(void)
|
|
|
057568 |
/* certs exists (correct) */
|
|
|
057568 |
ureport_server_config_init(&config);
|
|
|
057568 |
|
|
|
057568 |
- setenv("LIBREPORT_DEBUG_RHSMENT_PEM_DIR_PATH", TESTING_CERTS_CORRECT_DIR_PATH, 1);
|
|
|
057568 |
+ setenv("LIBREPORT_DEBUG_RHSMCON_PEM_DIR_PATH", TESTING_CERTS_CORRECT_DIR_PATH, 1);
|
|
|
057568 |
|
|
|
057568 |
ureport_server_config_set_client_auth(&config, "rhsm");
|
|
|
057568 |
|
|
|
057568 |
assert_ureport_server_config(&config, RHSM_WEB_SERVICE_URL, true,
|
|
|
057568 |
TESTING_CERTS_CORRECT_DIR_PATH"/cert.pem",
|
|
|
057568 |
- TESTING_CERTS_CORRECT_DIR_PATH"/cert-key.pem",
|
|
|
057568 |
+ TESTING_CERTS_CORRECT_DIR_PATH"/key.pem",
|
|
|
057568 |
NULL, NULL);
|
|
|
057568 |
|
|
|
057568 |
- char *ent = xasprintf(RHSMENT_ENT_DATA_BEGIN_TAG"%s"RHSMENT_ENT_DATA_END_TAG, "entitlementdata");
|
|
|
057568 |
- assert(0 == strcmp(ent,
|
|
|
057568 |
- get_map_string_item_or_NULL(config.ur_http_headers, "X-RH-Entitlement-Data")));
|
|
|
057568 |
-
|
|
|
057568 |
- char *sig= xasprintf(RHSMENT_SIG_DATA_BEGIN_TAG"%s"RHSMENT_SIG_DATA_END_TAG, "rsasignature");
|
|
|
057568 |
- assert(0 == strcmp(sig,
|
|
|
057568 |
- get_map_string_item_or_NULL(config.ur_http_headers, "X-RH-Entitlement-Sig")));
|
|
|
057568 |
-
|
|
|
057568 |
- free(ent);
|
|
|
057568 |
- free(sig);
|
|
|
057568 |
ureport_server_config_destroy(&config);
|
|
|
057568 |
|
|
|
057568 |
/* client_auth == cert:key */
|
|
|
057568 |
@@ -575,16 +572,16 @@ int main(void)
|
|
|
057568 |
ret_val = test_ureport_server_config_set_client_auth_exit_code(&config, "cert");
|
|
|
057568 |
assert(ret_val != 0 && ret_val != -1);
|
|
|
057568 |
|
|
|
057568 |
-/* rhsm_config_get_entitlement_cert_dir */
|
|
|
057568 |
+/* rhsm_config_get_consumer_cert_dir */
|
|
|
057568 |
/* certs exists (correct content) */
|
|
|
057568 |
- unsetenv("LIBREPORT_DEBUG_RHSMENT_PEM_DIR_PATH");
|
|
|
057568 |
+ unsetenv("LIBREPORT_DEBUG_RHSMCON_PEM_DIR_PATH");
|
|
|
057568 |
setenv("PYTHONPATH", TESTING_PYTHONPATH, 1);
|
|
|
057568 |
|
|
|
057568 |
ureport_server_config_init(&config);
|
|
|
057568 |
ureport_server_config_set_client_auth(&config, "rhsm");
|
|
|
057568 |
|
|
|
057568 |
char *abs_path_cert = realpath(TESTING_CERTS_CORRECT_DIR_PATH"/cert.pem", NULL);
|
|
|
057568 |
- char *abs_path_key = realpath(TESTING_CERTS_CORRECT_DIR_PATH"/cert-key.pem", NULL);
|
|
|
057568 |
+ char *abs_path_key = realpath(TESTING_CERTS_CORRECT_DIR_PATH"/key.pem", NULL);
|
|
|
057568 |
|
|
|
057568 |
assert_ureport_server_config(&config, RHSM_WEB_SERVICE_URL, true,
|
|
|
057568 |
abs_path_cert,
|
|
|
057568 |
@@ -593,29 +590,19 @@ int main(void)
|
|
|
057568 |
free(abs_path_cert);
|
|
|
057568 |
free(abs_path_key);
|
|
|
057568 |
|
|
|
057568 |
- ent = xasprintf(RHSMENT_ENT_DATA_BEGIN_TAG"%s"RHSMENT_ENT_DATA_END_TAG, "entitlementdata");
|
|
|
057568 |
- assert(0 == strcmp(ent,
|
|
|
057568 |
- get_map_string_item_or_NULL(config.ur_http_headers, "X-RH-Entitlement-Data")));
|
|
|
057568 |
-
|
|
|
057568 |
- sig= xasprintf(RHSMENT_SIG_DATA_BEGIN_TAG"%s"RHSMENT_SIG_DATA_END_TAG, "rsasignature");
|
|
|
057568 |
- assert(0 == strcmp(sig,
|
|
|
057568 |
- get_map_string_item_or_NULL(config.ur_http_headers, "X-RH-Entitlement-Sig")));
|
|
|
057568 |
-
|
|
|
057568 |
- free(ent);
|
|
|
057568 |
- free(sig);
|
|
|
057568 |
ureport_server_config_destroy(&config);
|
|
|
057568 |
|
|
|
057568 |
- /* python script fails, '/etc/pki/entitlement' is returned */
|
|
|
057568 |
+ /* python script fails, '/etc/pki/consumer' is returned */
|
|
|
057568 |
|
|
|
057568 |
- /* set cert dir path to '/etc/pki/entitlement' */
|
|
|
057568 |
+ /* set cert dir path to '/etc/pki/consumer' */
|
|
|
057568 |
/* store return value of ureport_server_config_set_client_auth */
|
|
|
057568 |
- setenv("LIBREPORT_DEBUG_RHSMENT_PEM_DIR_PATH", RHSMENT_PEM_DIR_PATH, 1);
|
|
|
057568 |
+ setenv("LIBREPORT_DEBUG_RHSMCON_PEM_DIR_PATH", RHSMCON_PEM_DIR_PATH, 1);
|
|
|
057568 |
|
|
|
057568 |
int exp_ret_val = test_ureport_server_config_set_client_auth_exit_code(&config, "rhsm");
|
|
|
057568 |
|
|
|
057568 |
- /* Do the same with unset LIBREPORT_DEBUG_RHSMENT_PEM_DIR_PATH and wrong PYTHONPATH */
|
|
|
057568 |
- /* function rhsm_config_get_entitlement_cert_dir has to return RHSMENT_PEM_DIR_PATH */
|
|
|
057568 |
- unsetenv("LIBREPORT_DEBUG_RHSMENT_PEM_DIR_PATH");
|
|
|
057568 |
+ /* Do the same with unset LIBREPORT_DEBUG_RHSMCON_PEM_DIR_PATH and wrong PYTHONPATH */
|
|
|
057568 |
+ /* function rhsm_config_get_consumer_cert_dir has to return RHSMCON_PEM_DIR_PATH */
|
|
|
057568 |
+ unsetenv("LIBREPORT_DEBUG_RHSMCON_PEM_DIR_PATH");
|
|
|
057568 |
setenv("PYTHONPATH", WRONG_TESTING_PYTHONPATH, 1);
|
|
|
057568 |
|
|
|
057568 |
int rec_ret_val = test_ureport_server_config_set_client_auth_exit_code(&config, "rhsm");
|
|
|
057568 |
@@ -1215,6 +1202,8 @@ AT_TESTFUN([ureport_server_config_load_basic_auth],
|
|
|
057568 |
#include "libreport_curl.h"
|
|
|
057568 |
#include "problem_data.h"
|
|
|
057568 |
|
|
|
057568 |
+#define RHSM_WEB_SERVICE_URL "https://cert-api.access.redhat.com/rs/telemetry/abrt"
|
|
|
057568 |
+
|
|
|
057568 |
int main(void)
|
|
|
057568 |
{
|
|
|
057568 |
g_verbose=3;
|
|
|
057568 |
@@ -1241,7 +1230,7 @@ int main(void)
|
|
|
057568 |
|
|
|
057568 |
assert(strcmp(config.ur_username, "rhn-user-name") == 0);
|
|
|
057568 |
assert(strcmp(config.ur_password, "rhn-password") == 0);
|
|
|
057568 |
- assert(strcmp(config.ur_url, "https://api.access.redhat.com/rs/telemetry/abrt") == 0);
|
|
|
057568 |
+ assert(strcmp(config.ur_url, RHSM_WEB_SERVICE_URL) == 0);
|
|
|
057568 |
|
|
|
057568 |
unsetenv("LIBREPORT_DEBUG_PLUGINS_CONF_DIR");
|
|
|
057568 |
ureport_server_config_destroy(&config);
|
|
|
057568 |
diff --git a/tests/ureport/certs/correct/cert-key.pem b/tests/ureport/certs/correct/cert-key.pem
|
|
|
057568 |
deleted file mode 100644
|
|
|
057568 |
index 1516328..0000000
|
|
|
057568 |
--- a/tests/ureport/certs/correct/cert-key.pem
|
|
|
057568 |
+++ /dev/null
|
|
|
057568 |
@@ -1,5 +0,0 @@
|
|
|
057568 |
------BEGIN RSA PRIVATE KEY-----
|
|
|
057568 |
-rsa
|
|
|
057568 |
-private
|
|
|
057568 |
-key
|
|
|
057568 |
------END RSA PRIVATE KEY-----
|
|
|
057568 |
diff --git a/tests/ureport/certs/correct/key.pem b/tests/ureport/certs/correct/key.pem
|
|
|
057568 |
new file mode 100644
|
|
|
057568 |
index 0000000..e69de29
|
|
|
057568 |
diff --git a/tests/ureport/certs/incorrect_content/cert-key.pem b/tests/ureport/certs/incorrect_content/cert-key.pem
|
|
|
057568 |
deleted file mode 100644
|
|
|
057568 |
index 1516328..0000000
|
|
|
057568 |
--- a/tests/ureport/certs/incorrect_content/cert-key.pem
|
|
|
057568 |
+++ /dev/null
|
|
|
057568 |
@@ -1,5 +0,0 @@
|
|
|
057568 |
------BEGIN RSA PRIVATE KEY-----
|
|
|
057568 |
-rsa
|
|
|
057568 |
-private
|
|
|
057568 |
-key
|
|
|
057568 |
------END RSA PRIVATE KEY-----
|
|
|
057568 |
diff --git a/tests/ureport/certs/incorrect_content/cert.pem b/tests/ureport/certs/incorrect_content/cert.pem
|
|
|
057568 |
deleted file mode 100644
|
|
|
057568 |
index e69de29..0000000
|
|
|
057568 |
diff --git a/tests/ureport/certs/only_cert/cert.pem b/tests/ureport/certs/only_cert/cert.pem
|
|
|
057568 |
new file mode 100644
|
|
|
057568 |
index 0000000..e69de29
|
|
|
057568 |
diff --git a/tests/ureport/certs/only_key/key.pem b/tests/ureport/certs/only_key/key.pem
|
|
|
057568 |
new file mode 100644
|
|
|
057568 |
index 0000000..e69de29
|
|
|
057568 |
--
|
|
|
057568 |
2.4.3
|
|
|
057568 |
|