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

Test/user #5139

Merged
merged 15 commits into from
Jan 29, 2023
16 changes: 16 additions & 0 deletions tests/tck/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -980,3 +980,19 @@ def switch_to_new_session(conn_pool, user, password, class_fixture_variables, ex
sess = conn_pool.get_session(user, password)
class_fixture_variables["sessions"].append(sess)
exec_ctx["current_session"] = sess

@when(parse('verify login with user "{user}"'))
def login_without_password(conn_pool, user):
sess = None
try:
sess = conn_pool.get_session(user, '')
Copy link
Contributor

Choose a reason for hiding this comment

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

why not to reset the current_session in exec_ctx?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Just verify logging, avoid affecting other tests.

Copy link
Contributor

Choose a reason for hiding this comment

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

if you don't change the current session, how do you make sure the next test cases use the current login user?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Next test will use origin session.

Copy link
Contributor

Choose a reason for hiding this comment

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

if so, does this step just test whether the user exists? why not to use show users to test it? if you want to switch user and test role, plz consider to switch the current session.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This will be logged in by this user.

Copy link
Contributor

Choose a reason for hiding this comment

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

Just test login feature? what to do after the user login? I don't find where to use the login user?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Just test login.

Copy link
Contributor

Choose a reason for hiding this comment

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

why not to test this feature in role cases ? such as:

When executing query:
  """
  create user username...
  grant user some rule ..
  """
Then executing successfully
When switch to new session with user "{user}" and password "{password}"
Then executing successfully
When executing query:
  """
   test role of user
  """
Then ...

it's not necessary to create a new step for this feature and we have the related step for switching user:

switch to new session with user "{user}" and password "{password}"

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Don't want to change current session.

except Exception as e:
assert e

@when(parse('verify login with user "{user}" and password "{password}"'))
def login_with_password(conn_pool, user, password):
sess = None
try:
sess = conn_pool.get_session(user, password)
except Exception as e:
assert e
Loading