• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

pulibrary / allsearch_api / dc764cb3-fc9b-47a1-b010-56b68ecb28a7

01 Aug 2025 03:30PM UTC coverage: 99.514%. Remained the same
dc764cb3-fc9b-47a1-b010-56b68ecb28a7

push

circleci

web-flow
Merge pull request #384 from pulibrary/dependabot/bundler/nokogiri-1.18.9

Bump nokogiri from 1.18.8 to 1.18.9

1024 of 1029 relevant lines covered (99.51%)

92.23 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

100.0
/app/services/oauth_service.rb
1
# frozen_string_literal: true
2

3
# This class is responsible for communicating with an
4
# OAuth server to get new access tokens
5
class OAuthService
3✔
6
  def initialize(endpoint:, service:)
3✔
7
    @endpoint = URI(endpoint)
26✔
8
    @service = service.to_sym
26✔
9
  end
10

11
  def new_token
3✔
12
    token = JSON.parse(response.body)['access_token']
25✔
13
    unless token
25✔
14
      raise AllsearchError.new(problem: 'UPSTREAM_ERROR',
2✔
15
                               msg: 'Could not generate a valid authentication token with upstream service.')
16
    end
17
    token
23✔
18
  end
19

20
  def expiration_time
3✔
21
    validity_in_seconds = JSON.parse(response.body)['expires_in']
23✔
22
    validity_in_seconds.seconds.from_now - 1.hour
23✔
23
  end
24

25
  private
3✔
26

27
  attr_reader :endpoint, :service
3✔
28

29
  def client_id
3✔
30
    configuration[:client_id]
26✔
31
  end
32

33
  def client_secret
3✔
34
    configuration[:client_secret]
26✔
35
  end
36

37
  def response
3✔
38
    @response ||= Net::HTTP.post_form(endpoint, client_id:, client_secret:, grant_type:)
48✔
39
  end
40

41
  def grant_type
3✔
42
    'client_credentials'
26✔
43
  end
44

45
  def configuration
3✔
46
    @configuration ||= Rails.application.config_for(:allsearch)[service]
52✔
47
  end
48
end
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc