From e0b08a3c810cc07e8fc3b7b015d7ffde09fc4dee Mon Sep 17 00:00:00 2001 From: Marcin Niesluchowski Date: Wed, 20 Aug 2014 11:13:28 +0200 Subject: [PATCH] Add tests for none bucket Change-Id: I546ded4f234470ab3754338080ab9800dde18279 --- tests/cynara-tests/test_cases.cpp | 89 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 89 insertions(+) diff --git a/tests/cynara-tests/test_cases.cpp b/tests/cynara-tests/test_cases.cpp index afc8c03..4ecf525 100644 --- a/tests/cynara-tests/test_cases.cpp +++ b/tests/cynara-tests/test_cases.cpp @@ -112,6 +112,7 @@ void tc04_admin_set_policies_invalid_params_func() const char *privilege = "privilege04"; const int resultAllow = CYNARA_ADMIN_ALLOW; const int resultBucket = CYNARA_ADMIN_BUCKET; + const int resultNone = CYNARA_ADMIN_NONE; const char *resultExtra = nullptr; checkInvalidPolicy(admin, nullptr, client, user, privilege, resultAllow, resultExtra); @@ -120,6 +121,7 @@ void tc04_admin_set_policies_invalid_params_func() checkInvalidPolicy(admin, bucket, client, user, nullptr, resultAllow, resultExtra); checkInvalidPolicy(admin, bucket, client, user, privilege, INT_MAX, resultExtra); checkInvalidPolicy(admin, bucket, client, user, privilege, resultBucket, nullptr ); + checkInvalidPolicy(admin, bucket, client, user, privilege, resultNone, resultExtra); } void tc05_admin_set_bucket_invalid_params_func() @@ -129,11 +131,13 @@ void tc05_admin_set_bucket_invalid_params_func() const char *bucket = CYNARA_ADMIN_DEFAULT_BUCKET; const int operationAllow = CYNARA_ADMIN_ALLOW; const int operationDelete = CYNARA_ADMIN_DELETE; + const int operationNone = CYNARA_ADMIN_NONE; const char *extra = nullptr; admin.setBucket(nullptr, operationAllow, extra, CYNARA_ADMIN_API_INVALID_PARAM); admin.setBucket(bucket, INT_MAX, extra, CYNARA_ADMIN_API_INVALID_PARAM); admin.setBucket(bucket, operationDelete, extra, CYNARA_ADMIN_API_OPERATION_NOT_ALLOWED); + admin.setBucket(bucket, operationNone, extra, CYNARA_ADMIN_API_OPERATION_NOT_ALLOWED); } void tc06_cynara_check_empty_admin1_func() @@ -602,7 +606,89 @@ void tc14_admin_set_policies_integrity_func() CynaraTestClient cynara; cynara.check(client, session, user, privilege, CYNARA_API_ACCESS_DENIED); } +} + +void tc15_admin_set_bucket_admin_none1_func() +{ + CynaraTestAdmin admin; + CynaraTestClient cynara; + + const char *bucketDefault = CYNARA_ADMIN_DEFAULT_BUCKET; + const char *bucket = "bucket15_1"; + const char *client = "client15_1"; + const char *session = "session15_1"; + const char *user = "user15_1"; + const char *privilege = "privilege15_1"; + const char *extra = nullptr; + const char *extraResult = nullptr; + + admin.setBucket(bucket, CYNARA_ADMIN_NONE, extra); + + { + CynaraPoliciesContainer cp; + cp.add(bucketDefault, + client, user, privilege, + CYNARA_ADMIN_BUCKET, bucket); + cp.add(bucket, + client, user, privilege, + CYNARA_ADMIN_ALLOW, extraResult); + admin.setPolicies(cp); + } + cynara.check(client, session, user, privilege, CYNARA_API_SUCCESS); +} + +void tc15_admin_set_bucket_admin_none2_func() +{ + CynaraTestAdmin admin; + CynaraTestClient cynara; + + const char *bucketDefault = CYNARA_ADMIN_DEFAULT_BUCKET; + const char *bucket = "bucket15_2"; + const char *client = "client15_2"; + const char *session = "session15_2"; + const char *user = "user15_2"; + const char *privilege = "privilege15_2"; + const char *extra = nullptr; + admin.setBucket(bucket, CYNARA_ADMIN_NONE, extra); + + { + CynaraPoliciesContainer cp; + cp.add(bucketDefault, + client, user, privilege, + CYNARA_ADMIN_BUCKET, bucket); + admin.setPolicies(cp); + } + cynara.check(client, session, user, privilege, CYNARA_API_ACCESS_DENIED); +} + +void tc15_admin_set_bucket_admin_none3_func() +{ + CynaraTestAdmin admin; + CynaraTestClient cynara; + + const char *bucketDefault = CYNARA_ADMIN_DEFAULT_BUCKET; + const char *bucket = "bucket15_3"; + const char *client = "client15_3"; + const char *session = "session15_3"; + const char *user = "user15_3"; + const char *privilege = "privilege15_3"; + const char *extra = nullptr; + const char *extraResult = nullptr; + + admin.setBucket(bucket, CYNARA_ADMIN_NONE, extra); + + { + CynaraPoliciesContainer cp; + cp.add(bucketDefault, + client, user, privilege, + CYNARA_ADMIN_BUCKET, bucket); + cp.add(bucketDefault, + client, user, CYNARA_ADMIN_WILDCARD, + CYNARA_ADMIN_ALLOW, extraResult); + admin.setPolicies(cp); + } + cynara.check(client, session, user, privilege, CYNARA_API_SUCCESS); } RUNNER_TEST_GROUP_INIT(cynara_tests) @@ -624,3 +710,6 @@ RUN_CYNARA_TEST(tc11_admin_bucket_not_found) RUN_CYNARA_TEST(tc12_admin_delete_bucket_with_policies_pointing_to_it) RUN_CYNARA_TEST(tc13_admin_set_policies_to_extra_bucket) RUN_CYNARA_TEST(tc14_admin_set_policies_integrity) +RUN_CYNARA_TEST(tc15_admin_set_bucket_admin_none1) +RUN_CYNARA_TEST(tc15_admin_set_bucket_admin_none2) +RUN_CYNARA_TEST(tc15_admin_set_bucket_admin_none3) -- 2.7.4