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

[spaceship] Move endpoint version from hostname to path #21900

Merged

Conversation

lucgrabowski
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 see several green ci/circleci builds in the "All checks have passed" section of my PR (connect CircleCI to GitHub if not)
  • I've read the Contribution Guidelines
  • I've updated the documentation if necessary.
  • I've added or updated relevant unit tests.

Motivation and Context

There is a need for preparing fastlane for implementation of requests that have v2 or v3 version in path component as noted in #21890.
There are requests defined in open api spec (https://developer.apple.com/documentation/appstoreconnectapi) that don't have v1 in path, e.g. https://developer.apple.com/documentation/appstoreconnectapi/read_app_availablity_territories
GET https://api.appstoreconnect.apple.com/v2/appAvailabilities/{id}/territoryAvailabilities

From spec:

"paths" : {
...
  "/v2/appAvailabilities/{id}/territoryAvailabilities" : {
      "get" : {
...

Description

Endpoint's hostnames for ConnectAPI had hardcoded endpoint version v1, also for https://api.appstoreconnect.apple.com/v1/ when API token is used.
In this PR v1 version is moved from hostname to paths for 4 ConnectAPI clients:

  • tunes_request_client
  • provisioning_request_client
  • test_flight_request_client
  • users_request_client

Also, this change required change in stats_middleware and stats_middleware_spec to properly log use of endpoints.

Testing Steps

Runned unit tests. Not all client methods are tested though, so I checked that all get, post, patch and delete requests in code have v1 in path with simple regular expressions:

tunes_request_client\.(get|post|patch|delete)
provisioning_request_client\.(get|post|patch|delete)
test_flight_request_client\.(get|post|patch|delete)
users_request_client\.(get|post|patch|delete)
provisioning_request_client\.(get|post|patch|delete)\("#\{Version::V1\}/
users_request_client\.(get|post|patch|delete)\("#\{Version::V1\}/
test_flight_request_client\.(get|post|patch|delete)\("#\{Version::V1\}/
tunes_request_client\.(get|post|patch|delete)\("#\{Version::V1\}/

Copy link

@shernade shernade left a comment

Choose a reason for hiding this comment

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

There's a lot of modified files, but easy changes. Looks ok to me.

ServiceOption.new("Legacy iTunesConnect Auth", "idmsa.apple.com", "Web session"),
ServiceOption.new("Legacy iTunesConnect Auth", "appstoreconnect.apple.com/olympus/v1/", "Web session"),
ServiceOption.new("Legacy iTunesConnect", Spaceship::TunesClient.hostname.gsub("https://", ""), "Web session"),
ServiceOption.new("Legacy iTunesConnect Developer Portal", Spaceship::PortalClient.hostname.gsub("https://", ""), "Web session")
ServiceOption.new("Legacy iTunesConnect Developer Portal", Spaceship::PortalClient.hostname.gsub("https://", ""), "Web session"),
ServiceOption.new("App Store Connect API (web session)", Spaceship::ConnectAPI::Provisioning::Client.hostname.gsub("https://", ""), "Web session")

Choose a reason for hiding this comment

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

why did you change the order in this?

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 think that the reason was that after the changes
Spaceship::PortalClient.hostname is https://developer.apple.com/services-account/QH65B2
Spaceship::ConnectAPI::Provisioning::Client.hostname is https://developer.apple.com/services-account/
and without changing the order, all the calls would have been matched by more generic https://developer.apple.com/services-account/ and the spec was failing because of that.

Copy link
Contributor

@max-ott max-ott left a comment

Choose a reason for hiding this comment

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

Looking good so far. Is the motivation behind this change to make it easier to switch versions (v1 -> v2) for specific models?

@jakub-przy
Copy link

Hey, have we got any updates on this? Thanks

Copy link
Contributor

@max-ott max-ott left a comment

Choose a reason for hiding this comment

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

Looking good!

@max-ott max-ott merged commit 3c3a937 into master May 3, 2024
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants