Skip to content

Commit

Permalink
Merge pull request #244 from aerospike/3.7.3-candidate
Browse files Browse the repository at this point in the history
3.7.3 candidate
  • Loading branch information
dwelch-spike committed Aug 16, 2019
2 parents ff0c555 + e504e17 commit 1a2e91a
Show file tree
Hide file tree
Showing 20 changed files with 164 additions and 25 deletions.
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
3.7.2
3.7.3
4 changes: 4 additions & 0 deletions doc/aerospike.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1734,6 +1734,10 @@ Permission codes define the type of permission granted for a user's role.
The user is granted read access.
.. data:: PRIV_WRITE
The user is granted write access.
.. data:: PRIV_READ_WRITE
The user is granted read and write access.
Expand Down
7 changes: 6 additions & 1 deletion doc/exception.rst
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,11 @@ Exception Types
Protocol-level error. Subclass of :py:exc:`~aerospike.exception.ServerError`.
.. py:exception:: OpNotApplicable
The operation cannot be applied to the current bin value on the server.
Subclass of :py:exc:`~aerospike.exception.ServerError`.
.. py:exception:: ServerFull
The server node is running out of memory and/or storage device space
Expand Down Expand Up @@ -396,4 +401,4 @@ Exception Hierarchy
| +-- NotAuthenticated (80)
+-- UDFError (*)
+-- UDFNotFound (1301)
+-- LuaFileNotFound (1302)
+-- LuaFileNotFound (1302)
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
os.environ['ARCHFLAGS'] = '-arch x86_64'
AEROSPIKE_C_VERSION = os.getenv('AEROSPIKE_C_VERSION')
if not AEROSPIKE_C_VERSION:
AEROSPIKE_C_VERSION = '4.6.3'
AEROSPIKE_C_VERSION = '4.6.5'
DOWNLOAD_C_CLIENT = os.getenv('DOWNLOAD_C_CLIENT')
AEROSPIKE_C_HOME = os.getenv('AEROSPIKE_C_HOME')
PREFIX = None
Expand Down
7 changes: 4 additions & 3 deletions src/include/exception_types.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ struct exceptions {
PyObject *ForbiddenError;
PyObject *QueryError;
PyObject *InvalidGeoJSON;
PyObject *OpNotApplicable; //26
PyObject *ScanAbortedError; //15
PyObject *ElementNotFoundError; //23
PyObject *ElementExistsError; //24
Expand Down Expand Up @@ -110,9 +111,9 @@ struct exceptions {
};

struct server_exceptions_struct {
PyObject * *server_exceptions[10];
char * server_exceptions_name[10];
int server_exceptions_codes[10];
PyObject * *server_exceptions[11];
char * server_exceptions_name[11];
int server_exceptions_codes[11];
};
struct record_exceptions_struct {
PyObject * *record_exceptions[8];
Expand Down
2 changes: 1 addition & 1 deletion src/main/aerospike.c
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ AerospikeConstants operator_constants[] = {
MOD_INIT(aerospike)
{

const char version[8] = "3.7.2";
const char version[8] = "3.7.3";
// Makes things "thread-safe"
PyEval_InitThreads();
int i = 0;
Expand Down
7 changes: 4 additions & 3 deletions src/main/exception.c
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,13 @@ PyObject * AerospikeException_New(void)
{&exceptions_array.InvalidRequest, &exceptions_array.ServerFull, &exceptions_array.AlwaysForbidden,
&exceptions_array.UnsupportedFeature, &exceptions_array.DeviceOverload, &exceptions_array.NamespaceNotFound,
&exceptions_array.ForbiddenError, &exceptions_array.QueryError, &exceptions_array.ClusterError,
&exceptions_array.InvalidGeoJSON},
&exceptions_array.InvalidGeoJSON, &exceptions_array.OpNotApplicable},
{"InvalidRequest", "ServerFull", "AlwaysForbidden", "UnsupportedFeature", "DeviceOverload", "NamespaceNotFound",
"ForbiddenError", "QueryError", "ClusterError", "InvalidGeoJSON"},
"ForbiddenError", "QueryError", "ClusterError", "InvalidGeoJSON", "OpNotApplicable"},
{AEROSPIKE_ERR_REQUEST_INVALID, AEROSPIKE_ERR_SERVER_FULL, AEROSPIKE_ERR_ALWAYS_FORBIDDEN,
AEROSPIKE_ERR_UNSUPPORTED_FEATURE, AEROSPIKE_ERR_DEVICE_OVERLOAD, AEROSPIKE_ERR_NAMESPACE_NOT_FOUND,
AEROSPIKE_ERR_FAIL_FORBIDDEN, AEROSPIKE_ERR_QUERY, AEROSPIKE_ERR_CLUSTER, AEROSPIKE_ERR_GEO_INVALID_GEOJSON}
AEROSPIKE_ERR_FAIL_FORBIDDEN, AEROSPIKE_ERR_QUERY, AEROSPIKE_ERR_CLUSTER, AEROSPIKE_ERR_GEO_INVALID_GEOJSON,
AEROSPIKE_ERR_OP_NOT_APPLICABLE}
};

