sequencescape-client-api 0.5.0.pre.rc1 → 0.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (30) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/ruby.yml +39 -0
  3. data/.gitignore +1 -0
  4. data/README.markdown +10 -7
  5. data/lib/sequencescape-api.rb +1 -0
  6. data/lib/sequencescape-api/connection_factory.rb +5 -5
  7. data/lib/sequencescape-api/connection_factory/actions.rb +1 -1
  8. data/lib/sequencescape-api/rails.rb +5 -9
  9. data/lib/sequencescape-api/version.rb +1 -1
  10. data/spec/sequencescape-api/contracts/create-invalid-resource.txt +1 -1
  11. data/spec/sequencescape-api/contracts/create-model-c-has-many-inline-nested.txt +1 -1
  12. data/spec/sequencescape-api/contracts/create-model-c-has-many-inline.txt +1 -1
  13. data/spec/sequencescape-api/contracts/create-model-c-has-many.txt +1 -1
  14. data/spec/sequencescape-api/contracts/create-model-c.txt +1 -1
  15. data/spec/sequencescape-api/contracts/create-via-has-many.txt +1 -1
  16. data/spec/sequencescape-api/contracts/retrieve-belongs-to-association.txt +1 -1
  17. data/spec/sequencescape-api/contracts/retrieve-model.txt +1 -2
  18. data/spec/sequencescape-api/contracts/retrieve-results-page-1.txt +1 -1
  19. data/spec/sequencescape-api/contracts/retrieve-results-page-2.txt +1 -1
  20. data/spec/sequencescape-api/contracts/retrieve-results-page-3.txt +1 -1
  21. data/spec/sequencescape-api/contracts/retrieve-root-with-an-authorised-client.txt +1 -2
  22. data/spec/sequencescape-api/contracts/retrieve-root-with-an-unauthorised-client.txt +1 -2
  23. data/spec/sequencescape-api/contracts/retrieve-unauthorised-model-a-list.txt +1 -2
  24. data/spec/sequencescape-api/contracts/retrieve-unauthorised-model-b-list.txt +1 -2
  25. data/spec/sequencescape-api/contracts/retrieve-unauthorised-model-c-list.txt +1 -2
  26. data/spec/sequencescape-api/contracts/update-invalid-resource.txt +1 -1
  27. data/spec/sequencescape-api/contracts/update-model-c.txt +1 -1
  28. data/spec/sequencescape-api/root_spec.rb +2 -2
  29. data/spec/support/contract_helper.rb +2 -2
  30. metadata +5 -4
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ca6bcf02a9824bf838a8f170a749c0772de14eacb3a8dc909c95ba1fb4ada5be
4
- data.tar.gz: fe09bb2f3e35c9257717cf6dafbc8c1e69cc95bbc9742e5e4862f5fa480130db
3
+ metadata.gz: '058f9686bbfcf2b51cfae0e49a76a548ed1915c7ab95e1e3c5361d7c8b32349f'
4
+ data.tar.gz: 443b45baeb30befd08490f3531ec84d80aafef4a0a852562e3a3da50598c3b56
5
5
  SHA512:
