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

Add tests for Enso Cloud auth + simple API mock for Enso_User #8511

Merged
merged 19 commits into from
Dec 19, 2023

Conversation

radeusgd
Copy link
Member

@radeusgd radeusgd commented Dec 11, 2023

Pull Request Description

Important Notes

Checklist

Please ensure that the following checklist has been satisfied before submitting the PR:

  • The documentation has been updated, if necessary.
  • Screenshots/screencasts have been attached, if there are any visual changes. For interactive or animated visual changes, a screencast is preferred.
  • All code follows the
    Scala,
    Java,
    and
    Rust
    style guides. In case you are using a language not listed above, follow the Rust style guide.
  • All code has been tested:
    • Unit tests have been written where possible.
    • If GUI codebase was changed, the GUI was tested when built using ./run ide build.

@radeusgd radeusgd changed the title add test for API url override Add tests for Enso Cloud auth + simple API mock for Enso_User Dec 11, 2023
@radeusgd radeusgd self-assigned this Dec 11, 2023
@radeusgd radeusgd added the CI: No changelog needed Do not require a changelog entry for this PR. label Dec 11, 2023
@radeusgd radeusgd linked an issue Dec 11, 2023 that may be closed by this pull request
9 tasks
@@ -12,4 +12,11 @@ polyglot java import org.enso.base.Environment_Utils
`System.getenv` Java call remains unchanged.
unsafe_with_environment_override : Text -> Text -> Any -> Any
unsafe_with_environment_override key value ~action =
Environment_Utils.with_environment_variable_override key value (_->action)
## This has to be done in Enso, not in Java, due to the bug: https://github.com/enso-org/enso/issues/7117
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe create Environment_Utils.enso for this? Unless it is temporary until that bug is fixed.

Copy link
Member Author

Choose a reason for hiding this comment

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

I don't understand why should I create this separate file? What would be the advantage over keeping the code here?

Copy link
Member Author

Choose a reason for hiding this comment

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

I removed the Java counterpart with_environment_variable_override as due to #7117 it is problematic.

But keeping this logic here seems to make most sense - the override is meant only for testing - it should never be used in actual production code.

Copy link
Contributor

Choose a reason for hiding this comment

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

Because the original implementation was in Environment_Utils.java, as if it was possibly meant to be used more than once. If not, then it doesn't matter.

Copy link
Member Author

Choose a reason for hiding this comment

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

I see. No that utils file was written specifically for this test tool and it shouldn't really be used elsewhere.

@radeusgd radeusgd force-pushed the wip/radeusgd/8352-cloud-followup-1 branch from 77a6489 to 20966e9 Compare December 12, 2023 11:06
@radeusgd radeusgd force-pushed the wip/radeusgd/8354-cloud-tests-2 branch from fac3165 to 89ba2d4 Compare December 12, 2023 11:07
@radeusgd radeusgd force-pushed the wip/radeusgd/8352-cloud-followup-1 branch from 20966e9 to 3d6856b Compare December 14, 2023 12:58
@radeusgd radeusgd force-pushed the wip/radeusgd/8354-cloud-tests-2 branch from 89ba2d4 to 17887d0 Compare December 14, 2023 13:01
Copy link
Member

@jdunkerley jdunkerley left a comment

Choose a reason for hiding this comment

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

As discussed we should have the tests in Tests as the functions are in Base.

@radeusgd radeusgd force-pushed the wip/radeusgd/8352-cloud-followup-1 branch from 3d6856b to f951403 Compare December 15, 2023 10:07
@radeusgd radeusgd force-pushed the wip/radeusgd/8354-cloud-tests-2 branch 3 times, most recently from ee87d57 to ba2a8db Compare December 15, 2023 16:17
Base automatically changed from wip/radeusgd/8352-cloud-followup-1 to develop December 15, 2023 17:58
@radeusgd radeusgd force-pushed the wip/radeusgd/8354-cloud-tests-2 branch from ba2a8db to baf0acc Compare December 16, 2023 13:44
Copy link
Member

Choose a reason for hiding this comment

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

Shall the tool continue to be called simple? It is becoming more and more complicated.

Copy link
Member Author

Choose a reason for hiding this comment

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

Sure, we can rename it.

Copy link
Member Author

Choose a reason for hiding this comment

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

As requested, I renamed it to http-test-helper in 583cabf

overrides.remove(name);
}
}
public static void setOverride(String name, String value) {
Copy link
Member

Choose a reason for hiding this comment

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

How does one prevent this to be used in production?

Copy link
Member Author

Choose a reason for hiding this comment

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

We cannot. Nor was this prevented in the earlier version.

We need some way to override environment variables in tests.

The functionality is hidden from the user. It does not do anything more than setting these env vars before launching Enso - so if the user wants to abuse the hidden feature, they are free to do so.

@radeusgd radeusgd requested a review from mwu-tow as a code owner December 19, 2023 11:13
@radeusgd radeusgd added the CI: Ready to merge This PR is eligible for automatic merge label Dec 19, 2023
Copy link
Collaborator

@hubertp hubertp left a comment

Choose a reason for hiding this comment

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

SimpleHTTPBin... my precious ;(

@mergify mergify bot merged commit 724f8d2 into develop Dec 19, 2023
@mergify mergify bot deleted the wip/radeusgd/8354-cloud-tests-2 branch December 19, 2023 17:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CI: No changelog needed Do not require a changelog entry for this PR. CI: Ready to merge This PR is eligible for automatic merge
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Review and Test Enso User and Cloud Utils
6 participants