quiz_api_client 4.4.0 → 4.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +0 -48
- data/Rakefile +0 -29
- data/lib/quiz_api_client/services/courses_service.rb +11 -0
- data/lib/quiz_api_client/version.rb +1 -1
- data/spec/services/courses_service_spec.rb +39 -0
- data/spec/spec_helper.rb +1 -25
- metadata +2 -80
- 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/quiz_sync_job_service_spec.rb +0 -21
- data/spec/contracts/quiz_sync_jobs_service_spec.rb +0 -21
- 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 -68
- 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,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
|