6
- metadata.gz: c847b9a8b44eca0ce5efe11aa177ef7c08de6b7751f234d004dc16a4464dab98887b9f7cb28ee0b4ebcf67b121d9bccce67cd0a2d95c43fdd10473a56a44fe47
7
- data.tar.gz: 3fe0065e18af4e98165966868c3a7790b87c50afdfb6e174ec0d43d74e5ed72a5ac24b9edeadb6b4c5d5eb4e406253c189b695c7b3c3b6cd46f19271a7fef17a
6
+ metadata.gz: 9d66b494b52bcd21453aa4af9d665182fa5a2f0bfd38c6f6fb8c7d4d1c86c270dd5c708ecf9f71933a2f8f69f6144c13734997ba61c5f5e7ec402258a1f00e1a
7
+ data.tar.gz: 90e38c15a88bb7c8454a102d42ebeb894500201c8b5c954385e474fc11e39e563dffe393088f06f9a1c24e3bb65940abd4e09501543eb788199ab1b4c9b2ac73
@@ -0,0 +1,39 @@
1
+ name: Ruby
2
+
3
+ on:
4
+ - push
5
+ - pull_request
6
+
7
+ jobs:
8
+ test:
9
+ runs-on: ubuntu-latest
10
+ strategy:
11
+ matrix:
12
+ ruby: ["2.5", "2.6", "2.7", "3.0"]
13
+ name: Ruby Test ${{ matrix.ruby }}
14
+
15
+ steps:
16
+ - uses: actions/checkout@v2
17
+ - name: Set up Ruby
18
+ uses: ruby/setup-ruby@v1
19
+ with:
20
+ ruby-version: ${{ matrix.ruby }}
21
+ bundler-cache:
22
+ true # Runs bundle install and caches gems. See the ruby_test.yml
23
+ # example if you need more control over bundler.
24
+ - name: Run tests
25
+ run: bundle exec rspec
26
+ lint:
27
+ runs-on: ubuntu-latest
28
+
29
+ steps:
30
+ - uses: actions/checkout@v2
31
+ - name: Set up Ruby
32
+ uses: ruby/setup-ruby@v1
33
+ with:
34
+ ruby-version: 3.0
35
+ bundler-cache:
36
+ true # Runs bundle install and caches gems. See the ruby_test.yml
37
+ # example if you need more control over bundler.
38
+ - name: Run lint
39
+ run: bundle exec rubocop
data/.gitignore CHANGED
@@ -5,3 +5,4 @@ pkg/*
5
5
  tags
6
6
  .DS_Store
7
7
  lib/.DS_Store
8
+ .talismanrc
data/README.markdown CHANGED
@@ -1,24 +1,25 @@
1
- Sequencescape Client API
2
- ========================
1
+ # Sequencescape Client API
3
2
 
4
3
  This is the Ruby client library for the Sequencescape API.
5
4
  Documentation can be found [on the wiki](https://github.com/sanger/sequencescape-client-api/wiki).
6
5
 
7
- Version Guides
8
- --------------
6
+ ## Version Guides
9
7
 
10
8
  - 0.2.x Supports older versions of Rails.
11
9
  - 0.3.x Supports Rails 3.2.x to 5.1.x
12
10
  - 0.4.x Supports Rails 5.0 and up
13
11
  - 0.5.x Supports Rails 5.0 and up, drops yajl in favour of multi-json
12
+ - 0.6.x Removes usage of WTSISignOn cookie. Replaces with user specific api key,
13
+ can be provided to Sequencescape::Api.new as user_api_key: or via
14
+ `api_connection_options` in the controller.
14
15
 
15
- - master currently corresponds to 0.5.x
16
+ - master currently corresponds to 0.6.x
16
17
 
17
18
  Rails 6 appears to be supported judging by Specs, but haven't used it in anger
18
19
  yet.
19
20
 
20
- Making a release
21
- ----------------
21
+ ## Making a release
22
+
22
23
  1. Update the version number in `lib/sequencescape-api/version.rb`
23
24
  2. For pre-releases the version number should be in the format:
24
25
  major.minor.point-rcx
@@ -26,6 +27,8 @@ Making a release
26
27
  major.minor.point
27
28
  4. Ensure everything is committed, and for non-pre-releases, make sure you are
28
29
  merged to master.
30
+
29
31
  ```
30
32
  rake release
31
33
  ``
34
+ ```
@@ -1,4 +1,5 @@
1
1
  require 'active_support'
2
+ require 'active_support/core_ext/array/extract_options'
2
3
  require 'active_support/core_ext/module/delegation'
3
4
  require 'active_support/core_ext/class'
4
5
  require 'active_support/core_ext/kernel/singleton_class'
@@ -7,8 +7,8 @@ class Sequencescape::Api::ConnectionFactory
7
7
 
8
8
  def self.create(options)
9
9
  required_options = []
10
- required_options.push(:cookie) if options[:authorisation].blank?
11
- required_options.push(:url) if default_url.blank?
10
+ required_options.push(:user_api_key) if options[:authorisation].blank?
11
+ required_options.push(:url) if default_url.blank?
12
12
 
13
13
  required_options.push(allow_blank: false)
14
14
  options.required!(*required_options) do |missing|
@@ -19,12 +19,12 @@ class Sequencescape::Api::ConnectionFactory
19
19
  new(options)
20
20
  end
21
21
 
22
- attr_reader :url, :cookie, :read_timeout
23
- private :url, :cookie, :read_timeout
22
+ attr_reader :url, :user_api_key, :read_timeout
23
+ private :url, :user_api_key, :read_timeout
24
24
 
25
25
  def initialize(options)
26
26
  @url = options[:url]
27
- @cookie = options[:cookie]
27
+ @user_api_key = options[:user_api_key]
28
28
  @authorisation = options[:authorisation]
29
29
  @read_timeout = options[:read_timeout] || 120
30
30
  end
@@ -151,7 +151,7 @@ module Sequencescape::Api::ConnectionFactory::Actions
151
151
  private :parse_json_from
152
152
 
153
153
  def headers
154
- { 'Accept' => 'application/json', 'Cookie' => "WTSISignOn=#{cookie}" }.tap do |standard|
154
+ { 'Accept' => 'application/json', 'Cookie' => "api_key=#{user_api_key}" }.tap do |standard|
155
155
  standard.merge!('X-Sequencescape-Client-ID' => @authorisation) unless @authorisation.blank?
156
156
  end
157
157
  end
@@ -1,7 +1,6 @@
1
1
  module Sequencescape::Api::Rails
2
2
  # Including this module into your Rails ApplicationController adds a before filter that will
3
- # provide a user (based on the WTSISignOn cookie) specific Sequencescape::Api instance to
4
- # use, accessible through `api`.
3
+ # provide a Sequencescape::Api instance to use, accessible through `api`.
5
4
  module ApplicationController
6
5
  def self.included(base) # rubocop:todo Metrics/MethodLength
7
6
  base.class_eval do
@@ -20,32 +19,29 @@ module Sequencescape::Api::Rails
20
19
  end
21
20
  end
22
21
 
22
+ private
23
+
23
24
  def api_class
24
25
  ::Sequencescape::Api
25
26
  end
26
- private :api_class
27
27
 
28
28
  def configure_api
29
- @api = api_class.new({ cookie: cookies['WTSISignOn'] }.merge(api_connection_options))
29
+ @api = api_class.new(api_connection_options)
30
30
  end
31
- private :configure_api
32
31
 
33
32
  def api_connection_options
34
- {}
33
+ raise Sequencescape::Api::Error, "api_connection_options not implemented for #{self.class}"
35
34
  end
36
- private :api_connection_options
37
35
 
38
36
  def sequencescape_api_error_handler(exception)
39
37
  Rails.logger.error "#{exception}, #{exception.backtrace}"
40
38
  raise StandardError, "There is an issue with the API connection to Sequencescape (#{exception.message})"
41
39
  end
42
- private :sequencescape_api_error_handler
43
40
 
44
41
  def sequencescape_api_unauthenticated_handler(exception)
45
42
  Rails.logger.error "#{exception}, #{exception.backtrace}"
46
43
  raise StandardError, 'You are not authenticated; please visit the WTSI login page'
47
44
  end
48
- private :sequencescape_api_unauthenticated_handler
49
45
  end
50
46
 
51
47
  # Including this module into your Rails model indicates that the model is associated with
@@ -1,5 +1,5 @@
1
1
  module Sequencescape
2
2
  class Api
3
- VERSION = '0.5.0-rc1'.freeze
3
+ VERSION = '0.6.0'.freeze
4
4
  end
5
5
  end
@@ -1,7 +1,7 @@
1
1
  POST /model_c/create HTTP/1.1
2
2
  Accept: application/json
3
3
  Content-Type: application/json
4
- Cookie: WTSISignOn=single-sign-on-cookie
4
+ Cookie: api_key=single-sign-on-cookie
5
5
 
6
6
  {
7
7
  "model_c": {
@@ -1,7 +1,7 @@
1
1
  POST /model_c/create HTTP/1.1
2
2
  Accept: application/json
3
3
  Content-Type: application/json
4
- Cookie: WTSISignOn=single-sign-on-cookie
4
+ Cookie: api_key=single-sign-on-cookie
5
5
 
6
6
  {
7
7
  "model_c": {
@@ -1,7 +1,7 @@
1
1
  POST /model_c/create HTTP/1.1
2
2
  Accept: application/json
3
3
  Content-Type: application/json
4
- Cookie: WTSISignOn=single-sign-on-cookie
4
+ Cookie: api_key=single-sign-on-cookie
5
5
 
6
6
  {
7
7
  "model_c": {
@@ -1,7 +1,7 @@
1
1
  POST /model_c/create HTTP/1.1
2
2
  Accept: application/json
3
3
  Content-Type: application/json
4
- Cookie: WTSISignOn=single-sign-on-cookie
4
+ Cookie: api_key=single-sign-on-cookie
5
5
 
6
6
  {
7
7
  "model_c": {
@@ -1,7 +1,7 @@
1
1
  POST /model_c/create HTTP/1.1
2
2
  Accept: application/json
3
3
  Content-Type: application/json
4
- Cookie: WTSISignOn=single-sign-on-cookie
4
+ Cookie: api_key=single-sign-on-cookie
5
5
 
6
6
  {
7
7
  "model_c": {
@@ -1,7 +1,7 @@
1
1
  POST /UUID/model_bs HTTP/1.1
2
2
  Accept: application/json
3
3
  Content-Type: application/json
4
- Cookie: WTSISignOn=single-sign-on-cookie
4
+ Cookie: api_key=single-sign-on-cookie
5
5
 
6
6
  {
7
7
  "model_b": {
@@ -1,3 +1,3 @@
1
1
  GET /BELONGS_TO_UUID HTTP/1.1
2
2
  Accept: application/json
3
- Cookie: WTSISignOn=single-sign-on-cookie
3
+ Cookie: api_key=single-sign-on-cookie
@@ -1,4 +1,3 @@
1
1
  GET /UUID HTTP/1.1
2
2
  Accept: application/json
3
- Cookie: WTSISignOn=single-sign-on-cookie
4
-
3
+ Cookie: api_key=single-sign-on-cookie
@@ -1,3 +1,3 @@
1
1
  GET /pages/1 HTTP/1.1
2
2
  Accept: application/json
3
- Cookie: WTSISignOn=single-sign-on-cookie
3
+ Cookie: api_key=single-sign-on-cookie
@@ -1,3 +1,3 @@
1
1
  GET /pages/2 HTTP/1.1
2
2
  Accept: application/json
3
- Cookie: WTSISignOn=single-sign-on-cookie
3
+ Cookie: api_key=single-sign-on-cookie
@@ -1,3 +1,3 @@
1
1
  GET /pages/3 HTTP/1.1
2
2
  Accept: application/json
3
- Cookie: WTSISignOn=single-sign-on-cookie
3
+ Cookie: api_key=single-sign-on-cookie
@@ -1,5 +1,4 @@
1
1
  GET / HTTP/1.1
2
2
  Accept: application/json
3
- Cookie: WTSISignOn=single-sign-on-cookie
3
+ Cookie: api_key=single-sign-on-cookie
4
4
  X-Sequencescape-Client-Id: authorised!
5
-
@@ -1,4 +1,3 @@
1
1
  GET / HTTP/1.1
2
2
  Accept: application/json
3
- Cookie: WTSISignOn=single-sign-on-cookie
4
-
3
+ Cookie: api_key=single-sign-on-cookie
@@ -1,4 +1,3 @@
1
1
  GET /model_a HTTP/1.1
2
2
  Accept: application/json
3
- Cookie: WTSISignOn=single-sign-on-cookie
4
-
3
+ Cookie: api_key=single-sign-on-cookie
@@ -1,4 +1,3 @@
1
1
  GET /model_b HTTP/1.1
2
2
  Accept: application/json
3
- Cookie: WTSISignOn=single-sign-on-cookie
4
-
3
+ Cookie: api_key=single-sign-on-cookie
@@ -1,4 +1,3 @@
1
1
  GET /model_c HTTP/1.1
2
2
  Accept: application/json
3
- Cookie: WTSISignOn=single-sign-on-cookie
4
-
3
+ Cookie: api_key=single-sign-on-cookie
@@ -1,7 +1,7 @@
1
1
  PUT /UUID HTTP/1.1
2
2
  Accept: application/json
3
3
  Content-Type: application/json
4
- Cookie: WTSISignOn=single-sign-on-cookie
4
+ Cookie: api_key=single-sign-on-cookie
5
5
 
6
6
  {
7
7
  "model_c": {
@@ -1,7 +1,7 @@
1
1
  PUT /UUID HTTP/1.1
2
2
  Accept: application/json
3
3
  Content-Type: application/json
4
- Cookie: WTSISignOn=single-sign-on-cookie
4
+ Cookie: api_key=single-sign-on-cookie
5
5
 
6
6
  {
7
7
  "model_c": {
@@ -5,7 +5,7 @@ require 'spec_helper'
5
5
  describe 'Handling authentication issues' do
6
6
  stub_request_from('retrieve-root-with-an-unauthorised-client') { response('client-fails-authentication') }
7
7
 
8
- subject { Sequencescape::Api.new(url: 'http://localhost:3000/', cookie: 'single-sign-on-cookie') }
8
+ subject { Sequencescape::Api.new(url: 'http://localhost:3000/', user_api_key: 'single-sign-on-cookie') }
9
9
 
10
10
  it 'raises an exception' do
11
11
  -> { subject }.should raise_error(Sequencescape::Api::UnauthenticatedError)
@@ -17,7 +17,7 @@ describe 'Retrieving the root URL' do
17
17
  is_working_as_an_unauthorised_client
18
18
 
19
19
  context 'with no namespace' do
20
- subject { Sequencescape::Api.new(url: 'http://localhost:3000/', cookie: 'single-sign-on-cookie') }
20
+ subject { Sequencescape::Api.new(url: 'http://localhost:3000/', user_api_key: 'single-sign-on-cookie') }
21
21
 
22
22
  Unauthorised::MODELS_THROUGH_API.each do |model|
23
23
  it "provides the #{model} through the API instance" do
@@ -96,7 +96,7 @@ module ContractHelper
96
96
  end
97
97
  let(:api) do
98
98
  Sequencescape::Api.new(
99
- url: 'http://localhost:3000/', cookie: 'single-sign-on-cookie',
99
+ url: 'http://localhost:3000/', user_api_key: 'single-sign-on-cookie',
100
100
  namespace: Unauthorised
101
101
  )
102
102
  end
@@ -107,7 +107,7 @@ module ContractHelper
107
107
 
108
108
  let(:api) do
109
109
  Sequencescape::Api.new(
110
- url: 'http://localhost:3000/', cookie: 'single-sign-on-cookie',
110
+ url: 'http://localhost:3000/', user_api_key: 'single-sign-on-cookie',
111
111
  authorisation: 'authorised!', namespace: Authenticated
112
112
  )
113
113
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sequencescape-client-api
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.0.pre.rc1
4
+ version: 0.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Matthew Denner
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2020-11-20 00:00:00.000000000 Z
13
+ date: 2021-07-28 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: activemodel
@@ -190,6 +190,7 @@ executables: []
190
190
  extensions: []
191
191
  extra_rdoc_files: []
192
192
  files:
193
+ - ".github/workflows/ruby.yml"
193
194
  - ".gitignore"
194
195
  - ".rspec"
195
196
  - ".rubocop.yml"
@@ -524,9 +525,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
524
525
  version: '2.4'
525
526
  required_rubygems_version: !ruby/object:Gem::Requirement
526
527
  requirements:
527
- - - ">"
528
+ - - ">="
528
529
  - !ruby/object:Gem::Version
529
- version: 1.3.1
530
+ version: '0'
530
531
  requirements: []
531
532
  rubygems_version: 3.1.4
532
533
  signing_key: