-
Notifications
You must be signed in to change notification settings - Fork 17
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
Added dummy identity provider to remove Keystone dependancy during testing #162
base: master
Are you sure you want to change the base?
Conversation
217fddd
to
2e7a9bb
Compare
My apologies for the ugly diff. I should have waited to do linting and formatting at the end. I have re-written The only question I have left is how the test cases should be modified. References to the moved functions above will of course be changed, as well as references to the keystone idp, but I'd still like to ask...
|
We will be using
I'll have to think on that a bit. |
2e7a9bb
to
3288e63
Compare
esi-leap/esi_leap/common/idp/__init__.py Lines 8 to 11 in 3288e63
@larsks I've made the function above to allow code in the esi_leap API to obtain the configured IDP class at runtime, instead of at import time, as we've talked about in our Tuesday meeting. Since test cases can override the config file at runtime, this allows us to make the esi_leap API use arbitrary IDP classes. esi-leap/esi_leap/api/controllers/v1/utils.py Lines 143 to 144 in 3288e63
As shown above, with this change, code in the esi_leap API, such as the Controller classes, will obtain the idp by calling |
3288e63
to
488dedd
Compare
@larsks In this draft update, I have done the following:
I will fix the python 3.8 test later, since it requires a very small fix.
|
488dedd
to
0acb060
Compare
@larsks Is this PR still being considered? |
I'm not positive about my comment here (and I'd be interested to see what others thing), but I think that the IDP abstraction here is a layer too high. There are only two keystone calls being made - In my opinion, I think the right path would be to:
|
@QuanMPhm Yes, the past couple of weeks have just been a bit crazy. I'll try to take a look through the PR tomorrow. |
@tzumainn I abstracted the IDP instead of the individual Keystone functions based on @larsks' suggestion in the original issue (#159). Performing a text search over the Thinking about your suggestion a bit more, I can sort of understand that the only function in I have revised my PR to make it more complete and to make my vision of the final PR more clear. I've split the PR into 2 commits, since one only involves moving two functions around. I've also updated the commit message to better reflect the changes I added. Hopefully that will make this mess of a PR easier to follow. |
0acb060
to
787749e
Compare
Every function in It's important to recognize that That's why I'd strongly recommend those two functions being the point of abstraction; they represent an actual API call to keystone, and they are fundamentally what need to be abstracted if we want to replace keystone with an arbitrary IDP. Thinking about it another way: right now your implementation abstracts out the functions in |
787749e
to
9941af3
Compare
@tzumainn I have implemented your feedback, and will wait for further instructions before turning this draft into a PR. |
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.
Hi! Just a few comments inline. In addition, test_keystone.py
should probably be renamed test_idp.py
, and you'll want unit tests for both the keystone and dummy implementation. The resource_objects
do something similar.
esi_leap/common/idp.py
Outdated
# Get Client config option | ||
module_path, class_name = CONF.esi.idp_plugin_class.rsplit(".", 1) | ||
module = importlib.import_module(module_path) | ||
cli = getattr(module, class_name)() |
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.
This feels a little delicate - can you do something similar to what we do for resource objects? (https://github.com/CCI-MOC/esi-leap/blob/master/esi_leap/objects/lease.py#L313 which calls https://github.com/CCI-MOC/esi-leap/blob/master/esi_leap/resource_objects/__init__.py#L34)
during testing The identity provider used by `esi_leap` is now abstracted with a `BaseIDP` ABC, and implemented by two subclasses: A `KeystoneIDP` class which mostly copied the code from `common/keystone.py`, and `DummyIDP` which mocks a real IDP The IDP used by `esi_leap` can be set by overriding the `idp_type` CONF value like so: CONF.set_override( "idp_type", "dummy_idp", group="esi" ) As a consequence of abstracting the IDP, `common/keystone.py` has been removed. All references to `common/keystone.py` and the functions defined in it has been appropriately changed. New unit tests have been added for the keystone and dummy IDP clients
9941af3
to
f8099ba
Compare
@tzumainn I have addressed your comments so far |
Closes #159 after the draft is complete. The dummy identity provider (idp) can be enabled by setting the environment variable ESI_DEBUG to True. For now, the dummy idp returns information about a dummy project.
Some functions from
api/controllers/v1/utils.py
have been moved into the only controllers that use them and turned into static class methods.Assuming everyone is fine with these draft changes, the remaining steps would be to do some cleanup with the test cases.