Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Executor ITF: transfer create_role_test #281

Conversation

MBoldyrev
Copy link
Contributor

Signed-off-by: Mikhail Boldyrev miboldyrev@gmail.com

Description of the Change

transfer create_role_test from postgres_executor_test & BIG ITF acceptance to new shiny Executor ITF.

Benefits

Possible Drawbacks

Usage Examples or Tests [optional]

Alternate Designs [optional]

@MBoldyrev MBoldyrev self-assigned this Oct 16, 2019
test/integration/executor/create_role_test.cpp Outdated Show resolved Hide resolved
test/integration/executor/create_role_test.cpp Outdated Show resolved Hide resolved
/**
* @given a user with all kCreateRole permission
* @when executes CreateRole command with empty permission set
* @then the command succeeds and the role is created
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This case is stateless invalid. Looks like we need to connect stateless validation and execution in this framework, otherwise it is possible to write invalid cases.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bump?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think so. this is command and query executor backend test. it has its interface and it needs to be tested. if this test is out of scope of the command executor backend interface, I remove it.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Alright, probably it makes sense in the context of configurable stateless validator.

test/integration/executor/command_permission_test.hpp Outdated Show resolved Hide resolved
test/integration/executor/command_permission_test.cpp Outdated Show resolved Hide resolved
@@ -125,7 +126,11 @@ TEST_P(CreateAccountPermissionTest, CommandPermissionTest) {
ASSERT_NO_FATAL_FAILURE(getItf().createDomain(kSecondDomain));
ASSERT_NO_FATAL_FAILURE(prepareState({}));

if (checkResponse(createAccount(getActor()))) {
if (checkResponse(createAccount(getActor(),
kNewName,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Such approach is error-prone, because if default argument in createAccount is changes, it should be changed here as well. Maybe reorder arguments, or make another function? Same in other tests.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

added another function here. in other tests the other functions do not use the same default argument values, so I do not see any bad in this approach there.

add_perm_case_if_provided(ActorRolePermissions::kEveryone,
permission_for_everyone);
add_perm_case_if_provided(ActorRolePermissions::kRoot, Role::kRoot);
add_case(ActorRolePermissions::kNone,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This code needs comments. It is not clear why there were more cases previously, and why it was possible to reduce them.

/**
* @given a user with all kCreateRole permission
* @when executes CreateRole command with empty permission set
* @then the command succeeds and the role is created
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bump?

/**
* @given a user with all kCreateRole permission
* @when executes CreateRole command with empty permission set
* @then the command succeeds and the role is created
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Alright, probably it makes sense in the context of configurable stateless validator.

  - accept additional perms for command issuer
  - readability of test case desctiptions
  - only create needed accounts
  - reduced amount of tests for grantable permission
  - added test case with disabled permission validation (for genesis block)

Signed-off-by: Mikhail Boldyrev <miboldyrev@gmail.com>
Signed-off-by: Mikhail Boldyrev <miboldyrev@gmail.com>
@MBoldyrev MBoldyrev force-pushed the feature/executor-itf-create_role_test branch from d7b130c to a2dbd65 Compare November 16, 2019 06:24
@MBoldyrev MBoldyrev merged commit ffb71f3 into hyperledger-iroha:master Nov 16, 2019
@MBoldyrev MBoldyrev deleted the feature/executor-itf-create_role_test branch November 16, 2019 06:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants