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

feat: added system tests for the asyncIO auth changes and async id_token credentials #574

Merged
merged 38 commits into from
Jul 31, 2020

Conversation

anibadde
Copy link
Contributor

@anibadde anibadde commented Jul 28, 2020

PR # 3 for AsyncIO Auth Class changes

  • Added in system tests paralleling existing regular system tests for the async implementation of the auth library and credentials
  • Fixed Timeout Context Manager bug that enables connection to asynchronous resumable media implementation.
  • Added in async id token credentials logic along with defaul, service account systems.
  • Required for credential depending on existence/validity of service account file

@google-cla
Copy link

google-cla bot commented Jul 28, 2020

Thanks for your pull request. It looks like this may be your first contribution to a Google open source project (if not, look below for help). Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

📝 Please visit https://cla.developers.google.com/ to sign.

Once you've signed (or fixed any issues), please reply here with @googlebot I signed it! and we'll verify it.


What to do if you already signed the CLA

Individual signers
Corporate signers

ℹ️ Googlers: Go here for more info.

@google-cla google-cla bot added the cla: no This human has *not* signed the Contributor License Agreement. label Jul 28, 2020
@tritone tritone requested review from crwilcox, busunkim96, andrewsg and frankyn and removed request for crwilcox July 28, 2020 15:07
@anibadde
Copy link
Contributor Author

@googlebot I signed it!

@google-cla google-cla bot added cla: yes This human has signed the Contributor License Agreement. and removed cla: no This human has *not* signed the Contributor License Agreement. labels Jul 28, 2020
@anibadde
Copy link
Contributor Author

@googlebot I signed it!

@frankyn frankyn changed the base branch from master to async July 28, 2020 16:52
@anibadde
Copy link
Contributor Author

@googlebot I signed it!

@busunkim96 busunkim96 closed this Jul 31, 2020
@busunkim96 busunkim96 reopened this Jul 31, 2020
@anibadde anibadde changed the title feat: added system tests for the asyncIO auth changes feat: added system tests for the asyncIO auth changes and async id_token credentials Jul 31, 2020
Copy link

@tritone tritone left a comment

Choose a reason for hiding this comment

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

Good progress! I think there's definitely some de-duplication that can happen in the nox and pytest configurations; @crwilcox might have more ideas. I'm also curious to hear other's thoughts on whether more system tests should be added.


session = requests.session()
cached_session = cachecontrol.CacheControl(session)
request = google.auth.transport.requests.Request(session=cached_session)
Copy link

Choose a reason for hiding this comment

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

Would this be the same for async?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I made this specific request call sync as an async version of this would result in a substantial re-working of the compute_engine credentials classes (as the current design is not compatible with asynchronous http requests). My reasoning for this was that this authentication trace isn't used in storage, but we could open up an issue for it as a future modification to make for the auth library.

Copy link
Contributor

Choose a reason for hiding this comment

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

Please open a tracking bug

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ok will do.

"Could not fetch certificates at {}".format(certs_url)
)

data = await response.data.read()
Copy link

Choose a reason for hiding this comment

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

Is this a network op?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, response.data returns a stream coroutine, and therefore needs to be awaited in order to read the content of the response.

google/oauth2/id_token_async.py Show resolved Hide resolved


HERE = os.path.dirname(__file__)
DATA_DIR = os.path.join(HERE, "data")
Copy link

Choose a reason for hiding this comment

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

So it seems like this will require the data to be re-copied into system_tests_async/data as well? Could we avoid that by using the same data dir for both sets of system tests?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I thought about this, since the data files aren't in the repository and are there for the user to run locally, I thought that it may make sense to leave this logic as is (without a dependency on the sync system tests) in case someone wanted to import the data files just for the async use case, similar to what I did when I was working on this and running tests locally. I think that regardless of whether we change the directory name, we would have to follow the steps in https://github.com/googleapis/google-auth-library-python/blob/master/CONTRIBUTING.rst to be able to run these tests.

I'm open to changing the directory if that would be better, but I thought it would be good to avoid the dependency in this case?



@pytest.fixture
def service_account_file():
Copy link

Choose a reason for hiding this comment

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

If these are copied from system_tests/conftest.py, could they be moved to the root conftest.py to de-duplicate?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Same inter-dependency reasoning as above, open to changing if we are okay with having the dependency.

system_tests_async/noxfile.py Outdated Show resolved Hide resolved
system_tests_async/test_default.py Outdated Show resolved Hide resolved
system_tests_async/test_service_account.py Outdated Show resolved Hide resolved
tests_async/oauth2/test_id_token.py Outdated Show resolved Hide resolved
"https://www.googleapis.com/auth/userinfo.email",
"https://www.googleapis.com/auth/userinfo.profile",
]
)
Copy link

Choose a reason for hiding this comment

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

So I see 2 system tests in this file, and 1 for id token. Does the sync version have additional system tests that you did not copy? If so, why?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The sync version also has 1 system test for id_token and 2 for service accounts, so a parallel code trace (same corresponding tests) are used here as in the sync system tests.

google/oauth2/id_token_async.py Show resolved Hide resolved
google/oauth2/id_token_async.py Outdated Show resolved Hide resolved
system_tests_async/noxfile.py Outdated Show resolved Hide resolved
@crwilcox crwilcox merged commit 0576ed3 into googleapis:async Jul 31, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla: yes This human has signed the Contributor License Agreement.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants