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

pulibrary / allsearch_api / 29cc47ba-38a5-447a-9a89-fa55bc36f401

14 Oct 2025 01:59PM UTC coverage: 99.32% (-0.2%) from 99.514%
29cc47ba-38a5-447a-9a89-fa55bc36f401

Pull #395

circleci

sandbergja
add missing require_relative
Pull Request #395: Migrate a few more controllers away from Rails

8 of 8 new or added lines in 4 files covered. (100.0%)

90 existing lines in 18 files now uncovered.

1022 of 1029 relevant lines covered (99.32%)

96.72 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✔
UNCOV
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