liblynx-api 1.0.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 +7 -0
- data/Gemfile +3 -0
- data/Gemfile.lock +53 -0
- data/LICENSE +21 -0
- data/README.md +33 -0
- data/Rakefile +35 -0
- data/api.md +713 -0
- data/config.json +7 -0
- data/config/config.rb +13 -0
- data/lib/liblynx-api.rb +22 -0
- data/lib/liblynx-api/client.rb +1153 -0
- data/lib/liblynx-api/version.rb +5 -0
- data/liblynx-api.gemspec +27 -0
- data/meta.json +11 -0
- data/schema.json +905 -0
- data/schemata/account.json +429 -0
- data/schemata/identification.json +239 -0
- data/schemata/samlidps.json +140 -0
- data/schemata/token.json +68 -0
- data/spec/client_spec.rb +110 -0
- metadata +162 -0
@@ -0,0 +1,140 @@
|
|
1
|
+
{
|
2
|
+
"$schema": "http://json-schema.org/draft-04/hyper-schema",
|
3
|
+
"title": "Samlidp",
|
4
|
+
"description": "",
|
5
|
+
"stability": "production",
|
6
|
+
"strictProperties": true,
|
7
|
+
"type": [
|
8
|
+
"object"
|
9
|
+
],
|
10
|
+
"definitions": {
|
11
|
+
"id": {
|
12
|
+
"description": "unique identifier of samlidp",
|
13
|
+
"readOnly": true,
|
14
|
+
"type": [
|
15
|
+
"integer"
|
16
|
+
]
|
17
|
+
},
|
18
|
+
"descriptor_url": {
|
19
|
+
"description": "saml descriptor url",
|
20
|
+
"readOnly": true,
|
21
|
+
"type": [
|
22
|
+
"string"
|
23
|
+
]
|
24
|
+
},
|
25
|
+
"xml_descriptor": {
|
26
|
+
"description": "xml descriptor",
|
27
|
+
"readOnly": true,
|
28
|
+
"type": [
|
29
|
+
"string"
|
30
|
+
]
|
31
|
+
},
|
32
|
+
"type": {
|
33
|
+
"description": "type",
|
34
|
+
"readOnly": true,
|
35
|
+
"type": [
|
36
|
+
"string"
|
37
|
+
]
|
38
|
+
},
|
39
|
+
"entity_id": {
|
40
|
+
"description": "entity_id",
|
41
|
+
"readOnly": true,
|
42
|
+
"type": [
|
43
|
+
"string"
|
44
|
+
]
|
45
|
+
},
|
46
|
+
"identity": {
|
47
|
+
"$ref": "/schemata/samlidp#/definitions/id"
|
48
|
+
}
|
49
|
+
},
|
50
|
+
"links": [
|
51
|
+
{
|
52
|
+
"description": "Create a new samlidp.",
|
53
|
+
"href": "/api/accounts/{(%2Fschemata%2Faccount%23%2Fdefinitions%2Fidentity)}/samlidps",
|
54
|
+
"method": "POST",
|
55
|
+
"rel": "create",
|
56
|
+
"schema": {
|
57
|
+
"properties": {
|
58
|
+
"descriptor_url": {
|
59
|
+
"$ref": "/schemata/samlidp#/definitions/descriptor_url"
|
60
|
+
}
|
61
|
+
},
|
62
|
+
"required": [
|
63
|
+
"descriptor_url"
|
64
|
+
],
|
65
|
+
"type": [
|
66
|
+
"object"
|
67
|
+
]
|
68
|
+
},
|
69
|
+
"title": "Create"
|
70
|
+
},
|
71
|
+
{
|
72
|
+
"description": "Delete an existing samlidp.",
|
73
|
+
"href": "/api/accounts/{(%2Fschemata%2Faccount%23%2Fdefinitions%2Fidentity)}/samlidps/{(%2Fschemata%2Fsamlidp%23%2Fdefinitions%2Fidentity)}",
|
74
|
+
"method": "DELETE",
|
75
|
+
"rel": "destroy",
|
76
|
+
"title": "Delete",
|
77
|
+
"targetSchema": {}
|
78
|
+
},
|
79
|
+
{
|
80
|
+
"description": "Info for existing samlidp.",
|
81
|
+
"href": "/api/accounts/{(%2Fschemata%2Faccount%23%2Fdefinitions%2Fidentity)}/samlidps/{(%2Fschemata%2Fsamlidp%23%2Fdefinitions%2Fidentity)}",
|
82
|
+
"method": "GET",
|
83
|
+
"rel": "self",
|
84
|
+
"title": "Info"
|
85
|
+
},
|
86
|
+
{
|
87
|
+
"description": "List existing samlidps.",
|
88
|
+
"href": "/api/accounts/{(%2Fschemata%2Faccount%23%2Fdefinitions%2Fidentity)}/samlidps",
|
89
|
+
"method": "GET",
|
90
|
+
"rel": "instances",
|
91
|
+
"title": "List",
|
92
|
+
"targetSchema": {
|
93
|
+
"properties": {
|
94
|
+
"samlidps": {
|
95
|
+
"items": {
|
96
|
+
"properties": {
|
97
|
+
"id": {
|
98
|
+
"$ref": "/schemata/samlidp#/definitions/id"
|
99
|
+
},
|
100
|
+
"descriptor_url": {
|
101
|
+
"$ref": "/schemata/samlidp#/definitions/descriptor_url"
|
102
|
+
},
|
103
|
+
"xml_descriptor": {
|
104
|
+
"$ref": "/schemata/samlidp#/definitions/xml_descriptor"
|
105
|
+
},
|
106
|
+
"type": {
|
107
|
+
"$ref": "/schemata/samlidp#/definitions/type"
|
108
|
+
},
|
109
|
+
"entity_id": {
|
110
|
+
"$ref": "/schemata/samlidp#/definitions/entity_id"
|
111
|
+
}
|
112
|
+
}
|
113
|
+
},
|
114
|
+
"type": [
|
115
|
+
"array"
|
116
|
+
]
|
117
|
+
}
|
118
|
+
}
|
119
|
+
}
|
120
|
+
}
|
121
|
+
],
|
122
|
+
"properties": {
|
123
|
+
"id": {
|
124
|
+
"$ref": "/schemata/samlidp#/definitions/id"
|
125
|
+
},
|
126
|
+
"descriptor_url": {
|
127
|
+
"$ref": "/schemata/samlidp#/definitions/descriptor_url"
|
128
|
+
},
|
129
|
+
"xml_descriptor": {
|
130
|
+
"$ref": "/schemata/samlidp#/definitions/xml_descriptor"
|
131
|
+
},
|
132
|
+
"type": {
|
133
|
+
"$ref": "/schemata/samlidp#/definitions/type"
|
134
|
+
},
|
135
|
+
"entity_id": {
|
136
|
+
"$ref": "/schemata/samlidp#/definitions/entity_id"
|
137
|
+
}
|
138
|
+
},
|
139
|
+
"id": "schemata/samlidp"
|
140
|
+
}
|
data/schemata/token.json
ADDED
@@ -0,0 +1,68 @@
|
|
1
|
+
{
|
2
|
+
"$schema": "http://json-schema.org/draft-04/hyper-schema",
|
3
|
+
"title": "OAuth2 token",
|
4
|
+
"description": "",
|
5
|
+
"stability": "production",
|
6
|
+
"strictProperties": true,
|
7
|
+
"type": [
|
8
|
+
"object"
|
9
|
+
],
|
10
|
+
"definitions": {
|
11
|
+
"account_token": {
|
12
|
+
"description": "unique identifier of identification",
|
13
|
+
"readOnly": true,
|
14
|
+
"type": [
|
15
|
+
"string"
|
16
|
+
]
|
17
|
+
},
|
18
|
+
"identity": {
|
19
|
+
"$ref": "/schemata/token#/definitions/account_token"
|
20
|
+
},
|
21
|
+
"grant_type": {
|
22
|
+
"description": "grant_type",
|
23
|
+
"example": "client_credentials",
|
24
|
+
"type": [
|
25
|
+
"string"
|
26
|
+
]
|
27
|
+
}
|
28
|
+
},
|
29
|
+
"links": [
|
30
|
+
{
|
31
|
+
"description": "Create a new oauth2 token",
|
32
|
+
"encType": "application/x-www-form-urlencoded",
|
33
|
+
"href": "/oauth/v2/token",
|
34
|
+
"method": "POST",
|
35
|
+
"rel": "create",
|
36
|
+
"schema": {
|
37
|
+
"properties": {
|
38
|
+
"grant_type": {
|
39
|
+
"$ref": "/schemata/token#/definitions/grant_type"
|
40
|
+
}
|
41
|
+
},
|
42
|
+
"required": [
|
43
|
+
"grant_type"
|
44
|
+
],
|
45
|
+
"type": [
|
46
|
+
"object"
|
47
|
+
]
|
48
|
+
},
|
49
|
+
"targetSchema": {
|
50
|
+
"properties": {
|
51
|
+
"account_token": {
|
52
|
+
"$ref": "/schemata/token#/definitions/account_token"
|
53
|
+
}
|
54
|
+
},
|
55
|
+
"type": [
|
56
|
+
"object"
|
57
|
+
]
|
58
|
+
},
|
59
|
+
"title": "Create"
|
60
|
+
}
|
61
|
+
],
|
62
|
+
"properties": {
|
63
|
+
"account_token": {
|
64
|
+
"$ref": "/schemata/token#/definitions/account_token"
|
65
|
+
}
|
66
|
+
},
|
67
|
+
"id": "schemata/token"
|
68
|
+
}
|
data/spec/client_spec.rb
ADDED
@@ -0,0 +1,110 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'securerandom'
|
4
|
+
require 'liblynx-api'
|
5
|
+
|
6
|
+
describe 'The generated liblynx api client' do
|
7
|
+
before(:all) do
|
8
|
+
@client = LibLynxAPI.connect_oauth2(ENV['CLIENT_ID'], ENV['CLIENT_SECRET'])
|
9
|
+
@test_domain = 'somedomain.com'
|
10
|
+
@test_descriptor_url = 'http://bit.ly/2E5Srk5'
|
11
|
+
@test_shib_entity = 'https://test-idp.ukfederation.org.uk/idp/shibboleth'
|
12
|
+
@test_account_config = {
|
13
|
+
'account_name' => SecureRandom.uuid,
|
14
|
+
'publisher_reference' => SecureRandom.random_number(1_000_000).to_s,
|
15
|
+
'email_domains' => "subdomain.#{@test_domain}\n#{@test_domain}"
|
16
|
+
}
|
17
|
+
@id_config = {
|
18
|
+
user_agent: 'Some agent',
|
19
|
+
ip: '127.0.0.1',
|
20
|
+
url: "http://#{@test_domain}",
|
21
|
+
email: "test@#{@test_domain}"
|
22
|
+
}
|
23
|
+
end
|
24
|
+
|
25
|
+
it 'can get list the accounts' do
|
26
|
+
expect(@client.account.list).to match(hash_including('accounts'))
|
27
|
+
end
|
28
|
+
|
29
|
+
context 'saml account' do
|
30
|
+
before(:context) do
|
31
|
+
@config = @test_account_config.merge('enable_saml' => true)
|
32
|
+
@account = @client.account.create(@config)
|
33
|
+
end
|
34
|
+
|
35
|
+
it 'can create a new account' do
|
36
|
+
expect(@account).to match(hash_including(@config))
|
37
|
+
end
|
38
|
+
|
39
|
+
it 'can update an account' do
|
40
|
+
expect(@client.account.update(@account['id'], @config))
|
41
|
+
.to match(hash_including(@config))
|
42
|
+
end
|
43
|
+
|
44
|
+
it 'can add saml idp descriptor url to an account' do
|
45
|
+
expect { @client.samlidp.create(@account['id'], descriptor_url: @test_descriptor_url) }
|
46
|
+
.not_to raise_error
|
47
|
+
end
|
48
|
+
|
49
|
+
it 'can list an account saml idps' do
|
50
|
+
expect(@client.samlidp.list(@account['id']))
|
51
|
+
.to match(hash_including('samlidps'))
|
52
|
+
end
|
53
|
+
|
54
|
+
context 'identification' do
|
55
|
+
before(:context) do
|
56
|
+
@identification = @client.identification.create(@id_config)
|
57
|
+
end
|
58
|
+
|
59
|
+
it 'can create new identification resource' do
|
60
|
+
expect(@identification).to match(hash_including('target_account' =>
|
61
|
+
hash_including(@config.slice('publisher_reference'))))
|
62
|
+
end
|
63
|
+
|
64
|
+
it 'can get identification resource info' do
|
65
|
+
expect(@client.identification.info(@identification['id'])).to match(@identification)
|
66
|
+
end
|
67
|
+
|
68
|
+
it 'can delete an account' do
|
69
|
+
expect { @client.account.delete(@account['id']) }.not_to raise_error
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
context 'shibboleth account' do
|
75
|
+
before(:context) do
|
76
|
+
@config = @test_account_config.merge(
|
77
|
+
'enable_shibboleth' => true,
|
78
|
+
'shibboleth_entity_id' => @test_shib_entity)
|
79
|
+
@account = @client.account.create(@config)
|
80
|
+
end
|
81
|
+
|
82
|
+
it 'can create a new account' do
|
83
|
+
expect(@account).to match(hash_including(@config))
|
84
|
+
end
|
85
|
+
|
86
|
+
it 'can update an account' do
|
87
|
+
expect(@client.account.update(@account['id'], @config))
|
88
|
+
.to match(hash_including(@config))
|
89
|
+
end
|
90
|
+
|
91
|
+
context 'identification' do
|
92
|
+
before(:context) do
|
93
|
+
@identification = @client.identification.create(@id_config)
|
94
|
+
end
|
95
|
+
|
96
|
+
it 'can create new identification resource' do
|
97
|
+
expect(@identification).to match(hash_including('target_account' =>
|
98
|
+
hash_including(@config.slice('publisher_reference'))))
|
99
|
+
end
|
100
|
+
|
101
|
+
it 'can get identification resource info' do
|
102
|
+
expect(@client.identification.info(@identification['id'])).to match(@identification)
|
103
|
+
end
|
104
|
+
|
105
|
+
it 'can delete an account' do
|
106
|
+
expect { @client.account.delete(@account['id']) }.not_to raise_error
|
107
|
+
end
|
108
|
+
end
|
109
|
+
end
|
110
|
+
end
|
metadata
ADDED
@@ -0,0 +1,162 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: liblynx-api
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Denis Sablic
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2018-02-07 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "<"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '11.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "<"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '11.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rspec
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: prmd
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: yard
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: heroics
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :runtime
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: moneta
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - ">="
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0'
|
104
|
+
type: :runtime
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - ">="
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0'
|
111
|
+
description:
|
112
|
+
email:
|
113
|
+
- denis.sablic@gmail.com
|
114
|
+
executables: []
|
115
|
+
extensions: []
|
116
|
+
extra_rdoc_files: []
|
117
|
+
files:
|
118
|
+
- Gemfile
|
119
|
+
- Gemfile.lock
|
120
|
+
- LICENSE
|
121
|
+
- README.md
|
122
|
+
- Rakefile
|
123
|
+
- api.md
|
124
|
+
- config.json
|
125
|
+
- config/config.rb
|
126
|
+
- lib/liblynx-api.rb
|
127
|
+
- lib/liblynx-api/client.rb
|
128
|
+
- lib/liblynx-api/version.rb
|
129
|
+
- liblynx-api.gemspec
|
130
|
+
- meta.json
|
131
|
+
- schema.json
|
132
|
+
- schemata/account.json
|
133
|
+
- schemata/identification.json
|
134
|
+
- schemata/samlidps.json
|
135
|
+
- schemata/token.json
|
136
|
+
- spec/client_spec.rb
|
137
|
+
homepage: https://github.com/dsablic/liblynx-api
|
138
|
+
licenses:
|
139
|
+
- MIT
|
140
|
+
metadata: {}
|
141
|
+
post_install_message:
|
142
|
+
rdoc_options: []
|
143
|
+
require_paths:
|
144
|
+
- lib
|
145
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
146
|
+
requirements:
|
147
|
+
- - ">="
|
148
|
+
- !ruby/object:Gem::Version
|
149
|
+
version: '0'
|
150
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
151
|
+
requirements:
|
152
|
+
- - ">="
|
153
|
+
- !ruby/object:Gem::Version
|
154
|
+
version: '0'
|
155
|
+
requirements: []
|
156
|
+
rubyforge_project:
|
157
|
+
rubygems_version: 2.7.3
|
158
|
+
signing_key:
|
159
|
+
specification_version: 4
|
160
|
+
summary: Ruby client for the LibLynx API
|
161
|
+
test_files:
|
162
|
+
- spec/client_spec.rb
|