Skip to content
This repository has been archived by the owner on Apr 17, 2019. It is now read-only.

Commit

Permalink
Fix tests for createRole with empty set of permissions (#1520)
Browse files Browse the repository at this point in the history
Signed-off-by: Igor Egorov <igor@soramitsu.co.jp>

The behavior of createRole command was changed, so the tests had to be updated.
  • Loading branch information
igor-egorov authored and l4l committed Jul 25, 2018
1 parent ca720db commit de433dd
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 8 deletions.
2 changes: 1 addition & 1 deletion shared_model/packages/javascript/tests/txbuilder.js
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ test('ModelTransactionBuilder tests', function (t) {
validPermissions.set(iroha.Role_kAddPeer)
validPermissions.set(iroha.Role_kAddAssetQty)

t.throws(() => correctTx.createRole('new_user_role', emptyPerm).build(), /Permission set should contain at least one permission/, 'Should throw Permission set should contain at least one permission')
t.doesNotThrow(() => correctTx.createRole('new_user_role', emptyPerm).build(), null, 'Should not throw any exceptions')
t.throws(() => correctTx.createRole('', validPermissions).build(), /Wrongly formed role_id, passed value: ''/, 'Should throw Wrongly formed role_id')
t.throws(() => correctTx.createRole('@@@', validPermissions).build(), /Wrongly formed role_id, passed value: '@@@'/, 'Should throw Wrongly formed role_id')
t.throws(() => correctTx.createRole('new_user_role', '').build(), /argument 3 of type 'shared_model::interface::RolePermissionSet/, 'Should throw ...argument 3 of type...')
Expand Down
7 changes: 2 additions & 5 deletions test/module/shared_model/bindings/BuilderTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -819,11 +819,8 @@ void createRoleWithInvalidName() {

@Test
void createRoleEmptyPermissions() {
RolePermissionSet permissions = new RolePermissionSet();

ModelTransactionBuilder builder = new ModelTransactionBuilder();
builder.createRole("new_role", permissions);
assertThrows(IllegalArgumentException.class, builder::build);
UnsignedTx tx = builder.createRole("new_role", new RolePermissionSet()).build();
assertTrue(checkProtoTx(proto(tx)));
}

/* ====================== DetachRole Tests ====================== */
Expand Down
4 changes: 2 additions & 2 deletions test/module/shared_model/bindings/builder-test.py
Original file line number Diff line number Diff line change
Expand Up @@ -532,8 +532,8 @@ def test_create_role_with_invalid_name(self):
self.base().createRole(name, iroha.RolePermissionSet([iroha.Role_kReceive, iroha.Role_kGetRoles])).build()

def test_create_role_with_empty_permissions(self):
with self.assertRaises(ValueError):
self.base().createRole("user", iroha.RolePermissionSet([])).build()
tx = self.builder.createRole("user", iroha.RolePermissionSet([])).build()
self.assertTrue(self.check_proto_tx(self.proto(tx)))

# ====================== DetachRole Tests ======================

Expand Down

0 comments on commit de433dd

Please sign in to comment.