[UTC][http][ACR-663][Add test cases for authentication APIs]
authorSeonah Moon <seonah1.moon@samsung.com>
Mon, 20 Jun 2016 02:26:56 +0000 (11:26 +0900)
committerseonah moon <seonah1.moon@samsung.com>
Mon, 20 Jun 2016 04:22:17 +0000 (21:22 -0700)
Change-Id: Ibab6bb94000bb627a6934ba1a05e5c1a33adfe6a
Signed-off-by: Seonah Moon <seonah1.moon@samsung.com>
src/utc/http/tct-http-core_mobile.h
src/utc/http/tct-http-core_wearable.h
src/utc/http/utc-network-http.c

index 68f274d..d516030 100755 (executable)
@@ -93,6 +93,16 @@ extern int utc_http_transaction_request_get_cookie_n(void);
 extern int utc_http_transaction_request_get_cookie_p(void);
 extern int utc_http_transaction_request_write_body_n(void);
 extern int utc_http_transaction_request_write_body_p(void);
+extern int utc_http_transaction_set_http_auth_scheme_n(void);
+extern int utc_http_transaction_set_http_auth_scheme_p(void);
+extern int utc_http_transaction_get_http_auth_scheme_n(void);
+extern int utc_http_transaction_get_http_auth_scheme_p(void);
+extern int utc_http_transaction_set_credentials_n(void);
+extern int utc_http_transaction_set_credentials_p(void);
+extern int utc_http_transaction_get_credentials_n(void);
+extern int utc_http_transaction_get_credentials_p(void);
+extern int utc_http_transaction_open_authentication_n(void);
+extern int utc_http_transaction_open_authentication_p(void);
 extern int utc_http_transaction_submit_n(void);
 extern int utc_http_transaction_submit_p(void);
 extern int utc_http_deinit_n(void);
@@ -171,6 +181,16 @@ testcase tc_array[] = {
        {"utc_http_transaction_request_get_cookie_p", utc_http_transaction_request_get_cookie_p, utc_http_startup, utc_http_cleanup},
        {"utc_http_transaction_request_write_body_n", utc_http_transaction_request_write_body_n, utc_http_startup, utc_http_cleanup},
        {"utc_http_transaction_request_write_body_p", utc_http_transaction_request_write_body_p, utc_http_startup, utc_http_cleanup},
+       {"utc_http_transaction_set_http_auth_scheme_n", utc_http_transaction_set_http_auth_scheme_n, utc_http_startup, utc_http_cleanup},
+       {"utc_http_transaction_set_http_auth_scheme_p", utc_http_transaction_set_http_auth_scheme_p, utc_http_startup, utc_http_cleanup},
+       {"utc_http_transaction_get_http_auth_scheme_n", utc_http_transaction_get_http_auth_scheme_n, utc_http_startup, utc_http_cleanup},
+       {"utc_http_transaction_get_http_auth_scheme_p", utc_http_transaction_get_http_auth_scheme_p, utc_http_startup, utc_http_cleanup},
+       {"utc_http_transaction_set_credentials_n", utc_http_transaction_set_credentials_n, utc_http_startup, utc_http_cleanup},
+       {"utc_http_transaction_set_credentials_p", utc_http_transaction_set_credentials_p, utc_http_startup, utc_http_cleanup},
+       {"utc_http_transaction_get_credentials_n", utc_http_transaction_get_credentials_n, utc_http_startup, utc_http_cleanup},
+       {"utc_http_transaction_get_credentials_p", utc_http_transaction_get_credentials_p, utc_http_startup, utc_http_cleanup},
+       {"utc_http_transaction_open_authentication_n", utc_http_transaction_open_authentication_n, utc_http_startup, utc_http_cleanup},
+       {"utc_http_transaction_open_authentication_p", utc_http_transaction_open_authentication_p, utc_http_startup, utc_http_cleanup},
        {"utc_http_transaction_submit_n", utc_http_transaction_submit_n, utc_http_startup, utc_http_cleanup},
        {"utc_http_transaction_submit_p", utc_http_transaction_submit_p, utc_http_startup, utc_http_cleanup},
        {"utc_http_deinit_p", utc_http_deinit_p, utc_http_startup, utc_http_cleanup},
index 68f274d..d516030 100755 (executable)
@@ -93,6 +93,16 @@ extern int utc_http_transaction_request_get_cookie_n(void);
 extern int utc_http_transaction_request_get_cookie_p(void);
 extern int utc_http_transaction_request_write_body_n(void);
 extern int utc_http_transaction_request_write_body_p(void);
+extern int utc_http_transaction_set_http_auth_scheme_n(void);
+extern int utc_http_transaction_set_http_auth_scheme_p(void);
+extern int utc_http_transaction_get_http_auth_scheme_n(void);
+extern int utc_http_transaction_get_http_auth_scheme_p(void);
+extern int utc_http_transaction_set_credentials_n(void);
+extern int utc_http_transaction_set_credentials_p(void);
+extern int utc_http_transaction_get_credentials_n(void);
+extern int utc_http_transaction_get_credentials_p(void);
+extern int utc_http_transaction_open_authentication_n(void);
+extern int utc_http_transaction_open_authentication_p(void);
 extern int utc_http_transaction_submit_n(void);
 extern int utc_http_transaction_submit_p(void);
 extern int utc_http_deinit_n(void);
@@ -171,6 +181,16 @@ testcase tc_array[] = {
        {"utc_http_transaction_request_get_cookie_p", utc_http_transaction_request_get_cookie_p, utc_http_startup, utc_http_cleanup},
        {"utc_http_transaction_request_write_body_n", utc_http_transaction_request_write_body_n, utc_http_startup, utc_http_cleanup},
        {"utc_http_transaction_request_write_body_p", utc_http_transaction_request_write_body_p, utc_http_startup, utc_http_cleanup},
+       {"utc_http_transaction_set_http_auth_scheme_n", utc_http_transaction_set_http_auth_scheme_n, utc_http_startup, utc_http_cleanup},
+       {"utc_http_transaction_set_http_auth_scheme_p", utc_http_transaction_set_http_auth_scheme_p, utc_http_startup, utc_http_cleanup},
+       {"utc_http_transaction_get_http_auth_scheme_n", utc_http_transaction_get_http_auth_scheme_n, utc_http_startup, utc_http_cleanup},
+       {"utc_http_transaction_get_http_auth_scheme_p", utc_http_transaction_get_http_auth_scheme_p, utc_http_startup, utc_http_cleanup},
+       {"utc_http_transaction_set_credentials_n", utc_http_transaction_set_credentials_n, utc_http_startup, utc_http_cleanup},
+       {"utc_http_transaction_set_credentials_p", utc_http_transaction_set_credentials_p, utc_http_startup, utc_http_cleanup},
+       {"utc_http_transaction_get_credentials_n", utc_http_transaction_get_credentials_n, utc_http_startup, utc_http_cleanup},
+       {"utc_http_transaction_get_credentials_p", utc_http_transaction_get_credentials_p, utc_http_startup, utc_http_cleanup},
+       {"utc_http_transaction_open_authentication_n", utc_http_transaction_open_authentication_n, utc_http_startup, utc_http_cleanup},
+       {"utc_http_transaction_open_authentication_p", utc_http_transaction_open_authentication_p, utc_http_startup, utc_http_cleanup},
        {"utc_http_transaction_submit_n", utc_http_transaction_submit_n, utc_http_startup, utc_http_cleanup},
        {"utc_http_transaction_submit_p", utc_http_transaction_submit_p, utc_http_startup, utc_http_cleanup},
        {"utc_http_deinit_p", utc_http_deinit_p, utc_http_startup, utc_http_cleanup},
index 8a4da5f..f1ce916 100755 (executable)
@@ -2143,6 +2143,290 @@ int utc_http_transaction_request_write_body_p(void)
 }
 
 /**
+ * @testcase           utc_http_transaction_set_http_auth_scheme_n
+ * @since_tizen     3.0
+ * @type               Negative
+ * @description                Sets an HTTP authentication scheme.
+ * @scenario           Invoking http_transaction_set_http_auth_scheme with invalid parameter.
+ */
+int utc_http_transaction_set_http_auth_scheme_n(void)
+{
+       int ret;
+       http_auth_scheme_e auth_scheme = HTTP_AUTH_WWW_BASIC;
+
+#ifdef WEARABLE
+       if (g_internet_supported == false) {
+               ret = http_transaction_set_http_auth_scheme(NULL, auth_scheme);
+               assert_eq(ret, TIZEN_ERROR_NOT_SUPPORTED);
+               return 0;
+       }
+#endif
+
+       ret = http_transaction_set_http_auth_scheme(NULL, auth_scheme);
+       assert_eq(ret, HTTP_ERROR_INVALID_PARAMETER);
+
+       return 0;
+}
+
+/**
+ * @testcase           utc_http_transaction_set_http_auth_scheme_p
+ * @since_tizen     3.0
+ * @type               Positive
+ * @description                Sets an HTTP authentication scheme.
+ * @scenario           Invoking http_transaction_set_http_auth_scheme with valid parameter.
+ */
+int utc_http_transaction_set_http_auth_scheme_p(void)
+{
+       int ret;
+       http_auth_scheme_e auth_scheme = HTTP_AUTH_WWW_BASIC;
+
+#ifdef WEARABLE
+       if (g_internet_supported == false) {
+               ret = http_transaction_set_http_auth_scheme(transaction, auth_scheme);
+               assert_eq(ret, TIZEN_ERROR_NOT_SUPPORTED);
+               return 0;
+       }
+#endif
+
+       ret = http_transaction_set_http_auth_scheme(transaction, auth_scheme);
+       assert_eq(ret, HTTP_ERROR_NONE);
+
+       return 0;
+}
+
+/**
+ * @testcase           utc_http_transaction_get_http_auth_scheme_n
+ * @since_tizen     3.0
+ * @type               Negative
+ * @description                Gets the HTTP authentication scheme.
+ * @scenario           Invoking http_transaction_get_http_auth_scheme with invalid parameter.
+ */
+int utc_http_transaction_get_http_auth_scheme_n(void)
+{
+       int ret;
+       http_auth_scheme_e auth_scheme;
+
+#ifdef WEARABLE
+       if (g_internet_supported == false) {
+               ret = http_transaction_get_http_auth_scheme(NULL, NULL);
+               assert_eq(ret, TIZEN_ERROR_NOT_SUPPORTED);
+               return 0;
+       }
+#endif
+
+       ret = http_transaction_get_http_auth_scheme(transaction, NULL);
+       assert_eq(ret, HTTP_ERROR_INVALID_PARAMETER);
+       ret = http_transaction_get_http_auth_scheme(NULL, &auth_scheme);
+       assert_eq(ret, HTTP_ERROR_INVALID_PARAMETER);
+       ret = http_transaction_get_http_auth_scheme(NULL, NULL);
+       assert_eq(ret, HTTP_ERROR_INVALID_PARAMETER);
+
+       return 0;
+}
+
+/**
+ * @testcase           utc_http_transaction_get_http_auth_scheme_p
+ * @since_tizen     3.0
+ * @type               Positive
+ * @description                Gets the HTTP authentication scheme.
+ * @scenario           Invoking http_transaction_get_http_auth_scheme with valid parameter.
+ */
+int utc_http_transaction_get_http_auth_scheme_p(void)
+{
+       int ret;
+       http_auth_scheme_e auth_scheme;
+
+#ifdef WEARABLE
+       if (g_internet_supported == false) {
+               ret = http_transaction_get_http_auth_scheme(transaction, auth_scheme);
+               assert_eq(ret, TIZEN_ERROR_NOT_SUPPORTED);
+               return 0;
+       }
+#endif
+
+       ret = http_transaction_set_http_auth_scheme(transaction, HTTP_AUTH_WWW_BASIC);
+       assert_eq(ret, HTTP_ERROR_NONE);
+       ret = http_transaction_get_http_auth_scheme(transaction, &auth_scheme);
+       assert_eq(ret, HTTP_ERROR_NONE);
+
+       return 0;
+}
+
+/**
+ * @testcase           utc_http_transaction_set_credentials_n
+ * @since_tizen     3.0
+ * @type               Negative
+ * @description                Sets an HTTP credentials.
+ * @scenario           Invoking http_transaction_set_credentials with invalid parameter.
+ */
+int utc_http_transaction_set_credentials_n(void)
+{
+       int ret;
+       const char user_name[10] = "tizen";
+       const char password[10] = "q1w2e3r4";
+
+#ifdef WEARABLE
+       if (g_internet_supported == false) {
+               ret = http_transaction_set_credentials(NULL, NULL, NULL);
+               assert_eq(ret, TIZEN_ERROR_NOT_SUPPORTED);
+               return 0;
+       }
+#endif
+
+       ret = http_transaction_set_credentials(transaction, user_name, NULL);
+       assert_eq(ret, HTTP_ERROR_INVALID_PARAMETER);
+       ret = http_transaction_set_credentials(transaction, NULL, password);
+       assert_eq(ret, HTTP_ERROR_INVALID_PARAMETER);
+       ret = http_transaction_set_credentials(NULL, user_name, password);
+       assert_eq(ret, HTTP_ERROR_INVALID_PARAMETER);
+       ret = http_transaction_set_credentials(NULL, NULL, NULL);
+       assert_eq(ret, HTTP_ERROR_INVALID_PARAMETER);
+
+       return 0;
+}
+
+/**
+ * @testcase           utc_http_transaction_set_credentials_p
+ * @since_tizen     3.0
+ * @type               Positive
+ * @description                Sets an HTTP credentials.
+ * @scenario           Invoking http_transaction_set_credentials  with valid parameter.
+ */
+int utc_http_transaction_set_credentials_p(void)
+{
+       int ret;
+       const char user_name[10] = "tizen";
+       const char password[10] = "q1w2e3r4";
+
+#ifdef WEARABLE
+       if (g_internet_supported == false) {
+               ret = http_transaction_set_credentials(transaction, user_name, password);
+               assert_eq(ret, TIZEN_ERROR_NOT_SUPPORTED);
+               return 0;
+       }
+#endif
+       ret = http_transaction_set_credentials(transaction, user_name, password);
+       assert_eq(ret, HTTP_ERROR_NONE);
+
+       return 0;
+}
+
+/**
+ * @testcase           utc_http_transaction_get_credentials_n
+ * @since_tizen     3.0
+ * @type               Negative
+ * @description                Gets the username & password for the http credential.
+ * @scenario           Invoking http_transaction_get_credentials with invalid parameter.
+ */
+int utc_http_transaction_get_credentials_n(void)
+{
+       int ret;
+       char *user_name;
+       char *password;
+
+#ifdef WEARABLE
+       if (g_internet_supported == false) {
+               ret = http_transaction_get_credentials(NULL, NULL, NULL);
+               assert_eq(ret, TIZEN_ERROR_NOT_SUPPORTED);
+               return 0;
+       }
+#endif
+
+       ret = http_transaction_set_credentials(transaction, "tizen", "q1w2e3r4");
+       assert_eq(ret, HTTP_ERROR_NONE);
+       ret = http_transaction_get_credentials(transaction, &user_name, NULL);
+       assert_eq(ret, HTTP_ERROR_INVALID_PARAMETER);
+       ret = http_transaction_get_credentials(transaction, NULL, &password);
+       assert_eq(ret, HTTP_ERROR_INVALID_PARAMETER);
+       ret = http_transaction_get_credentials(NULL, &user_name, &password);
+       assert_eq(ret, HTTP_ERROR_INVALID_PARAMETER);
+       ret = http_transaction_get_credentials(NULL, NULL, NULL);
+       assert_eq(ret, HTTP_ERROR_INVALID_PARAMETER);
+
+       return 0;
+}
+
+/**
+ * @testcase           utc_http_transaction_get_credentials_p
+ * @since_tizen     3.0
+ * @type               Positive
+ * @description                Gets the username & password for the http credential.
+ * @scenario           Invoking http_transaction_get_credentials with valid parameter.
+ */
+int utc_http_transaction_get_credentials_p(void)
+{
+       int ret;
+       char *user_name;
+       char *password;
+
+#ifdef WEARABLE
+       if (g_internet_supported == false) {
+               ret = http_transaction_get_credentials(transaction, &user_name, &password);
+               assert_eq(ret, TIZEN_ERROR_NOT_SUPPORTED);
+               return 0;
+       }
+#endif
+       ret = http_transaction_set_credentials(transaction, "tizen", "q1w2e3r4");
+       assert_eq(ret, HTTP_ERROR_NONE);
+       ret = http_transaction_get_credentials(transaction, &user_name, &password);
+       assert_eq(ret, HTTP_ERROR_NONE);
+
+       return 0;
+}
+
+/**
+ * @testcase           utc_http_transaction_open_authentication_n
+ * @since_tizen     3.0
+ * @type               Negative
+ * @description                Opens HTTP transaction with authentication information.
+ * @scenario           Invoking http_transaction_open_authentication with invalid parameter.
+ */
+int utc_http_transaction_open_authentication_n(void)
+{
+       int ret;
+       http_transaction_h http_auth_transaction;
+
+#ifdef WEARABLE
+       if (g_internet_supported == false) {
+               ret = http_transaction_open_authentication(NULL, &http_auth_transaction);
+               assert_eq(ret, TIZEN_ERROR_NOT_SUPPORTED);
+               return 0;
+       }
+#endif
+
+       ret = http_transaction_open_authentication(NULL, &http_auth_transaction);
+       assert_eq(ret, HTTP_ERROR_INVALID_PARAMETER);
+
+       return 0;
+}
+
+/**
+ * @testcase           utc_http_transaction_open_authentication_p
+ * @since_tizen     3.0
+ * @type               Positive
+ * @description                Opens HTTP transaction with authentication information.
+ * @scenario           Invoking http_transaction_open_authentication with valid parameter.
+ */
+int utc_http_transaction_open_authentication_p(void)
+{
+       int ret;
+       http_transaction_h http_auth_transaction;
+
+#ifdef WEARABLE
+       if (g_internet_supported == false) {
+               ret = http_transaction_open_authentication(transaction, &http_auth_transaction);
+               assert_eq(ret, TIZEN_ERROR_NOT_SUPPORTED);
+               return 0;
+       }
+#endif
+
+       ret = http_transaction_open_authentication(transaction, &http_auth_transaction);
+       assert_eq(ret, HTTP_ERROR_NONE);
+
+       return 0;
+}
+
+/**
  * @testcase        utc_http_transaction_submit_n
  * @since_tizen     3.0
  * @type               Negative