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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

[spaceship] spaceauth - add new functionality to check if a user's session is still valid #19658

Merged
merged 3 commits into from
Dec 9, 2021

Conversation

justAnotherDev
Copy link
Contributor

Checklist

  • I've run bundle exec rspec from the root directory to see all new and existing tests pass
  • I've followed the fastlane code style and run bundle exec rubocop -a to ensure the code style is valid
  • I've read the Contribution Guidelines
  • I've updated the documentation if necessary.

Motivation and Context

For CI testing it would be useful to quickly/succinctly tell if a spaceship session for a specific user is still valid. This would allow a CI build to immediately fail a task that requires authentication if the session is expired/missing.

Description

This PR adds a new parameter, --check_session, to expose existing code in the spaceauth command. Using the new parameter allows users to check if a session is still valid. If the session is valid the command will exit with a status code of 0, if the session is invalid it will exit with a status code of 1.

Example Usage:

fastlane spaceauth --check_session
[鉁擼 馃殌 
Username: some-valid-user
Valid session found (some-valid-user). Exiting.
fastlane spaceauth --check_session -u some-expired-user
[鉁擼 馃殌 
No valid session found (some-expired-user). Exiting.

Testing Steps

Testing via the CLI should be pretty straightforward, recommend testing with and without a user set in the Appfile and testing with real and fake usernames.

fastlane spaceauth --check_session
fastlane spaceauth --check_session -u real-username
fastlane spaceauth --check_session -u fake-username

There are also 3 new tests that can be run locally:

bundle exec rspec spaceship/spec/spaceauth_spec.rb

Spaceship::SpaceauthRunner
  uses all required cookies for fastlane session
  copy_to_clipboard option
    when true, it should copy the session to clipboard
    when false, it should not copy the session to clipboard
  check_session option
    when using the default user, it should return a message saying the session is logged in with an exit code of 0
    when passed a known user, it should return a message saying the session is logged in with an exit code of 0
    when passed an unknown user, it should return a message saying no valid session found with an exit code of 1
  #session_string
    should return the session when called after run
    should throw when called before run

Finished in 0.83703 seconds (files took 3.54 seconds to load)
8 examples, 0 failures

@google-cla google-cla bot added the cla: no label Nov 29, 2021
@justAnotherDev
Copy link
Contributor Author

The CLA has been signed, please rescan.

@google-cla google-cla bot added cla: yes and removed cla: no labels Dec 3, 2021
@joshdholtz joshdholtz changed the title Add new functionality to check if a user's session is still valid [spaceship] add new functionality to check if a user's session is still valid Dec 9, 2021
@joshdholtz joshdholtz changed the title [spaceship] add new functionality to check if a user's session is still valid [spaceship] spaceauth - add new functionality to check if a user's session is still valid Dec 9, 2021
Copy link
Member

@joshdholtz joshdholtz left a comment

Choose a reason for hiding this comment

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

This is 馃敟 Thank you so much for adding this and tests! Really appreciate the contribution 馃グ

@joshdholtz joshdholtz merged commit a6be336 into fastlane:master Dec 9, 2021
@fastlane-bot
Copy link

Hey @justAnotherDev 馃憢

Thank you for your contribution to fastlane and congrats on getting this pull request merged 馃帀
The code change now lives in the master branch, however it wasn't released to RubyGems yet.
We usually ship about once a week, and your PR will be included in the next one.

Please let us know if this change requires an immediate release by adding a comment here 馃憤
We'll notify you once we shipped a new release with your changes 馃殌

Copy link

@fastlane-bot fastlane-bot left a comment

Choose a reason for hiding this comment

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

Congratulations! 馃帀 This was released as part of fastlane 2.199.0 馃殌

@fastlane fastlane locked and limited conversation to collaborators Feb 9, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants