summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArkadiusz Nowak <a.nowak3@samsung.com>2022-07-18 09:15:40 +0200
committerArkadiusz Nowak <a.nowak3@samsung.com>2022-07-19 12:43:10 +0200
commit0a2ce368b877d51a42792fed77287e13bf76db3c (patch)
tree8bf317174c0e8c6f20f7771d81b56e2c05a07988
parent330e4429171a18f5f28e49c915c507572deff539 (diff)
downloadsessiond-0a2ce368b877d51a42792fed77287e13bf76db3c.tar.gz
sessiond-0a2ce368b877d51a42792fed77287e13bf76db3c.tar.bz2
sessiond-0a2ce368b877d51a42792fed77287e13bf76db3c.zip
User len 19 and len 20 tests
Change-Id: Ibf7710a0248fdd0dfcafa885a1b6d9687fcce6b3
-rw-r--r--libsessiond/src/lib.c2
-rw-r--r--libsessiond/target_test/test_api_add_remove_user.cpp18
-rw-r--r--libsessiond/target_test/test_api_add_remove_user_err.cpp15
-rw-r--r--libsessiond/target_test/test_api_switchuser_err.cpp8
-rw-r--r--libsessiond/target_test/test_hlp.hpp14
5 files changed, 40 insertions, 17 deletions
diff --git a/libsessiond/src/lib.c b/libsessiond/src/lib.c
index c6a4ebf..ae5683f 100644
--- a/libsessiond/src/lib.c
+++ b/libsessiond/src/lib.c
@@ -124,7 +124,6 @@ typedef struct {
void *reply_data;
} reply_client_data_t;
-
static int is_user_id_null(const char *user_id) {
if(user_id == NULL) {
LOGE("user_id is NULL");
@@ -133,7 +132,6 @@ static int is_user_id_null(const char *user_id) {
return FALSE;
}
-
static int has_added_user_correct_length(const char *user_id) {
if(strnlen(user_id, SUBSESSION_USER_MAXLEN) > SUBSESSION_USER_MAXLEN-1) {
diff --git a/libsessiond/target_test/test_api_add_remove_user.cpp b/libsessiond/target_test/test_api_add_remove_user.cpp
index a89e36c..0c80280 100644
--- a/libsessiond/target_test/test_api_add_remove_user.cpp
+++ b/libsessiond/target_test/test_api_add_remove_user.cpp
@@ -9,7 +9,7 @@
#include "test_hlp.hpp"
-const int action_items = 2;
+const int action_items = 4;
TEST(subsession_add_remove_user_test, APIAddRemoveUserTest) {
@@ -22,13 +22,25 @@ TEST(subsession_add_remove_user_test, APIAddRemoveUserTest) {
.expected = SUBSESSION_ERROR_NONE,
.desc = "Check if add " + std::string(TestUserStr::user_1) + " is successful",
.cb_expected = SUBSESSION_ERROR_NONE,
- .cb_desc = "Check if add " + std::string(TestUserStr::user_1) + "callback is successful", },
+ .cb_desc = "Check if add " + std::string(TestUserStr::user_1) + " callback is successful", },
api_call_res_t{ .call_result = std::move(subsession_remove_user_l<subsession_5001>(TestUserStr::user_1)),
.expected = SUBSESSION_ERROR_NONE,
.desc = "Check if remove " + std::string(TestUserStr::user_1) + " is successful",
.cb_expected = SUBSESSION_ERROR_NONE,
- .cb_desc = "Check if remove " + std::string(TestUserStr::user_1) + "callback is successful", },
+ .cb_desc = "Check if remove " + std::string(TestUserStr::user_1) + " callback is successful", },
+
+ api_call_res_t{ .call_result = std::move(subsession_add_user_l<subsession_5001>( TestUserStr::user_19)),
+ .expected = SUBSESSION_ERROR_NONE,
+ .desc = "Check if add " + std::string(TestUserStr::user_19) + " is successful",
+ .cb_expected = SUBSESSION_ERROR_NONE,
+ .cb_desc = "Check if add " + std::string(TestUserStr::user_19) + " callback is successful", },
+
+ api_call_res_t{ .call_result = std::move(subsession_remove_user_l<subsession_5001>(TestUserStr::user_19)),
+ .expected = SUBSESSION_ERROR_NONE,
+ .desc = "Check if remove " + std::string(TestUserStr::user_19) + " is successful",
+ .cb_expected = SUBSESSION_ERROR_NONE,
+ .cb_desc = "Check if remove " + std::string(TestUserStr::user_19) + " callback is successful", },
}
};
diff --git a/libsessiond/target_test/test_api_add_remove_user_err.cpp b/libsessiond/target_test/test_api_add_remove_user_err.cpp
index 45fcf43..978908b 100644
--- a/libsessiond/target_test/test_api_add_remove_user_err.cpp
+++ b/libsessiond/target_test/test_api_add_remove_user_err.cpp
@@ -9,7 +9,7 @@
#include "test_hlp.hpp"
-const int action_items = 11;
+const int action_items = 13;
TEST(subsession_add_remove_test, FailAtAddRemoveUser) {
using ud_t = ud_data_t<std::array<api_call_res_t, action_items>>;
@@ -83,6 +83,19 @@ TEST(subsession_add_remove_test, FailAtAddRemoveUser) {
.cb_expected = SUBSESSION_ERROR_INVALID_PARAMETER,
.cb_desc = "Check if remove [ " + std::string(TestBadUserStr::bad_user_long) + " ] callback returns error", },
+ api_call_res_t{ .call_result = std::move(subsession_add_user_l<subsession_5001>( TestBadUserStr::bad_user_20)),
+ .expected = SUBSESSION_ERROR_INVALID_PARAMETER,
+ .desc = "Check if add [ " + std::string(TestBadUserStr::bad_user_20) + " ] returns error",
+ .cb_expected = SUBSESSION_ERROR_INVALID_PARAMETER,
+ .cb_desc = "Check if add [ " + std::string(TestBadUserStr::bad_user_20) + " ] callback returns error", },
+
+ api_call_res_t{ .call_result = std::move(subsession_remove_user_l<subsession_5001>( TestBadUserStr::bad_user_20)),
+ .expected = SUBSESSION_ERROR_INVALID_PARAMETER,
+ .desc = "Check if remove [ " + std::string(TestBadUserStr::bad_user_20) + " ] returns error",
+ .cb_expected = SUBSESSION_ERROR_INVALID_PARAMETER,
+ .cb_desc = "Check if remove [ " + std::string(TestBadUserStr::bad_user_20) + " ] callback returns error", },
+
+
}
};
diff --git a/libsessiond/target_test/test_api_switchuser_err.cpp b/libsessiond/target_test/test_api_switchuser_err.cpp
index e89a649..0ca6bd7 100644
--- a/libsessiond/target_test/test_api_switchuser_err.cpp
+++ b/libsessiond/target_test/test_api_switchuser_err.cpp
@@ -6,7 +6,7 @@
#include "test_hlp.hpp"
-const int action_items = 11;
+const int action_items = 12;
TEST(subsession_switch_user_test, FailAtSwitchUser) {
@@ -38,6 +38,12 @@ TEST(subsession_switch_user_test, FailAtSwitchUser) {
.cb_expected = SUBSESSION_ERROR_INVALID_PARAMETER,
.cb_desc = "Check if switch to non existing [" + std::string(TestBadUserStr::bad_user_3) + " ] callback returns error", },
+ api_call_res_t{ .call_result = std::move(subsession_switch_user_l<subsession_5001>( TestBadUserStr::bad_user_20)),
+ .expected = SUBSESSION_ERROR_INVALID_PARAMETER,
+ .desc = "Check if switch to [ " + std::string(TestBadUserStr::bad_user_20) + " ] returns error",
+ .cb_expected = SUBSESSION_ERROR_INVALID_PARAMETER,
+ .cb_desc = "Check if switch to non existing [" + std::string(TestBadUserStr::bad_user_20) + " ] callback returns error", },
+
api_call_res_t{ .call_result = std::move(subsession_add_user_l<subsession_5001>( TestUserStr::user_1)),
.expected = SUBSESSION_ERROR_NONE,
.desc = "Check if add [ " + std::string(TestUserStr::user_1) + " ] returns no error",
diff --git a/libsessiond/target_test/test_hlp.hpp b/libsessiond/target_test/test_hlp.hpp
index ee0af2d..8c8b9b3 100644
--- a/libsessiond/target_test/test_hlp.hpp
+++ b/libsessiond/target_test/test_hlp.hpp
@@ -27,6 +27,7 @@ namespace TestUserStr {
[[maybe_unused]] static subsession_user_t user_1 = "user_1";
[[maybe_unused]] static subsession_user_t user_2 = "user_2";
[[maybe_unused]] static subsession_user_t user_3 = "user_3";
+ [[maybe_unused]] static subsession_user_t user_19 = "user__length__is_19";
};
namespace TestBadUserStr {
@@ -36,9 +37,11 @@ namespace TestBadUserStr {
[[maybe_unused]] static subsession_user_t bad_user_3 = "user_3/user_3";
[[maybe_unused]] static subsession_user_t bad_user_empty = "";
[[maybe_unused]] static char bad_user_long[] = "too_long_user_name___";
+ //Below filled subsession_user_t array without '\0' (null) terminator, use only for testing.
+ [[maybe_unused]] static subsession_user_t bad_user_20 = {'1','2','3','4','5','6','7','8','9','0','1','2','3','4','5','6',
+ '7','8','9','0'};
};
-
static constexpr int MAGIC_ADD = 111;
static constexpr int MAGIC_REMOVE = 222;
static constexpr int MAGIC_SWITCH = 333;
@@ -49,7 +52,6 @@ static constexpr int MAGIC_EVENT_REMOVE = 777;
static constexpr int MAGIC_EVENT_SWITCH = 888;
static constexpr int MAGIC_EVENT_SWITCH_COMPLETION = 999;
-
const int got = 0;
const int expected = 1;
const int desc = 2;
@@ -75,7 +77,6 @@ struct test_user_data_cb_t {
int magic{MAGIC_DEFAULT};
};
-
typedef struct {
int session_uid;
int callback_reference{1};
@@ -166,8 +167,6 @@ void init_user_s(test_user_data_cb_t& arg) {
arg.magic=MAGIC_DEFAULT;
}
-
-
template<typename T = test_get_user_list_res_t& , typename S>
void init_user_s(test_get_user_list_res_t& arg) {
arg.session_uid = S::subsession_uid();
@@ -175,8 +174,6 @@ void init_user_s(test_get_user_list_res_t& arg) {
arg.user_list = NULL;
}
-
-
/*
template<typename T = test_user_data_cb_t, typename S>
void init_user_s(test_user_data_cb_t& arg) {
@@ -197,11 +194,9 @@ void atomic_set_0(T arg, V... args) {
return;
}
-
/* Magic constants set by various callbacks
* to verify whether they were called. */
-
void test_reply_callback_default (int result, void *cb_data) {
//std::cout << "call callback default" << std::endl;
@@ -553,7 +548,6 @@ void loop_run_for_test(GSourceFunc f, gpointer data, GMainLoop *loop) {
//using res_t = std::tuple<int, int, std::string>;
-
template<int N>
void summarize_results(std::array<res_t, N> &results) {
std::for_each(results.begin(), results.end(), [=](res_t &res) {