Skip to content

Commit

Permalink
Merge pull request #15 from gettyimages/update-auth-hostname
Browse files Browse the repository at this point in the history
Make auth requests with new hostname
  • Loading branch information
mapitman committed May 22, 2023
2 parents aca9a61 + d0ce98b commit 48d323e
Show file tree
Hide file tree
Showing 18 changed files with 21 additions and 16 deletions.
1 change: 1 addition & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ gem 'rake'
gem 'json'
gem 'test-unit'
gem 'webmock'
gem 'rexml'
4 changes: 3 additions & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ GEM
power_assert (1.1.6)
public_suffix (4.0.6)
rake (13.0.1)
rexml (3.2.5)
safe_yaml (1.0.5)
test-unit (3.3.5)
power_assert
Expand All @@ -27,8 +28,9 @@ PLATFORMS
DEPENDENCIES
json
rake
rexml
test-unit
webmock

BUNDLED WITH
2.1.4
2.2.22
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ GID := $(shell id -g)

build:
bundle config set --local path 'vendor/bundle'
bundle install --path vendor/bundle
bundle install
bundle exec rake
gem build gettyimages-api.gemspec

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ _Source code is only needed if you would like to contribute to the project. Othe

### Requirements

- Ruby version >= 2.5
- Ruby version >= 3.0
- [Bundler](http://bundler.io)

Install bundler and all dependencies
Expand Down
2 changes: 1 addition & 1 deletion lib/Credentials.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ def initialize(args)
end

def get_uri(path)
return URI.parse "#{Api_Host::API_BASE_URL}#{path}"
return URI.parse "#{Api_Host::AUTH_BASE_URL}#{path}"
end

def token_has_expired()
Expand Down
2 changes: 2 additions & 0 deletions lib/HttpHelper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
class Api_Host
API_HOST = "api.gettyimages.com"
API_BASE_URL = "https://#{API_HOST}"
AUTH_HOST = "authentication.gettyimages.com"
AUTH_BASE_URL = "https://#{AUTH_HOST}"
end

class HttpHelper
Expand Down
2 changes: 1 addition & 1 deletion unit_tests/CustomParamHeaderTests.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

class CustomParamHeaderTests < Test::Unit::TestCase
def setup
stub_request(:post, "https://api.gettyimages.com/oauth2/token").with(body: {"client_id"=>"api key", "client_secret"=>"api secret", "grant_type"=>"client_credentials"})
stub_request(:post, "https://authentication.gettyimages.com/oauth2/token").with(body: {"client_id"=>"api key", "client_secret"=>"api secret", "grant_type"=>"client_credentials"})
.to_return(status: 200, body: '{"access_token": "client_credentials_access_token", "token_types": "Bearer", "expires_in": "1800"}')
end

Expand Down
2 changes: 1 addition & 1 deletion unit_tests/CustomRequestsTests.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

class CustomRequestsTests < Test::Unit::TestCase
def setup
stub_request(:post, "https://api.gettyimages.com/oauth2/token").with(body: {"client_id"=>"api key", "client_secret"=>"api secret", "grant_type"=>"client_credentials"})
stub_request(:post, "https://authentication.gettyimages.com/oauth2/token").with(body: {"client_id"=>"api key", "client_secret"=>"api secret", "grant_type"=>"client_credentials"})
.to_return(status: 200, body: '{"access_token": "client_credentials_access_token", "token_types": "Bearer", "expires_in": "1800"}')
end

Expand Down
2 changes: 1 addition & 1 deletion unit_tests/DownloadImagesTests.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

class DownloadImagesTests < Test::Unit::TestCase
def setup
stub_request(:post, "https://api.gettyimages.com/oauth2/token").with(body: {"client_id"=>"api key", "client_secret"=>"api secret", "grant_type"=>"client_credentials"})
stub_request(:post, "https://authentication.gettyimages.com/oauth2/token").with(body: {"client_id"=>"api key", "client_secret"=>"api secret", "grant_type"=>"client_credentials"})
.to_return(status: 200, body: '{"access_token": "client_credentials_access_token", "token_types": "Bearer", "expires_in": "1800"}')
end

Expand Down
2 changes: 1 addition & 1 deletion unit_tests/DownloadVideosTests.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

class DownloadVideosTests < Test::Unit::TestCase
def setup
stub_request(:post, "https://api.gettyimages.com/oauth2/token").with(body: {"client_id"=>"api key", "client_secret"=>"api secret", "grant_type"=>"client_credentials"})
stub_request(:post, "https://authentication.gettyimages.com/oauth2/token").with(body: {"client_id"=>"api key", "client_secret"=>"api secret", "grant_type"=>"client_credentials"})
.to_return(status: 200, body: '{"access_token": "client_credentials_access_token", "token_types": "Bearer", "expires_in": "1800"}')
end

Expand Down
2 changes: 1 addition & 1 deletion unit_tests/ImagesTests.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

class ImagesTests < Test::Unit::TestCase
def setup
stub_request(:post, "https://api.gettyimages.com/oauth2/token").with(body: {"client_id"=>"api key", "client_secret"=>"api secret", "grant_type"=>"client_credentials"})
stub_request(:post, "https://authentication.gettyimages.com/oauth2/token").with(body: {"client_id"=>"api key", "client_secret"=>"api secret", "grant_type"=>"client_credentials"})
.to_return(status: 200, body: '{"access_token": "client_credentials_access_token", "token_types": "Bearer", "expires_in": "1800"}')
end

Expand Down
2 changes: 1 addition & 1 deletion unit_tests/SearchImagesCreativeTests.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

class SearchImagesCreativeTests < Test::Unit::TestCase
def setup
stub_request(:post, "https://api.gettyimages.com/oauth2/token").with(body: {"client_id"=>"api key", "client_secret"=>"api secret", "grant_type"=>"client_credentials"})
stub_request(:post, "https://authentication.gettyimages.com/oauth2/token").with(body: {"client_id"=>"api key", "client_secret"=>"api secret", "grant_type"=>"client_credentials"})
.to_return(status: 200, body: '{"access_token": "client_credentials_access_token", "token_types": "Bearer", "expires_in": "1800"}')
end

Expand Down
2 changes: 1 addition & 1 deletion unit_tests/SearchImagesEditorialTests.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

class SearchImagesEditorialTests < Test::Unit::TestCase
def setup
stub_request(:post, "https://api.gettyimages.com/oauth2/token").with(body: {"client_id"=>"api key", "client_secret"=>"api secret", "grant_type"=>"client_credentials"})
stub_request(:post, "https://authentication.gettyimages.com/oauth2/token").with(body: {"client_id"=>"api key", "client_secret"=>"api secret", "grant_type"=>"client_credentials"})
.to_return(status: 200, body: '{"access_token": "client_credentials_access_token", "token_types": "Bearer", "expires_in": "1800"}')
end

Expand Down
2 changes: 1 addition & 1 deletion unit_tests/SearchImagesTests.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

class SearchImagesTests < Test::Unit::TestCase
def setup
stub_request(:post, "https://api.gettyimages.com/oauth2/token").with(body: {"client_id"=>"api key", "client_secret"=>"api secret", "grant_type"=>"client_credentials"})
stub_request(:post, "https://authentication.gettyimages.com/oauth2/token").with(body: {"client_id"=>"api key", "client_secret"=>"api secret", "grant_type"=>"client_credentials"})
.to_return(status: 200, body: '{"access_token": "client_credentials_access_token", "token_types": "Bearer", "expires_in": "1800"}')
end

Expand Down
2 changes: 1 addition & 1 deletion unit_tests/SearchVideosCreativeTests.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

class SearchVideosCreativeTests < Test::Unit::TestCase
def setup
stub_request(:post, "https://api.gettyimages.com/oauth2/token").with(body: {"client_id"=>"api key", "client_secret"=>"api secret", "grant_type"=>"client_credentials"})
stub_request(:post, "https://authentication.gettyimages.com/oauth2/token").with(body: {"client_id"=>"api key", "client_secret"=>"api secret", "grant_type"=>"client_credentials"})
.to_return(status: 200, body: '{"access_token": "client_credentials_access_token", "token_types": "Bearer", "expires_in": "1800"}')
end

Expand Down
2 changes: 1 addition & 1 deletion unit_tests/SearchVideosEditorialTests.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

class SearchVideosEditorialTests < Test::Unit::TestCase
def setup
stub_request(:post, "https://api.gettyimages.com/oauth2/token").with(body: {"client_id"=>"api key", "client_secret"=>"api secret", "grant_type"=>"client_credentials"})
stub_request(:post, "https://authentication.gettyimages.com/oauth2/token").with(body: {"client_id"=>"api key", "client_secret"=>"api secret", "grant_type"=>"client_credentials"})
.to_return(status: 200, body: '{"access_token": "client_credentials_access_token", "token_types": "Bearer", "expires_in": "1800"}')
end

Expand Down
2 changes: 1 addition & 1 deletion unit_tests/SearchVideosTests.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

class SearchVideosTests < Test::Unit::TestCase
def setup
stub_request(:post, "https://api.gettyimages.com/oauth2/token").with(body: {"client_id"=>"api key", "client_secret"=>"api secret", "grant_type"=>"client_credentials"})
stub_request(:post, "https://authentication.gettyimages.com/oauth2/token").with(body: {"client_id"=>"api key", "client_secret"=>"api secret", "grant_type"=>"client_credentials"})
.to_return(status: 200, body: '{"access_token": "client_credentials_access_token", "token_types": "Bearer", "expires_in": "1800"}')
end

Expand Down
2 changes: 1 addition & 1 deletion unit_tests/VideosTests.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

class VideosTests < Test::Unit::TestCase
def setup
stub_request(:post, "https://api.gettyimages.com/oauth2/token").with(body: {"client_id"=>"api key", "client_secret"=>"api secret", "grant_type"=>"client_credentials"})
stub_request(:post, "https://authentication.gettyimages.com/oauth2/token").with(body: {"client_id"=>"api key", "client_secret"=>"api secret", "grant_type"=>"client_credentials"})
.to_return(status: 200, body: '{"access_token": "client_credentials_access_token", "token_types": "Bearer", "expires_in": "1800"}')
end

Expand Down

0 comments on commit 48d323e

Please sign in to comment.