Login modifier reads from env by malaskowski 路 Pull Request #583 路 wttech/aet

@malaskowski

Description

Login modifier can read login and password from environment variables.

Motivation and Context

Fixes #512

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)

Checklist:

  • My code follows the code style of this project.
  • I have reviewed (and updated if needed) the documentation regarding this change

I hereby agree to the terms of the AET Contributor License Agreement.

toniedzwiedz


import com.cognifide.aet.job.api.exceptions.ParametersException;
import com.googlecode.zohhak.api.TestWith;
import com.googlecode.zohhak.api.runners.ZohhakRunner;

Choose a reason for hiding this comment

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

It's a completely separate conversation but, out of curiosity, have you considered migrating to JUnit 5? Something I could help with?

Choose a reason for hiding this comment

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

Sure, generally this is good idea to migrate to JUnit 5 - but there was never time for that.
This is definitely the thing you could help with and create a PR 馃槂

toniedzwiedz

Map<String, String> params = new HashMap<>();
params.put(LOGIN_PAGE_PARAM, "whatever");
params.put(PASSWORD_PARAM, "${MY_SECRET_PASSWORD}");
environmentVariables.set("MY_SECRET_PASSWORD", "pass-form-env");

Choose a reason for hiding this comment

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

Typo?

environmentVariables.set("MY_SECRET_PASSWORD", "pass-form-env");
environmentVariables.set("MY_SECRET_PASSWORD", "pass-from-env");

Choose a reason for hiding this comment

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

Yes, that's typo I will fix that in IDE together with assertion. Thanks for spotting.

private static final String DEFAULT_LOGIN_TOKEN = "login-token";

private static final String LOGIN_PARAM = "login";
static final String LOGIN_PARAM = "login";

Choose a reason for hiding this comment

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

I'm not sure I'm reading this right but if this is literally going to be the name of the Environment variable to set, how about prefixing it with something more explicit?At the moment, it's quite generic and not immediately associated with AET, a kind of thing that might get users and administrators confusing.

Choose a reason for hiding this comment

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

This constant is the name of a param that is passed via XML suite definition. The actual environment variable name is configured through that param, see the example:

<login login="${LOGIN_EXAMPLE_ADMIN_PANEL}"
                password="${PASS_EXAMPLE_ADMIN_PANEL}"
                login-page="/login.html"
                login-input-selector="//input[@name='j_username']"
                password-input-selector="//input[@name='j_password']"
                submit-button-selector="//*[@type='submit']" />

@malaskowski

tkaik

@radeklawgmin

@malaskowski