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

migrate e2e/users tests to common framework #13819

Merged
merged 2 commits into from
Apr 6, 2022

Conversation

endocrimes
Copy link
Contributor

@endocrimes
Copy link
Contributor Author

 --- FAIL: TestV2Deprecation (0.37s)

seems unrelated - will file an issue for the flake


// If no password is provided, and NoPassword isn't set, the CLI will always
// wait for a password, send an enter in this case for an "empty" password.
if !opts.NoPassword && password == "" {
Copy link
Member

Choose a reason for hiding this comment

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

Could we simplify code by always providing password in interactive mode?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We could! - But this way we maintain a semblance of the previous coverage that included password on stdin and password in the command.

I'm not particularly tied to either tho - this actually caught me out pretty last minute bc I was surprised by the behaviour of "non-interactive, but still waiting on stdin"

Copy link
Member

Choose a reason for hiding this comment

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

I don't think we need UserAddOptions added in tests/framework/config/client.go. We need to follow the same logic as etcdctl, refer to user_command.go#L135-L163.

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 is the same logic - the CLI will only pass NoPassword: true when --no-password is provided, because it's explicitly distinct behavior from an empty password. (--no-password as documented requires CN auth, but an empty password is also apparently valid on normal accounts?)

Copy link
Member

Choose a reason for hiding this comment

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

OK, sounds good. The logic should be OK, and it's a valid case as well. When password is empty and NoPassword is false, it makes sense to send an enter. It aligns with the existing user experience.


// If no password is provided, and NoPassword isn't set, the CLI will always
// wait for a password, send an enter in this case for an "empty" password.
if !opts.NoPassword && password == "" {
Copy link
Member

Choose a reason for hiding this comment

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

I don't think we need UserAddOptions added in tests/framework/config/client.go. We need to follow the same logic as etcdctl, refer to user_command.go#L135-L163.

@@ -1265,3 +1265,24 @@ func ctlV3EndpointHealth(cx ctlCtx) error {
}
return e2e.SpawnWithExpects(cmdArgs, cx.envMap, lines...)
}

func ctlV3User(cx ctlCtx, args []string, expStr string, stdIn []string) error {
Copy link
Member

Choose a reason for hiding this comment

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

Please add a comment here something like: This function may need to be deleted when the tests in ctl_v3_auth_test.go are migrated.

Copy link
Member

Choose a reason for hiding this comment

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

I think this can be said about every function, delete it when it's not used :P

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah I'm not sure a comment makes sense - anyone migrating the tests will presumably also delete any code they can. (And that person is probably going to be next week me)

Copy link
Member

Choose a reason for hiding this comment

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

It is OK because the function ctlV3User is in the same file as the test cases.

tests/framework/integration.go Outdated Show resolved Hide resolved
tests/framework/integration.go Outdated Show resolved Hide resolved
tests/framework/integration.go Outdated Show resolved Hide resolved
tests/framework/integration.go Outdated Show resolved Hide resolved

// If no password is provided, and NoPassword isn't set, the CLI will always
// wait for a password, send an enter in this case for an "empty" password.
if !opts.NoPassword && password == "" {
Copy link
Member

Choose a reason for hiding this comment

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

OK, sounds good. The logic should be OK, and it's a valid case as well. When password is empty and NoPassword is false, it makes sense to send an enter. It aligns with the existing user experience.

tests/common/user_test.go Show resolved Hide resolved
username: "foo",
password: "",
noPassword: false,
expectError: false,
Copy link
Member

Choose a reason for hiding this comment

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

A non-empty password is always required when NoPassword is false, so the integration test should fail in this case. Please double check.

@kkkkun
Copy link
Contributor

kkkkun commented Mar 19, 2022

@endocrimes Could you please record to #13637, Let us know which cases have been taken?

@serathius serathius merged commit c4d055f into etcd-io:main Apr 6, 2022
@endocrimes endocrimes deleted the dani/auth_test.go branch April 6, 2022 16:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

4 participants