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.
- checksums.yaml +4 -4
- data/.github/workflows/ruby.yml +39 -0
- data/.gitignore +1 -0
- data/README.markdown +10 -7
- data/lib/sequencescape-api.rb +1 -0
- data/lib/sequencescape-api/connection_factory.rb +5 -5
- data/lib/sequencescape-api/connection_factory/actions.rb +1 -1
- data/lib/sequencescape-api/rails.rb +5 -9
- data/lib/sequencescape-api/version.rb +1 -1
- data/spec/sequencescape-api/contracts/create-invalid-resource.txt +1 -1
- data/spec/sequencescape-api/contracts/create-model-c-has-many-inline-nested.txt +1 -1
- data/spec/sequencescape-api/contracts/create-model-c-has-many-inline.txt +1 -1
- data/spec/sequencescape-api/contracts/create-model-c-has-many.txt +1 -1
- data/spec/sequencescape-api/contracts/create-model-c.txt +1 -1
- data/spec/sequencescape-api/contracts/create-via-has-many.txt +1 -1
- data/spec/sequencescape-api/contracts/retrieve-belongs-to-association.txt +1 -1
- data/spec/sequencescape-api/contracts/retrieve-model.txt +1 -2
- data/spec/sequencescape-api/contracts/retrieve-results-page-1.txt +1 -1
- data/spec/sequencescape-api/contracts/retrieve-results-page-2.txt +1 -1
- data/spec/sequencescape-api/contracts/retrieve-results-page-3.txt +1 -1
- data/spec/sequencescape-api/contracts/retrieve-root-with-an-authorised-client.txt +1 -2
- data/spec/sequencescape-api/contracts/retrieve-root-with-an-unauthorised-client.txt +1 -2
- data/spec/sequencescape-api/contracts/retrieve-unauthorised-model-a-list.txt +1 -2
- data/spec/sequencescape-api/contracts/retrieve-unauthorised-model-b-list.txt +1 -2
- data/spec/sequencescape-api/contracts/retrieve-unauthorised-model-c-list.txt +1 -2
- data/spec/sequencescape-api/contracts/update-invalid-resource.txt +1 -1
- data/spec/sequencescape-api/contracts/update-model-c.txt +1 -1
- data/spec/sequencescape-api/root_spec.rb +2 -2
- data/spec/support/contract_helper.rb +2 -2
- metadata +5 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: '058f9686bbfcf2b51cfae0e49a76a548ed1915c7ab95e1e3c5361d7c8b32349f'
|
4
|
+
data.tar.gz: 443b45baeb30befd08490f3531ec84d80aafef4a0a852562e3a3da50598c3b56
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
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.
|
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
|
+
```
|
data/lib/sequencescape-api.rb
CHANGED
@@ -7,8 +7,8 @@ class Sequencescape::Api::ConnectionFactory
|
|
7
7
|
|
8
8
|
def self.create(options)
|
9
9
|
required_options = []
|
10
|
-
required_options.push(:
|
11
|
-
required_options.push(:url)
|
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, :
|
23
|
-
private :url, :
|
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
|
-
@
|
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' => "
|
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
|
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(
|
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
|
@@ -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/',
|
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/',
|
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/',
|
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/',
|
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.
|
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:
|
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:
|
530
|
+
version: '0'
|
530
531
|
requirements: []
|
531
532
|
rubygems_version: 3.1.4
|
532
533
|
signing_key:
|