quiz_api_client 4.2.1 → 4.5.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/README.md +0 -48
- data/Rakefile +0 -29
- data/lib/quiz_api_client/services/courses_service.rb +37 -0
- data/lib/quiz_api_client/services/quiz_clone_jobs_service.rb +11 -0
- data/lib/quiz_api_client/services/quiz_sync_job_service.rb +17 -0
- data/lib/quiz_api_client/services/quiz_sync_jobs_service.rb +16 -0
- data/lib/quiz_api_client/version.rb +1 -1
- data/lib/quiz_api_client.rb +15 -0
- data/spec/quiz_api_client_spec.rb +7 -0
- data/spec/services/courses_service_spec.rb +98 -0
- data/spec/services/quiz_clone_jobs_service_spec.rb +36 -0
- data/spec/services/quiz_sync_job_service_spec.rb +41 -0
- data/spec/services/quiz_sync_jobs_service_spec.rb +77 -0
- data/spec/spec_helper.rb +1 -25
- metadata +11 -76
- data/spec/contracts/interaction_types_service_spec.rb +0 -22
- data/spec/contracts/item_analyses_service_spec.rb +0 -59
- data/spec/contracts/items_service_spec.rb +0 -59
- data/spec/contracts/qti_imports_service_spec.rb +0 -34
- data/spec/contracts/quiz_clone_job_service_spec.rb +0 -20
- data/spec/contracts/quiz_clone_jobs_service_spec.rb +0 -21
- data/spec/contracts/quiz_entries_service_spec.rb +0 -125
- data/spec/contracts/quiz_service_spec.rb +0 -68
- data/spec/contracts/quiz_session_events_service_spec.rb +0 -30
- data/spec/contracts/quiz_session_result_service_spec.rb +0 -42
- data/spec/contracts/quiz_session_service_spec.rb +0 -56
- data/spec/contracts/quiz_sessions_service_spec.rb +0 -28
- data/spec/contracts/quizzes_service_spec.rb +0 -80
- data/spec/contracts/session_item_results_service_spec.rb +0 -60
- data/spec/contracts/session_items_service_spec.rb +0 -21
- data/spec/contracts/shared_banks_spec.rb +0 -366
- data/spec/contracts/shared_examples/http_delete_example.rb +0 -56
- data/spec/contracts/shared_examples/http_get_example.rb +0 -139
- data/spec/contracts/shared_examples/http_patch_example.rb +0 -60
- data/spec/contracts/shared_examples/http_post_example.rb +0 -60
- data/spec/contracts/shared_examples/http_put_example.rb +0 -60
- data/spec/support/pact_config.rb +0 -64
- data/spec/support/pact_helper.rb +0 -19
@@ -1,139 +0,0 @@
|
|
1
|
-
shared_context 'http get' do
|
2
|
-
let(:quizzes_api_path) { raise 'Override in spec' }
|
3
|
-
let(:consumer_key) { 'consumer key' }
|
4
|
-
let(:consumer_request_id) { 'consumer request id' }
|
5
|
-
let(:host) { 'localhost:1234' }
|
6
|
-
let(:shared_secret) { 'secret' }
|
7
|
-
let(:scope) { raise 'Override in spec' }
|
8
|
-
let(:resource_id) { nil }
|
9
|
-
let(:response_headers) { { 'Content-Type' => 'application/json; charset=utf-8' } }
|
10
|
-
let(:response_body) { raise 'Override in spec' }
|
11
|
-
let(:service_name) { raise 'Override in spec' }
|
12
|
-
let(:status) { 200 }
|
13
|
-
let(:provider_state) { raise 'Override in spec' }
|
14
|
-
let(:user) { nil }
|
15
|
-
let(:params) { raise 'Override in spec' }
|
16
|
-
let(:query_params) { {} }
|
17
|
-
let(:request_description) { raise 'Override in spec (must be unique!)' }
|
18
|
-
|
19
|
-
let(:client) do
|
20
|
-
QuizApiClient::Client.new(
|
21
|
-
consumer_key: consumer_key,
|
22
|
-
consumer_request_id: consumer_request_id,
|
23
|
-
host: host,
|
24
|
-
shared_secret: shared_secret,
|
25
|
-
protocol: 'http'
|
26
|
-
)
|
27
|
-
end
|
28
|
-
end
|
29
|
-
|
30
|
-
shared_examples 'a http get request to quiz_api' do
|
31
|
-
include_context 'http get'
|
32
|
-
|
33
|
-
context 'retrieving a single resource' do
|
34
|
-
let(:token) do
|
35
|
-
client.jwt_service.grant_permission(
|
36
|
-
exp: token_expiration_one_year,
|
37
|
-
scope: scope,
|
38
|
-
uuid: user,
|
39
|
-
resource_id: resource_id
|
40
|
-
)
|
41
|
-
end
|
42
|
-
|
43
|
-
before do
|
44
|
-
quiz_api
|
45
|
-
.given(provider_state)
|
46
|
-
.upon_receiving(request_description)
|
47
|
-
.with(
|
48
|
-
method: :get,
|
49
|
-
path: quizzes_api_path,
|
50
|
-
headers: headers(token),
|
51
|
-
query: query_params
|
52
|
-
)
|
53
|
-
.will_respond_with(
|
54
|
-
status: status,
|
55
|
-
headers: response_headers,
|
56
|
-
body: response_body
|
57
|
-
)
|
58
|
-
end
|
59
|
-
|
60
|
-
it 'verifies the request is valid' do
|
61
|
-
result = client.send(service_name).show(token: token, params: params)
|
62
|
-
expect(result).to be_truthy
|
63
|
-
end
|
64
|
-
end
|
65
|
-
end
|
66
|
-
|
67
|
-
shared_examples 'a http get request to quiz_api collection endpoint' do
|
68
|
-
include_context 'http get'
|
69
|
-
|
70
|
-
context 'retrieving a list of resources' do
|
71
|
-
let(:token) do
|
72
|
-
client.jwt_service.grant_permission(
|
73
|
-
exp: token_expiration_one_year,
|
74
|
-
scope: scope,
|
75
|
-
uuid: user,
|
76
|
-
resource_id: resource_id
|
77
|
-
)
|
78
|
-
end
|
79
|
-
|
80
|
-
before do
|
81
|
-
quiz_api
|
82
|
-
.given(provider_state)
|
83
|
-
.upon_receiving(request_description)
|
84
|
-
.with(
|
85
|
-
method: :get,
|
86
|
-
path: quizzes_api_path,
|
87
|
-
headers: headers(token),
|
88
|
-
query: query_params
|
89
|
-
)
|
90
|
-
.will_respond_with(
|
91
|
-
status: status,
|
92
|
-
headers: response_headers,
|
93
|
-
body: response_body
|
94
|
-
)
|
95
|
-
end
|
96
|
-
|
97
|
-
it 'verifies the request is valid' do
|
98
|
-
result = client.send(service_name).list(token: token, params: params)
|
99
|
-
expect(result).to be_truthy
|
100
|
-
end
|
101
|
-
end
|
102
|
-
end
|
103
|
-
|
104
|
-
shared_examples 'a http get only request to quiz_api' do
|
105
|
-
include_context 'http get'
|
106
|
-
|
107
|
-
context 'retrieving a single resource' do
|
108
|
-
let(:token) do
|
109
|
-
client.jwt_service.grant_permission(
|
110
|
-
exp: token_expiration_one_year,
|
111
|
-
scope: scope,
|
112
|
-
uuid: user,
|
113
|
-
resource_id: resource_id
|
114
|
-
)
|
115
|
-
end
|
116
|
-
|
117
|
-
before do
|
118
|
-
quiz_api
|
119
|
-
.given(provider_state)
|
120
|
-
.upon_receiving(request_description)
|
121
|
-
.with(
|
122
|
-
method: :get,
|
123
|
-
path: quizzes_api_path,
|
124
|
-
headers: headers(token),
|
125
|
-
query: query_params
|
126
|
-
)
|
127
|
-
.will_respond_with(
|
128
|
-
status: status,
|
129
|
-
headers: response_headers,
|
130
|
-
body: response_body
|
131
|
-
)
|
132
|
-
end
|
133
|
-
|
134
|
-
it 'verifies the request is valid' do
|
135
|
-
result = client.send(service_name).get(token: token, params: params)
|
136
|
-
expect(result).to be_truthy
|
137
|
-
end
|
138
|
-
end
|
139
|
-
end
|
@@ -1,60 +0,0 @@
|
|
1
|
-
shared_examples 'a http patch request to quiz_api' do
|
2
|
-
let(:quizzes_api_path) { raise 'Override in spec' }
|
3
|
-
let(:consumer_key) { 'consumer key' }
|
4
|
-
let(:consumer_request_id) { 'consumer request id' }
|
5
|
-
let(:host) { 'localhost:1234' }
|
6
|
-
let(:shared_secret) { 'secret' }
|
7
|
-
let(:scope) { raise 'Override in spec' }
|
8
|
-
let(:user) { nil }
|
9
|
-
let(:resource_id) { nil }
|
10
|
-
let(:response_body) { raise 'Override in spec' }
|
11
|
-
let(:service_name) { raise 'Override in spec' }
|
12
|
-
let(:status) { 200 }
|
13
|
-
let(:provider_state) { raise 'Override in spec' }
|
14
|
-
let(:params) { raise 'Override in spec' }
|
15
|
-
let(:body) { raise 'Override in spec' }
|
16
|
-
let(:request_description) { raise 'Override in spec (must be unique!)' }
|
17
|
-
|
18
|
-
let(:client) do
|
19
|
-
QuizApiClient::Client.new(
|
20
|
-
consumer_key: consumer_key,
|
21
|
-
consumer_request_id: consumer_request_id,
|
22
|
-
host: host,
|
23
|
-
shared_secret: shared_secret,
|
24
|
-
protocol: 'http'
|
25
|
-
)
|
26
|
-
end
|
27
|
-
|
28
|
-
context 'updating a resource' do
|
29
|
-
let(:token) do
|
30
|
-
client.jwt_service.grant_permission(
|
31
|
-
exp: token_expiration_one_year,
|
32
|
-
scope: scope,
|
33
|
-
uuid: user,
|
34
|
-
resource_id: resource_id
|
35
|
-
)
|
36
|
-
end
|
37
|
-
|
38
|
-
before do
|
39
|
-
quiz_api
|
40
|
-
.given(provider_state)
|
41
|
-
.upon_receiving(request_description)
|
42
|
-
.with(
|
43
|
-
method: :patch,
|
44
|
-
path: quizzes_api_path,
|
45
|
-
headers: headers(token),
|
46
|
-
body: body
|
47
|
-
)
|
48
|
-
.will_respond_with(
|
49
|
-
status: status,
|
50
|
-
headers: { 'Content-Type' => 'application/json; charset=utf-8' },
|
51
|
-
body: response_body
|
52
|
-
)
|
53
|
-
end
|
54
|
-
|
55
|
-
it 'verifies the request is valid' do
|
56
|
-
result = client.send(service_name).update(token: token, params: params)
|
57
|
-
expect(result).to be_truthy
|
58
|
-
end
|
59
|
-
end
|
60
|
-
end
|
@@ -1,60 +0,0 @@
|
|
1
|
-
shared_examples 'a http post request to quiz_api' do
|
2
|
-
let(:quizzes_api_path) { raise 'Override in spec' }
|
3
|
-
let(:consumer_key) { 'consumer key' }
|
4
|
-
let(:consumer_request_id) { 'consumer request id' }
|
5
|
-
let(:host) { 'localhost:1234' }
|
6
|
-
let(:shared_secret) { 'secret' }
|
7
|
-
let(:scope) { raise 'Override in spec' }
|
8
|
-
let(:user) { nil }
|
9
|
-
let(:resource_id) { nil }
|
10
|
-
let(:response_body) { raise 'Override in spec' }
|
11
|
-
let(:service_name) { raise 'Override in spec' }
|
12
|
-
let(:status) { 201 }
|
13
|
-
let(:provider_state) { raise 'Override in spec' }
|
14
|
-
let(:params) { raise 'Override in spec' }
|
15
|
-
let(:body) { raise 'Override in spec' }
|
16
|
-
let(:request_description) { raise 'Override in spec (must be unique!)' }
|
17
|
-
|
18
|
-
let(:client) do
|
19
|
-
QuizApiClient::Client.new(
|
20
|
-
consumer_key: consumer_key,
|
21
|
-
consumer_request_id: consumer_request_id,
|
22
|
-
host: host,
|
23
|
-
shared_secret: shared_secret,
|
24
|
-
protocol: 'http'
|
25
|
-
)
|
26
|
-
end
|
27
|
-
|
28
|
-
context 'creating a new resource' do
|
29
|
-
let(:token) do
|
30
|
-
client.jwt_service.grant_permission(
|
31
|
-
exp: token_expiration_one_year,
|
32
|
-
scope: scope,
|
33
|
-
uuid: user,
|
34
|
-
resource_id: resource_id
|
35
|
-
)
|
36
|
-
end
|
37
|
-
|
38
|
-
before do
|
39
|
-
quiz_api
|
40
|
-
.given(provider_state)
|
41
|
-
.upon_receiving(request_description)
|
42
|
-
.with(
|
43
|
-
method: :post,
|
44
|
-
path: quizzes_api_path,
|
45
|
-
headers: headers(token),
|
46
|
-
body: body
|
47
|
-
)
|
48
|
-
.will_respond_with(
|
49
|
-
status: status,
|
50
|
-
headers: { 'Content-Type' => 'application/json; charset=utf-8' },
|
51
|
-
body: response_body
|
52
|
-
)
|
53
|
-
end
|
54
|
-
|
55
|
-
it 'verifies the request is valid' do
|
56
|
-
result = client.send(service_name).create(token: token, params: params)
|
57
|
-
expect(result).to be_truthy
|
58
|
-
end
|
59
|
-
end
|
60
|
-
end
|
@@ -1,60 +0,0 @@
|
|
1
|
-
shared_examples 'a http put request to quiz_api' do
|
2
|
-
let(:quizzes_api_path) { raise 'Override in spec' }
|
3
|
-
let(:consumer_key) { 'consumer key' }
|
4
|
-
let(:consumer_request_id) { 'consumer request id' }
|
5
|
-
let(:host) { 'localhost:1234' }
|
6
|
-
let(:shared_secret) { 'secret' }
|
7
|
-
let(:scope) { raise 'Override in spec' }
|
8
|
-
let(:resource_id) { nil }
|
9
|
-
let(:response_body) { raise 'Override in spec' }
|
10
|
-
let(:service_name) { raise 'Override in spec' }
|
11
|
-
let(:status) { 200 }
|
12
|
-
let(:provider_state) { raise 'Override in spec' }
|
13
|
-
let(:user) { nil }
|
14
|
-
let(:params) { raise 'Override in spec' }
|
15
|
-
let(:body) { raise 'Override in spec' }
|
16
|
-
let(:request_description) { raise 'Override in spec (must be unique!)' }
|
17
|
-
|
18
|
-
let(:client) do
|
19
|
-
QuizApiClient::Client.new(
|
20
|
-
consumer_key: consumer_key,
|
21
|
-
consumer_request_id: consumer_request_id,
|
22
|
-
host: host,
|
23
|
-
shared_secret: shared_secret,
|
24
|
-
protocol: 'http'
|
25
|
-
)
|
26
|
-
end
|
27
|
-
|
28
|
-
context 'updating a resource' do
|
29
|
-
let(:token) do
|
30
|
-
client.jwt_service.grant_permission(
|
31
|
-
exp: token_expiration_one_year,
|
32
|
-
scope: scope,
|
33
|
-
uuid: user,
|
34
|
-
resource_id: resource_id
|
35
|
-
)
|
36
|
-
end
|
37
|
-
|
38
|
-
before do
|
39
|
-
quiz_api
|
40
|
-
.given(provider_state)
|
41
|
-
.upon_receiving(request_description)
|
42
|
-
.with(
|
43
|
-
method: :put,
|
44
|
-
path: quizzes_api_path,
|
45
|
-
headers: headers(token),
|
46
|
-
body: body
|
47
|
-
)
|
48
|
-
.will_respond_with(
|
49
|
-
status: status,
|
50
|
-
headers: { 'Content-Type' => 'application/json; charset=utf-8' },
|
51
|
-
body: response_body
|
52
|
-
)
|
53
|
-
end
|
54
|
-
|
55
|
-
it 'verifies the request is valid' do
|
56
|
-
result = client.send(service_name).update(token: token, params: params)
|
57
|
-
expect(result).to be_truthy
|
58
|
-
end
|
59
|
-
end
|
60
|
-
end
|
data/spec/support/pact_config.rb
DELETED
@@ -1,64 +0,0 @@
|
|
1
|
-
module PactConfig
|
2
|
-
# These constants ensure we use the correct strings and thus help avoid our
|
3
|
-
# accidentally breaking the contract tests
|
4
|
-
QUIZ_API_CLIENT_RUBY = 'Quiz API Client Ruby'.freeze
|
5
|
-
|
6
|
-
# Add new API and LiveEvents providers to this Providers module
|
7
|
-
module Providers
|
8
|
-
QUIZ_API = 'Quiz API'.freeze
|
9
|
-
ALL = Providers.constants.map { |c| Providers.const_get(c) }.freeze
|
10
|
-
end
|
11
|
-
|
12
|
-
class << self
|
13
|
-
def pact_uri(pact_path:)
|
14
|
-
URI::HTTP.build(
|
15
|
-
scheme: protocol,
|
16
|
-
userinfo: "#{broker_username}:#{broker_password}",
|
17
|
-
host: broker_host,
|
18
|
-
path: "/#{pact_path}/#{consumer_tag}"
|
19
|
-
).to_s
|
20
|
-
end
|
21
|
-
|
22
|
-
def broker_uri
|
23
|
-
URI::HTTP.build(
|
24
|
-
scheme: protocol,
|
25
|
-
userinfo: "#{broker_username}:#{broker_password}",
|
26
|
-
host: broker_host
|
27
|
-
).to_s
|
28
|
-
end
|
29
|
-
|
30
|
-
def broker_host
|
31
|
-
ENV.fetch('PACT_BROKER_HOST', 'pact-broker.docker')
|
32
|
-
end
|
33
|
-
|
34
|
-
def consumer_tag
|
35
|
-
ENV.fetch('PACT_CONSUMER_TAG', 'local')
|
36
|
-
end
|
37
|
-
|
38
|
-
def consumer_version
|
39
|
-
version = QuizApiClient::VERSION
|
40
|
-
sha = ENV['SHA']
|
41
|
-
version = "#{version}+#{sha}" if sha
|
42
|
-
version
|
43
|
-
end
|
44
|
-
|
45
|
-
def broker_password
|
46
|
-
ENV.fetch('PACT_BROKER_PASSWORD', 'broker')
|
47
|
-
end
|
48
|
-
|
49
|
-
def broker_username
|
50
|
-
ENV.fetch('PACT_BROKER_USERNAME', 'pact')
|
51
|
-
end
|
52
|
-
|
53
|
-
private
|
54
|
-
|
55
|
-
def jenkins_build?
|
56
|
-
!ENV['JENKINS_URL'].nil?
|
57
|
-
end
|
58
|
-
|
59
|
-
def protocol
|
60
|
-
protocol = jenkins_build? ? 'https' : 'http'
|
61
|
-
ENV.fetch('PACT_BROKER_PROTOCOL', protocol)
|
62
|
-
end
|
63
|
-
end
|
64
|
-
end
|
data/spec/support/pact_helper.rb
DELETED
@@ -1,19 +0,0 @@
|
|
1
|
-
module PactHelper
|
2
|
-
def token_expiration_one_year
|
3
|
-
token_expiration_seconds_from_now(seconds: 31_536_000)
|
4
|
-
end
|
5
|
-
|
6
|
-
def token_expiration_seconds_from_now(seconds:)
|
7
|
-
Time.now.utc.to_i + seconds
|
8
|
-
end
|
9
|
-
|
10
|
-
def headers(token)
|
11
|
-
{
|
12
|
-
'Content-Type' => 'application/json',
|
13
|
-
'AuthType' => 'Signature',
|
14
|
-
'Accept' => 'application/json',
|
15
|
-
'Authorization' => token.to_s,
|
16
|
-
'HOST' => 'localhost:1234'
|
17
|
-
}
|
18
|
-
end
|
19
|
-
end
|