From 42a83269dbc98ca19578d94335e9bf0144aa1254 Mon Sep 17 00:00:00 2001 From: Lukasz Wojciechowski Date: Tue, 28 Oct 2014 09:05:31 +0100 Subject: [PATCH] Provide CynaraTestAdmin namespace for admin classes CynaraTestAdmin contains all classes related to administrative cynara interface wrap in cynara-tests. CynaraTestAdmin class was renamed to simpler name Admin. Change-Id: Ic48a432346deaee5d55ff87640d9fb85a18457d2 --- tests/cynara-tests/common/cynara_test_admin.cpp | 23 +++++++------ tests/cynara-tests/common/cynara_test_admin.h | 14 +++++--- tests/cynara-tests/test_cases.cpp | 44 +++++++++++++------------ tests/cynara-tests/test_cases_async.cpp | 3 +- 4 files changed, 47 insertions(+), 37 deletions(-) diff --git a/tests/cynara-tests/common/cynara_test_admin.cpp b/tests/cynara-tests/common/cynara_test_admin.cpp index 9bafbb7..19362ad 100644 --- a/tests/cynara-tests/common/cynara_test_admin.cpp +++ b/tests/cynara-tests/common/cynara_test_admin.cpp @@ -22,6 +22,8 @@ #include #include +namespace CynaraTestAdmin { + namespace { @@ -93,7 +95,7 @@ void CynaraPoliciesContainer::add(const char *bucket, add(bucket, checkKey.m_client, checkKey.m_user, checkKey.m_privilege, result, resultExtra); } -CynaraTestAdmin::CynaraTestAdmin() +Admin::Admin() : m_admin(nullptr) { int ret = cynara_admin_initialize(&m_admin); @@ -102,13 +104,13 @@ CynaraTestAdmin::CynaraTestAdmin() RUNNER_ASSERT_MSG(m_admin != nullptr, "cynara_admin struct was not initialized"); } -CynaraTestAdmin::~CynaraTestAdmin() +Admin::~Admin() { cynara_admin_finish(m_admin); } -void CynaraTestAdmin::setPolicies(const CynaraPoliciesContainer &policiesContainer, - int expectedResult) +void Admin::setPolicies(const CynaraPoliciesContainer &policiesContainer, + int expectedResult) { const cynara_admin_policy *policies[policiesContainer.m_policies.size()+1]; @@ -124,8 +126,8 @@ void CynaraTestAdmin::setPolicies(const CynaraPoliciesContainer &policiesContain << "policies:\n" << policies); } -void CynaraTestAdmin::setBucket(const char *bucket, int operation, const char *extra, - int expectedResult) +void Admin::setBucket(const char *bucket, int operation, const char *extra, + int expectedResult) { int ret = cynara_admin_set_bucket(m_admin, bucket, operation, extra); RUNNER_ASSERT_MSG(ret == expectedResult, @@ -136,10 +138,10 @@ void CynaraTestAdmin::setBucket(const char *bucket, int operation, const char *e << " extra: " << formatCstr(extra)); } -void CynaraTestAdmin::adminCheck(const char *startBucket, int recursive, - const char *client, const char *user, const char *privilege, - int expectedCheckResult, const char *expectedCheckResultExtra, - int expectedResult) +void Admin::adminCheck(const char *startBucket, int recursive, + const char *client, const char *user, const char *privilege, + int expectedCheckResult, const char *expectedCheckResultExtra, + int expectedResult) { int checkResult; char *checkResultExtra = nullptr; @@ -186,3 +188,4 @@ void CynaraTestAdmin::adminCheck(const char *startBucket, int recursive, << dump()); } +} // namespace CynaraTestAdmin diff --git a/tests/cynara-tests/common/cynara_test_admin.h b/tests/cynara-tests/common/cynara_test_admin.h index 5116bc3..b153a64 100644 --- a/tests/cynara-tests/common/cynara_test_admin.h +++ b/tests/cynara-tests/common/cynara_test_admin.h @@ -22,7 +22,9 @@ #include #include -class CynaraTestAdmin; +namespace CynaraTestAdmin { + +class Admin; class CynaraPoliciesContainer { @@ -42,16 +44,16 @@ public: const char *resultExtra = nullptr); private: - friend class CynaraTestAdmin; + friend class Admin; std::vector m_policies; }; -class CynaraTestAdmin +class Admin { public: - CynaraTestAdmin(); - virtual ~CynaraTestAdmin(); + Admin(); + virtual ~Admin(); void setPolicies(const CynaraPoliciesContainer &policiesContainer, int expectedResult = CYNARA_API_SUCCESS); @@ -66,4 +68,6 @@ private: struct cynara_admin *m_admin; }; +} // namespace CynaraTestAdmin + #endif // CYNARA_TEST_ADMIN_H diff --git a/tests/cynara-tests/test_cases.cpp b/tests/cynara-tests/test_cases.cpp index a5c2bc7..e86ad9e 100644 --- a/tests/cynara-tests/test_cases.cpp +++ b/tests/cynara-tests/test_cases.cpp @@ -31,6 +31,8 @@ #include +using namespace CynaraTestAdmin; + void tc01_cynara_initialize_func() { CynaraTestClient(); @@ -38,7 +40,7 @@ void tc01_cynara_initialize_func() void tc02_admin_initialize_func() { - CynaraTestAdmin admin; + Admin admin; } void tc03_cynara_check_invalid_params_func() @@ -56,7 +58,7 @@ void tc03_cynara_check_invalid_params_func() cynara.check(client, session, user, nullptr, CYNARA_API_INVALID_PARAM); } -void checkInvalidPolicy(CynaraTestAdmin &admin, +void checkInvalidPolicy(Admin &admin, const char *bucket, const char *client, const char *user, @@ -72,7 +74,7 @@ void checkInvalidPolicy(CynaraTestAdmin &admin, void tc04_admin_set_policies_invalid_params_func() { - CynaraTestAdmin admin; + Admin admin; const char *bucket = CYNARA_ADMIN_DEFAULT_BUCKET; const char *client = "client04"; @@ -94,7 +96,7 @@ void tc04_admin_set_policies_invalid_params_func() void tc05_admin_set_bucket_invalid_params_func() { - CynaraTestAdmin admin; + Admin admin; const char *bucket = CYNARA_ADMIN_DEFAULT_BUCKET; const int operationAllow = CYNARA_ADMIN_ALLOW; @@ -134,7 +136,7 @@ void tc06_cynara_check_empty_admin2_func() void tc07_admin_set_bucket_admin_allow_deny_func() { - CynaraTestAdmin admin; + Admin admin; CynaraTestClient cynara; const char *bucket = CYNARA_ADMIN_DEFAULT_BUCKET; @@ -155,7 +157,7 @@ void tc07_admin_set_bucket_admin_allow_deny_func() void tc08_admin_set_policies_allow_remove1_func() { - CynaraTestAdmin admin; + Admin admin; CynaraTestClient cynara; const char *bucket = CYNARA_ADMIN_DEFAULT_BUCKET; @@ -211,7 +213,7 @@ void tc08_admin_set_policies_allow_remove1_func() void tc08_admin_set_policies_allow_remove2_func() { - CynaraTestAdmin admin; + Admin admin; CynaraTestClient cynara; const char *bucket = CYNARA_ADMIN_DEFAULT_BUCKET; @@ -260,7 +262,7 @@ void tc08_admin_set_policies_allow_remove2_func() void tc08_admin_set_policies_allow_remove3_func() { - CynaraTestAdmin admin; + Admin admin; CynaraTestClient cynara; const char *bucket = CYNARA_ADMIN_DEFAULT_BUCKET; @@ -351,7 +353,7 @@ void setSingleWildcardPolicies(const char *bucket, const std::vector< std::vector > &data, const int result, const char* resultExtra) { - CynaraTestAdmin admin; + Admin admin; CynaraPoliciesContainer cp; checkSingleWildcardData(data); @@ -394,7 +396,7 @@ void tc09_admin_set_policies_wildcard_accesses_func() void tc10_admin_change_extra_bucket_func() { - CynaraTestAdmin admin; + Admin admin; CynaraTestClient cynara; const char *bucketDefault = CYNARA_ADMIN_DEFAULT_BUCKET; @@ -454,7 +456,7 @@ void tc10_admin_change_extra_bucket_func() void tc11_admin_bucket_not_found_func() { - CynaraTestAdmin admin; + Admin admin; CynaraTestClient cynara; const char *bucketDefault = CYNARA_ADMIN_DEFAULT_BUCKET; @@ -478,7 +480,7 @@ void tc11_admin_bucket_not_found_func() void tc12_admin_delete_bucket_with_policies_pointing_to_it_func() { - CynaraTestAdmin admin; + Admin admin; CynaraTestClient cynara; const char *bucketDefault = CYNARA_ADMIN_DEFAULT_BUCKET; @@ -512,7 +514,7 @@ void tc12_admin_delete_bucket_with_policies_pointing_to_it_func() void tc13_admin_set_policies_to_extra_bucket_func() { - CynaraTestAdmin admin; + Admin admin; CynaraTestClient cynara; const char *bucketDefault = CYNARA_ADMIN_DEFAULT_BUCKET; @@ -559,7 +561,7 @@ void tc14_admin_set_policies_integrity_func() } { - CynaraTestAdmin admin; + Admin admin; CynaraPoliciesContainer cp; cp.add(bucketDefault, client, user, privilege, @@ -578,7 +580,7 @@ void tc14_admin_set_policies_integrity_func() void tc15_admin_set_bucket_admin_none1_func() { - CynaraTestAdmin admin; + Admin admin; CynaraTestClient cynara; const char *bucketDefault = CYNARA_ADMIN_DEFAULT_BUCKET; @@ -607,7 +609,7 @@ void tc15_admin_set_bucket_admin_none1_func() void tc15_admin_set_bucket_admin_none2_func() { - CynaraTestAdmin admin; + Admin admin; CynaraTestClient cynara; const char *bucketDefault = CYNARA_ADMIN_DEFAULT_BUCKET; @@ -632,7 +634,7 @@ void tc15_admin_set_bucket_admin_none2_func() void tc15_admin_set_bucket_admin_none3_func() { - CynaraTestAdmin admin; + Admin admin; CynaraTestClient cynara; const char *bucketDefault = CYNARA_ADMIN_DEFAULT_BUCKET; @@ -669,7 +671,7 @@ void tc16_admin_check_single_bucket_func() int recursive = 1; int notrecursive = 0; - CynaraTestAdmin admin; + Admin admin; admin.adminCheck(bucketDefault, recursive, client, user, privilege, CYNARA_ADMIN_DENY, nullptr, CYNARA_API_SUCCESS); @@ -700,7 +702,7 @@ void tc17_admin_check_nested_bucket_func() int recursive = 1; int notrecursive = 0; - CynaraTestAdmin admin; + Admin admin; admin.setBucket(bucket, CYNARA_ADMIN_DENY, extra); admin.adminCheck(bucketDefault, recursive, client, user, privilege, @@ -745,7 +747,7 @@ void tc18_admin_check_multiple_matches_func() int recursive = 1; int notrecursive = 0; - CynaraTestAdmin admin; + Admin admin; auto check = [&](int expected_result) { @@ -814,7 +816,7 @@ void tc19_admin_check_none_bucket_func() int recursive = 1; int notrecursive = 0; - CynaraTestAdmin admin; + Admin admin; admin.setBucket(bucket1, CYNARA_ADMIN_NONE, extra); admin.setBucket(bucket2, CYNARA_ADMIN_ALLOW, extra); diff --git a/tests/cynara-tests/test_cases_async.cpp b/tests/cynara-tests/test_cases_async.cpp index ba8fb2d..29626e6c 100644 --- a/tests/cynara-tests/test_cases_async.cpp +++ b/tests/cynara-tests/test_cases_async.cpp @@ -33,6 +33,7 @@ #include using namespace CynaraTestClientAsync; +using namespace CynaraTestAdmin; void tca01_initialize_func() { @@ -172,7 +173,7 @@ void tca06_cancel_fail_func() void tca07_request_with_data_insertion_func() { std::string testNo("07"); - CynaraTestAdmin admin; + Admin admin; const char *bucket = CYNARA_ADMIN_DEFAULT_BUCKET; const int resultAllow = CYNARA_ADMIN_ALLOW; CheckData data[2] = {{testNo, 1}, {testNo, 2}}; -- 2.7.4