Configurable outcomes service protocol
refs OUT-3591 flag=none test plan: - qa-cr Change-Id: I3d21717cc8dcae686989c66b9a39ab7e45426354 Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/234728 Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com> Reviewed-by: Michael Brewer-Davis <mbd@instructure.com> Reviewed-by: Pat Renner <prenner@instructure.com> QA-Review: Brian Watson <bwatson@instructure.com> Product-Review: Augusto Callejas <acallejas@instructure.com>
This commit is contained in:
parent
b59e56d444
commit
2eaa09b3ba
|
@ -22,7 +22,7 @@ module CanvasOutcomesHelper
|
|||
domain, jwt = extract_domain_jwt(context.root_account, 'outcome_alignment_sets.create')
|
||||
return if domain.nil? || jwt.nil?
|
||||
|
||||
_, protocol = get_host_and_protocol_from_request()
|
||||
protocol = ENV.fetch('OUTCOMES_SERVICE_PROTOCOL', Rails.env.production? ? 'https' : 'http')
|
||||
host_url = "#{protocol}://#{domain}" if domain.present?
|
||||
|
||||
js_env(
|
||||
|
|
|
@ -34,25 +34,47 @@ describe CanvasOutcomesHelper do
|
|||
end
|
||||
|
||||
describe '#set_outcomes_alignment_js_env' do
|
||||
let(:wiki_page) { create_page title: "title text", body: "body text" }
|
||||
|
||||
it 'raises error on invalid artifact type' do
|
||||
expect { subject.set_outcomes_alignment_js_env(account, account, {}) }.to raise_error('Unsupported artifact type: Account')
|
||||
end
|
||||
|
||||
it 'sets js_env values' do
|
||||
wiki_page = create_page title: "title text", body: "body text"
|
||||
expect(subject).to receive(:extract_domain_jwt).and_return ['domain', 'jwt']
|
||||
expect(subject).to receive(:get_host_and_protocol_from_request).and_return ['host', 'https']
|
||||
expect(subject).to receive(:js_env).with({
|
||||
canvas_outcomes: {
|
||||
artifact_type: 'canvas.page',
|
||||
artifact_id: wiki_page.id,
|
||||
context_uuid: account.uuid,
|
||||
host: 'https://domain',
|
||||
jwt: 'jwt',
|
||||
extra_key: 'extra_value'
|
||||
}
|
||||
})
|
||||
subject.set_outcomes_alignment_js_env(wiki_page, account, extra_key: 'extra_value')
|
||||
shared_examples_for 'valid js_env settings' do
|
||||
it 'sets js_env values' do
|
||||
expect(subject).to receive(:extract_domain_jwt).and_return ['domain', 'jwt']
|
||||
expect(subject).to receive(:js_env).with({
|
||||
canvas_outcomes: {
|
||||
artifact_type: 'canvas.page',
|
||||
artifact_id: wiki_page.id,
|
||||
context_uuid: account.uuid,
|
||||
host: expected_host,
|
||||
jwt: 'jwt',
|
||||
extra_key: 'extra_value'
|
||||
}
|
||||
})
|
||||
subject.set_outcomes_alignment_js_env(wiki_page, account, extra_key: 'extra_value')
|
||||
end
|
||||
end
|
||||
|
||||
context 'without overriding protocol' do
|
||||
let(:expected_host) { 'http://domain' }
|
||||
|
||||
it_behaves_like 'valid js_env settings'
|
||||
end
|
||||
|
||||
context 'overriding protocol' do
|
||||
let(:expected_host) { 'https://domain' }
|
||||
|
||||
before do
|
||||
ENV['OUTCOMES_SERVICE_PROTOCOL'] = 'https'
|
||||
end
|
||||
|
||||
after do
|
||||
ENV.delete('OUTCOMES_SERVICE_PROTOCOL')
|
||||
end
|
||||
|
||||
it_behaves_like 'valid js_env settings'
|
||||
end
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in New Issue