-
Notifications
You must be signed in to change notification settings - Fork 326
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
Conversation
Enso_User
@@ -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 |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
77a6489
to
20966e9
Compare
fac3165
to
89ba2d4
Compare
20966e9
to
3d6856b
Compare
89ba2d4
to
17887d0
Compare
There was a problem hiding this 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.
3d6856b
to
f951403
Compare
ee87d57
to
ba2a8db
Compare
ba2a8db
to
baf0acc
Compare
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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) { |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
SimpleHTTPBin
... my precious ;(
Pull Request Description
simple-httpbin
with a simple mock of the Cloud API (currently it checks the token and serves the/users
endpoint).simple-httpbin
tohttp-test-helper
.Important Notes
Checklist
Please ensure that the following checklist has been satisfied before submitting the PR:
Scala,
Java,
and
Rust
style guides. In case you are using a language not listed above, follow the Rust style guide.
./run ide build
.