|
|
4b6aa8 |
From 71b1c4b5322051320574f4de113e139e8aeb4b89 Mon Sep 17 00:00:00 2001
|
|
|
4b6aa8 |
From: Jakub Filak <jfilak@redhat.com>
|
|
|
4b6aa8 |
Date: Tue, 4 Nov 2014 15:29:06 +0100
|
|
|
4b6aa8 |
Subject: [LIBREPORT PATCH 117/118] testsuite: do not expected ureport exiting
|
|
|
4b6aa8 |
on rhsm cert errors
|
|
|
4b6aa8 |
|
|
|
4b6aa8 |
Related #1140224
|
|
|
4b6aa8 |
|
|
|
4b6aa8 |
Signed-off-by: Jakub Filak <jfilak@redhat.com>
|
|
|
4b6aa8 |
---
|
|
|
4b6aa8 |
tests/Makefile.am | 2 +-
|
|
|
4b6aa8 |
tests/ureport.at | 66 +++++++++++++++++++++++++++++++++++++++++--------------
|
|
|
4b6aa8 |
2 files changed, 51 insertions(+), 17 deletions(-)
|
|
|
4b6aa8 |
|
|
|
4b6aa8 |
diff --git a/tests/Makefile.am b/tests/Makefile.am
|
|
|
4b6aa8 |
index cda9375..1cfc206 100644
|
|
|
4b6aa8 |
--- a/tests/Makefile.am
|
|
|
4b6aa8 |
+++ b/tests/Makefile.am
|
|
|
4b6aa8 |
@@ -49,7 +49,7 @@ TESTSUITE = $(srcdir)/testsuite
|
|
|
4b6aa8 |
MAINTAINERCLEANFILES = Makefile.in $(TESTSUITE)
|
|
|
4b6aa8 |
check_DATA = atconfig atlocal $(TESTSUITE)
|
|
|
4b6aa8 |
DISTCLEANFILES = atconfig
|
|
|
4b6aa8 |
-EXTRA_DIST += atlocal.in conf
|
|
|
4b6aa8 |
+EXTRA_DIST += atlocal.in conf ureport
|
|
|
4b6aa8 |
|
|
|
4b6aa8 |
atconfig: $(top_builddir)/config.status
|
|
|
4b6aa8 |
(cd ${top_builddir} && ./config.status ${subdir}/atconfig)
|
|
|
4b6aa8 |
diff --git a/tests/ureport.at b/tests/ureport.at
|
|
|
4b6aa8 |
index 22d34e9..76e2f7a 100644
|
|
|
4b6aa8 |
--- a/tests/ureport.at
|
|
|
4b6aa8 |
+++ b/tests/ureport.at
|
|
|
4b6aa8 |
@@ -339,12 +339,24 @@ void set_ureport_server_config(struct ureport_server_config *config,
|
|
|
4b6aa8 |
|
|
|
4b6aa8 |
void my_assert(const char *str1, const char *str2)
|
|
|
4b6aa8 |
{
|
|
|
4b6aa8 |
- if (str1 == NULL || str2 == NULL)
|
|
|
4b6aa8 |
- assert( str1 == NULL && str2 == NULL );
|
|
|
4b6aa8 |
- else
|
|
|
4b6aa8 |
- assert(strcmp(str1, str2) == 0);
|
|
|
4b6aa8 |
+ if (str1 == str2)
|
|
|
4b6aa8 |
+ return;
|
|
|
4b6aa8 |
|
|
|
4b6aa8 |
- return;
|
|
|
4b6aa8 |
+ if (str1 == NULL && str2 != NULL)
|
|
|
4b6aa8 |
+ {
|
|
|
4b6aa8 |
+ fprintf(stderr, "Assertion failed: NULL == '%s'\n", str2);
|
|
|
4b6aa8 |
+ abort();
|
|
|
4b6aa8 |
+ }
|
|
|
4b6aa8 |
+ else if (str1 != NULL && str2 == NULL)
|
|
|
4b6aa8 |
+ {
|
|
|
4b6aa8 |
+ fprintf(stderr, "Assertion failed: '%s' == NULL\n", str1);
|
|
|
4b6aa8 |
+ abort();
|
|
|
4b6aa8 |
+ }
|
|
|
4b6aa8 |
+ else if (strcmp(str1, str2) != 0)
|
|
|
4b6aa8 |
+ {
|
|
|
4b6aa8 |
+ fprintf(stderr, "Assertion failed: '%s' == '%s'\n", str1, str2);
|
|
|
4b6aa8 |
+ abort();
|
|
|
4b6aa8 |
+ }
|
|
|
4b6aa8 |
}
|
|
|
4b6aa8 |
|
|
|
4b6aa8 |
void assert_ureport_server_config(struct ureport_server_config *config,
|
|
|
4b6aa8 |
@@ -365,8 +377,10 @@ void assert_ureport_server_config(struct ureport_server_config *config,
|
|
|
4b6aa8 |
return;
|
|
|
4b6aa8 |
}
|
|
|
4b6aa8 |
|
|
|
4b6aa8 |
-int test_ureport_server_config_set_client_auth_exit_code(struct ureport_server_config *config,
|
|
|
4b6aa8 |
- const char *client_auth)
|
|
|
4b6aa8 |
+int test_ureport_server_config_set_client_auth_exit_code_ext(struct ureport_server_config *config,
|
|
|
4b6aa8 |
+ const char *client_auth,
|
|
|
4b6aa8 |
+ const char *cert_file,
|
|
|
4b6aa8 |
+ const char *key_file)
|
|
|
4b6aa8 |
{
|
|
|
4b6aa8 |
ureport_server_config_init(config);
|
|
|
4b6aa8 |
|
|
|
4b6aa8 |
@@ -380,6 +394,8 @@ int test_ureport_server_config_set_client_auth_exit_code(struct ureport_server_c
|
|
|
4b6aa8 |
if (pid == 0)
|
|
|
4b6aa8 |
{
|
|
|
4b6aa8 |
ureport_server_config_set_client_auth(config, client_auth);
|
|
|
4b6aa8 |
+ assert((cert_file == (void *)-1) || (cert_file == NULL && config->ur_client_cert == NULL) || (strcmp(cert_file, config->ur_client_cert) == 0));
|
|
|
4b6aa8 |
+ assert((key_file == (void *)-1) || (key_file == NULL && config->ur_client_cert == NULL) || (strcmp(key_file, config->ur_client_key) == 0));
|
|
|
4b6aa8 |
exit(0);
|
|
|
4b6aa8 |
}
|
|
|
4b6aa8 |
int status;
|
|
|
4b6aa8 |
@@ -390,6 +406,12 @@ int test_ureport_server_config_set_client_auth_exit_code(struct ureport_server_c
|
|
|
4b6aa8 |
return status;
|
|
|
4b6aa8 |
}
|
|
|
4b6aa8 |
|
|
|
4b6aa8 |
+int test_ureport_server_config_set_client_auth_exit_code(struct ureport_server_config *config,
|
|
|
4b6aa8 |
+ const char *client_auth)
|
|
|
4b6aa8 |
+{
|
|
|
4b6aa8 |
+ return test_ureport_server_config_set_client_auth_exit_code_ext(config, client_auth, (void *)-1, (void *)-1);
|
|
|
4b6aa8 |
+}
|
|
|
4b6aa8 |
+
|
|
|
4b6aa8 |
int main(void)
|
|
|
4b6aa8 |
{
|
|
|
4b6aa8 |
g_verbose=3;
|
|
|
4b6aa8 |
@@ -418,8 +440,8 @@ int main(void)
|
|
|
4b6aa8 |
assert(empty_cert_dir);
|
|
|
4b6aa8 |
setenv("LIBREPORT_DEBUG_RHSMENT_PEM_DIR_PATH", empty_cert_dir, 1);
|
|
|
4b6aa8 |
|
|
|
4b6aa8 |
- int status = test_ureport_server_config_set_client_auth_exit_code(&config, "rhsm");
|
|
|
4b6aa8 |
- assert(status != 0 && status != -1);
|
|
|
4b6aa8 |
+ int status = test_ureport_server_config_set_client_auth_exit_code_ext(&config, "rhsm", NULL, NULL);
|
|
|
4b6aa8 |
+ assert(status == 0);
|
|
|
4b6aa8 |
|
|
|
4b6aa8 |
assert(rmdir(empty_cert_dir) == 0);
|
|
|
4b6aa8 |
|
|
|
4b6aa8 |
@@ -429,8 +451,8 @@ int main(void)
|
|
|
4b6aa8 |
|
|
|
4b6aa8 |
setenv("LIBREPORT_DEBUG_RHSMENT_PEM_DIR_PATH", TESTING_CERTS_INCORRECT_CONTENT_DIR_PATH, 1);
|
|
|
4b6aa8 |
|
|
|
4b6aa8 |
- status = test_ureport_server_config_set_client_auth_exit_code(&config, "rhsm");
|
|
|
4b6aa8 |
- assert(status != 0 && status != -1);
|
|
|
4b6aa8 |
+ status = test_ureport_server_config_set_client_auth_exit_code_ext(&config, "rhsm", NULL, NULL);
|
|
|
4b6aa8 |
+ assert(status == 0);
|
|
|
4b6aa8 |
|
|
|
4b6aa8 |
/* client_auth == rhsm */
|
|
|
4b6aa8 |
/* ur_url == NULL */
|
|
|
4b6aa8 |
@@ -548,12 +570,24 @@ AT_TESTFUN([ureport_server_config_set_basic_auth],
|
|
|
4b6aa8 |
|
|
|
4b6aa8 |
void my_assert(const char *str1, const char *str2)
|
|
|
4b6aa8 |
{
|
|
|
4b6aa8 |
- if (str1 == NULL || str2 == NULL)
|
|
|
4b6aa8 |
- assert( str1 == NULL && str2 == NULL );
|
|
|
4b6aa8 |
- else
|
|
|
4b6aa8 |
- assert(strcmp(str1, str2) == 0);
|
|
|
4b6aa8 |
+ if (str1 == str2)
|
|
|
4b6aa8 |
+ return;
|
|
|
4b6aa8 |
|
|
|
4b6aa8 |
- return;
|
|
|
4b6aa8 |
+ if (str1 == NULL && str2 != NULL)
|
|
|
4b6aa8 |
+ {
|
|
|
4b6aa8 |
+ fprintf(stderr, "Assertion failed: NULL == '%s'\n", str2);
|
|
|
4b6aa8 |
+ abort();
|
|
|
4b6aa8 |
+ }
|
|
|
4b6aa8 |
+ else if (str1 != NULL && str2 == NULL)
|
|
|
4b6aa8 |
+ {
|
|
|
4b6aa8 |
+ fprintf(stderr, "Assertion failed: '%s' == NULL\n", str1);
|
|
|
4b6aa8 |
+ abort();
|
|
|
4b6aa8 |
+ }
|
|
|
4b6aa8 |
+ else if (strcmp(str1, str2) != 0)
|
|
|
4b6aa8 |
+ {
|
|
|
4b6aa8 |
+ fprintf(stderr, "Assertion failed: '%s' == '%s'\n", str1, str2);
|
|
|
4b6aa8 |
+ abort();
|
|
|
4b6aa8 |
+ }
|
|
|
4b6aa8 |
}
|
|
|
4b6aa8 |
|
|
|
4b6aa8 |
void assert_ureport_server_config(struct ureport_server_config *config,
|
|
|
4b6aa8 |
--
|
|
|
4b6aa8 |
1.8.3.1
|
|
|
4b6aa8 |
|