sequencescape-client-api 0.5.0 → 0.6.0.pre.rc1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/ruby.yml +39 -0
- data/.gitignore +1 -0
- data/README.markdown +10 -7
- 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/sequencescape-api.gemspec +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 +11 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 44f010fb9ed69aae5a2db7f07ae354c9c122ad86fb5d96c0a731cd0db7a7188e
|
4
|
+
data.tar.gz: 3d4ddf33e18bcceb7c04634b2c7c753a47ab91ad3ae8280b75c9f7e47f5497e5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3ac41fe200d33af7324ccd449f35c755b036adc44f101c3a60729d515de2882a948d511771755c20b85e20908b9661f6a7b9469c7b90fdf2b98c3ce7ce47b78e
|
7
|
+
data.tar.gz: 96d7dbd068dfbf42cc9425330c146f1d6a24abf7c5da19306b8d3ebaace8f0e3ca933f2037826f6a335390a0bcf05e8e598ca7993e0b49fcb597d6c006ed372c
|
@@ -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
|
+
```
|
@@ -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
|
data/sequencescape-api.gemspec
CHANGED
@@ -29,7 +29,7 @@ Gem::Specification.new do |s|
|
|
29
29
|
POST_INSTALL
|
30
30
|
|
31
31
|
s.add_dependency('activemodel', '>= 5.0.0')
|
32
|
-
s.add_dependency('activesupport', '>= 5.0.0')
|
32
|
+
s.add_dependency('activesupport', '>= 5.0.0', '< 6.1.0')
|
33
33
|
s.add_dependency('i18n')
|
34
34
|
s.add_dependency('multi_json')
|
35
35
|
|
@@ -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.pre.rc1
|
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
|
@@ -33,6 +33,9 @@ dependencies:
|
|
33
33
|
- - ">="
|
34
34
|
- !ruby/object:Gem::Version
|
35
35
|
version: 5.0.0
|
36
|
+
- - "<"
|
37
|
+
- !ruby/object:Gem::Version
|
38
|
+
version: 6.1.0
|
36
39
|
type: :runtime
|
37
40
|
prerelease: false
|
38
41
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -40,6 +43,9 @@ dependencies:
|
|
40
43
|
- - ">="
|
41
44
|
- !ruby/object:Gem::Version
|
42
45
|
version: 5.0.0
|
46
|
+
- - "<"
|
47
|
+
- !ruby/object:Gem::Version
|
48
|
+
version: 6.1.0
|
43
49
|
- !ruby/object:Gem::Dependency
|
44
50
|
name: i18n
|
45
51
|
requirement: !ruby/object:Gem::Requirement
|
@@ -190,6 +196,7 @@ executables: []
|
|
190
196
|
extensions: []
|
191
197
|
extra_rdoc_files: []
|
192
198
|
files:
|
199
|
+
- ".github/workflows/ruby.yml"
|
193
200
|
- ".gitignore"
|
194
201
|
- ".rspec"
|
195
202
|
- ".rubocop.yml"
|
@@ -524,9 +531,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
524
531
|
version: '2.4'
|
525
532
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
526
533
|
requirements:
|
527
|
-
- - "
|
534
|
+
- - ">"
|
528
535
|
- !ruby/object:Gem::Version
|
529
|
-
version:
|
536
|
+
version: 1.3.1
|
530
537
|
requirements: []
|
531
538
|
rubygems_version: 3.1.4
|
532
539
|
signing_key:
|