struct record_exceptions_struct record_array = {
Expand Down
1 change: 1 addition & 0 deletions src/main/policy.c
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,7 @@ AerospikeConstants aerospike_constants[] = {
{ AS_PRIVILEGE_SYS_ADMIN , "PRIV_SYS_ADMIN" },
{ AS_PRIVILEGE_DATA_ADMIN , "PRIV_DATA_ADMIN" },
{ AS_PRIVILEGE_READ , "PRIV_READ"},
{ AS_PRIVILEGE_WRITE , "PRIV_WRITE"},
{ AS_PRIVILEGE_READ_WRITE , "PRIV_READ_WRITE"},
{ AS_PRIVILEGE_READ_WRITE_UDF , "PRIV_READ_WRITE_UDF"},

Expand Down
31 changes: 31 additions & 0 deletions test/new_tests/test_admin_create_role.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,37 @@ def test_create_role_positive_with_policy(self):

self.client.admin_drop_user("testcreaterole")

def test_create_role_positive_with_policy_write(self):
"""
Create role with write privilege positive
"""
try:
self.client.admin_query_role("usr-sys-admin-test")
# role exists, clear it out.
self.client.admin_drop_role("usr-sys-admin-test")
time.sleep(2)
except e.InvalidRole:
pass # we are good, no such role exists

self.client.admin_create_role("usr-sys-admin-test",
[{"code": aerospike.PRIV_WRITE,
"ns": "test", "set": "demo"}],
{'timeout': 1000})
time.sleep(1)
roles = self.client.admin_query_role("usr-sys-admin-test")
assert roles == [{'code': 13, 'ns': 'test', 'set': 'demo'}]

status = self.client.admin_create_user(
"testcreaterole", "createrole", ["usr-sys-admin-test"])

assert status == 0
time.sleep(1)
roles = self.client.admin_query_user("testcreaterole")

assert roles == ["usr-sys-admin-test"]

self.client.admin_drop_user("testcreaterole")

def test_create_role_positive(self):
"""
Create role positive
Expand Down
27 changes: 27 additions & 0 deletions test/new_tests/test_admin_drop_role.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,33 @@ def test_drop_role_positive_with_policy(self):
with pytest.raises(e.InvalidRole):
self.client.admin_query_role("usr-sys-admin-test")

def test_drop_role_positive_with_policy_write(self):
"""
Drop write role positive with policy
"""
try:
self.client.admin_query_role("usr-sys-admin-test")
# role exists, clear it out.
self.client.admin_drop_role("usr-sys-admin-test")
time.sleep(1)
except e.InvalidRole:
pass # we are good, no such role exists

self.client.admin_create_role("usr-sys-admin-test",
[{"code": aerospike.PRIV_WRITE,
"ns": "test", "set": "demo"}],
{'timeout': 1000})
time.sleep(1)

status = self.client.admin_drop_role(
"usr-sys-admin-test", {'timeout': 1000})

assert status == 0
time.sleep(1)

with pytest.raises(e.InvalidRole):
self.client.admin_query_role("usr-sys-admin-test")

def test_drop_role_positive(self):
"""
Drop role positive
Expand Down
21 changes: 21 additions & 0 deletions test/new_tests/test_admin_grant_privileges.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,27 @@ def test_admin_grant_privileges_positive(self):

assert status == 0

def test_admin_grant_privileges_positive_write(self):
"""
Grant write privileges positive
"""
status = self.client.admin_grant_privileges(
"usr-sys-admin-test",
[{"code": aerospike.PRIV_WRITE}])

assert status == 0
time.sleep(1)
roles = self.client.admin_query_role("usr-sys-admin-test")
assert roles == [{'code': 0, 'ns': '', 'set': ''},
{'code': 1, 'ns': '', 'set': ''},
{'code': 13, 'ns': '', 'set': ''}]

status = self.client.admin_revoke_privileges(
"usr-sys-admin-test",
[{"code": aerospike.PRIV_WRITE}])

assert status == 0

def test_admin_grant_privileges_positive_with_policy(self):
"""
Grant privileges positive with policy
Expand Down
50 changes: 50 additions & 0 deletions test/new_tests/test_admin_revoke_privileges.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,31 @@ def test_admin_revoke_privileges_positive(self):
assert roles == [{'code': 0, 'ns': '', 'set': ''},
{'code': 1, 'ns': '', 'set': ''}]

def test_admin_revoke_privileges_positive_write(self):
"""
revoke write privileges positive
"""
status = self.client.admin_grant_privileges(
"usr-sys-admin-test",
[{"code": aerospike.PRIV_WRITE}])

assert status == 0
time.sleep(2)
roles = self.client.admin_query_role("usr-sys-admin-test")
assert roles == [{'code': 0, 'ns': '', 'set': ''},
{'code': 1, 'ns': '', 'set': ''},
{'code': 13, 'ns': '', 'set': ''}]

status = self.client.admin_revoke_privileges(
"usr-sys-admin-test",
[{"code": aerospike.PRIV_WRITE}])

assert status == 0
time.sleep(2)
roles = self.client.admin_query_role("usr-sys-admin-test")
assert roles == [{'code': 0, 'ns': '', 'set': ''},
{'code': 1, 'ns': '', 'set': ''}]

def test_admin_revoke_privileges_positive_with_policy(self):
"""
Revoke privileges positive with policy
Expand All @@ -105,6 +130,31 @@ def test_admin_revoke_privileges_positive_with_policy(self):
assert roles == [{'code': 0, 'ns': '', 'set': ''},
{'code': 1, 'ns': '', 'set': ''}]

def test_admin_revoke_privileges_positive_with_policy_write(self):
"""
Revoke write privileges positive with policy
"""
status = self.client.admin_grant_privileges(
"usr-sys-admin-test",
[{"code": aerospike.PRIV_WRITE}], {'timeout': 1000})

assert status == 0
time.sleep(2)
roles = self.client.admin_query_role("usr-sys-admin-test")
assert roles == [{'code': 0, 'ns': '', 'set': ''},
{'code': 1, 'ns': '', 'set': ''},
{'code': 13, 'ns': '', 'set': ''}]

status = self.client.admin_revoke_privileges(
"usr-sys-admin-test",
[{"code": aerospike.PRIV_WRITE}], {'timeout': 1000})

time.sleep(1)
assert status == 0
roles = self.client.admin_query_role("usr-sys-admin-test")
assert roles == [{'code': 0, 'ns': '', 'set': ''},
{'code': 1, 'ns': '', 'set': ''}]

def test_admin_revoke_privileges_positive_with_ns_set(self):
"""
Revoke privileges positive with ns and set
Expand Down
2 changes: 0 additions & 2 deletions test/new_tests/test_index.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,13 @@
from .index_helpers import ensure_dropped_index
from aerospike import exception as e


aerospike = pytest.importorskip("aerospike")
try:
import aerospike
except:
print("Please install aerospike python client.")
sys.exit(1)


class TestIndex(object):

@pytest.fixture(autouse=True)
Expand Down
4 changes: 2 additions & 2 deletions test/new_tests/test_list_get.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,8 +160,8 @@ def test_neg_list_get_with_negative_index(self):
key = ('test', 'demo', 1)
try:
self.as_connection.list_get(key, "contact_no", -56)
except e.InvalidRequest as exception:
assert exception.code == 4
except e.OpNotApplicable as exception:
assert exception.code == 26

def test_neg_list_get_meta_type_integer(self):
"""
Expand Down
4 changes: 2 additions & 2 deletions test/new_tests/test_list_insert.py
Original file line number Diff line number Diff line change
Expand Up @@ -247,8 +247,8 @@ def test_neg_list_insert_index_negative(self):

try:
self.as_connection.list_insert(key, "age", -6, False)
except e.InvalidRequest as exception:
assert exception.code == 4
except e.OpNotApplicable as exception:
assert exception.code == 26

def test_neg_list_insert_index_type_string(self):
"""
Expand Down
4 changes: 2 additions & 2 deletions test/new_tests/test_list_pop.py
Original file line number Diff line number Diff line change
Expand Up @@ -180,8 +180,8 @@ def test_neg_list_pop_with_negative_index(self):
key = ('test', 'demo', 1)
try:
self.as_connection.list_pop(key, "contact_no", -56)
except e.InvalidRequest as exception:
assert exception.code == 4
except e.OpNotApplicable as exception:
assert exception.code == 26

def test_neg_list_pop_meta_type_integer(self):
"""
Expand Down
4 changes: 2 additions & 2 deletions test/new_tests/test_list_remove.py
Original file line number Diff line number Diff line change
Expand Up @@ -188,8 +188,8 @@ def test_neg_list_remove_with_negative_index(self):
key = ('test', 'demo', 1)
try:
self.as_connection.list_remove(key, "contact_no", -56)
except e.InvalidRequest as exception:
assert exception.code == 4
except e.OpNotApplicable as exception:
assert exception.code == 26

def test_neg_list_remove_meta_type_integer(self):
"""
Expand Down
4 changes: 2 additions & 2 deletions test/new_tests/test_list_set.py
Original file line number Diff line number Diff line change
Expand Up @@ -244,8 +244,8 @@ def test_neg_list_set_with_negative_index(self):
key = ('test', 'demo', 1)
try:
self.as_connection.list_set(key, "contact_no", -56, 12)
except e.InvalidRequest as exception:
assert exception.code == 4
except e.OpNotApplicable as exception:
assert exception.code == 26

def test_neg_list_set_meta_type_integer(self):
"""
Expand Down
4 changes: 2 additions & 2 deletions test/new_tests/test_operate.py
Original file line number Diff line number Diff line change
Expand Up @@ -1200,8 +1200,8 @@ def test_neg_operate_list_invalid_requests(self, list):
key = ('test', 'demo', 'list_key')
try:
key, _, _ = self.as_connection.operate(key, list)
except e.InvalidRequest as exception:
assert exception.code == 4
except e.OpNotApplicable as exception:
assert exception.code == 26

def test_neg_operate_with_command_invalid(self):
"""
Expand Down
2 changes: 1 addition & 1 deletion test/new_tests/test_operate_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -922,7 +922,7 @@ def test_neg_operate_list_invalid_requests(self, list):
Invoke operate() with list addition operations negative
"""
key = ('test', 'demo', 'list_key')
with pytest.raises(e.InvalidRequest):
with pytest.raises(e.OpNotApplicable):
self.as_connection.operate(key, list)


Expand Down

0 comments on commit 1a2e91a

Please sign in to comment.