diff options
author | Francisco Javier López <fjlopez@gitlab.com> | 2019-04-04 21:32:02 +0300 |
---|---|---|
committer | Nick Thomas <nick@gitlab.com> | 2019-04-04 21:32:02 +0300 |
commit | 8a134f4c6505c4f8f3c89e0ae4d4ea2293765be3 (patch) | |
tree | 910dce4df7fd61af86a9f282f52fcc72ff056975 /spec | |
parent | 465f82e32cd1ca7c87ca7553e350af4c52b00805 (diff) |
Renamed terminal_specification to channel_specification
We're moving from using terminology related to terminals when
we refer to Websockets connections in Workhorse.
It's more appropiate a concept like channel.
Diffstat (limited to 'spec')
-rw-r--r-- | spec/controllers/projects/environments_controller_spec.rb | 2 | ||||
-rw-r--r-- | spec/controllers/projects/jobs_controller_spec.rb | 2 | ||||
-rw-r--r-- | spec/lib/gitlab/workhorse_spec.rb | 10 | ||||
-rw-r--r-- | spec/models/ci/build_runner_session_spec.rb | 16 |
4 files changed, 19 insertions, 11 deletions
diff --git a/spec/controllers/projects/environments_controller_spec.rb b/spec/controllers/projects/environments_controller_spec.rb index 2dca2c3976f..43639875265 100644 --- a/spec/controllers/projects/environments_controller_spec.rb +++ b/spec/controllers/projects/environments_controller_spec.rb @@ -283,7 +283,7 @@ describe Projects::EnvironmentsController do .and_return([:fake_terminal]) expect(Gitlab::Workhorse) - .to receive(:terminal_websocket) + .to receive(:channel_websocket) .with(:fake_terminal) .and_return(workhorse: :response) diff --git a/spec/controllers/projects/jobs_controller_spec.rb b/spec/controllers/projects/jobs_controller_spec.rb index d8a331b3cf0..23e4e9806c2 100644 --- a/spec/controllers/projects/jobs_controller_spec.rb +++ b/spec/controllers/projects/jobs_controller_spec.rb @@ -989,7 +989,7 @@ describe Projects::JobsController, :clean_gitlab_redis_shared_state do context 'and valid id' do it 'returns the terminal for the job' do expect(Gitlab::Workhorse) - .to receive(:terminal_websocket) + .to receive(:channel_websocket) .and_return(workhorse: :response) get_terminal_websocket(id: job.id) diff --git a/spec/lib/gitlab/workhorse_spec.rb b/spec/lib/gitlab/workhorse_spec.rb index fed7834e2a9..f8ce399287a 100644 --- a/spec/lib/gitlab/workhorse_spec.rb +++ b/spec/lib/gitlab/workhorse_spec.rb @@ -94,7 +94,7 @@ describe Gitlab::Workhorse do end end - describe '.terminal_websocket' do + describe '.channel_websocket' do def terminal(ca_pem: nil) out = { subprotocols: ['foo'], @@ -108,25 +108,25 @@ describe Gitlab::Workhorse do def workhorse(ca_pem: nil) out = { - 'Terminal' => { + 'Channel' => { 'Subprotocols' => ['foo'], 'Url' => 'wss://example.com/terminal.ws', 'Header' => { 'Authorization' => ['Token x'] }, 'MaxSessionTime' => 600 } } - out['Terminal']['CAPem'] = ca_pem if ca_pem + out['Channel']['CAPem'] = ca_pem if ca_pem out end context 'without ca_pem' do - subject { described_class.terminal_websocket(terminal) } + subject { described_class.channel_websocket(terminal) } it { is_expected.to eq(workhorse) } end context 'with ca_pem' do - subject { described_class.terminal_websocket(terminal(ca_pem: "foo")) } + subject { described_class.channel_websocket(terminal(ca_pem: "foo")) } it { is_expected.to eq(workhorse(ca_pem: "foo")) } end diff --git a/spec/models/ci/build_runner_session_spec.rb b/spec/models/ci/build_runner_session_spec.rb index a52c10019e6..e51fd009f50 100644 --- a/spec/models/ci/build_runner_session_spec.rb +++ b/spec/models/ci/build_runner_session_spec.rb @@ -13,25 +13,33 @@ describe Ci::BuildRunnerSession, model: true do it { is_expected.to validate_presence_of(:url).with_message('must be a valid URL') } describe '#terminal_specification' do - let(:terminal_specification) { subject.terminal_specification } + let(:specification) { subject.terminal_specification } + + it 'returns terminal.gitlab.com protocol' do + expect(specification[:subprotocols]).to eq ['terminal.gitlab.com'] + end + + it 'returns a wss url' do + expect(specification[:url]).to start_with('wss://') + end it 'returns empty hash if no url' do subject.url = '' - expect(terminal_specification).to be_empty + expect(specification).to be_empty end context 'when url is present' do it 'returns ca_pem nil if empty certificate' do subject.certificate = '' - expect(terminal_specification[:ca_pem]).to be_nil + expect(specification[:ca_pem]).to be_nil end it 'adds Authorization header if authorization is present' do subject.authorization = 'whatever' - expect(terminal_specification[:headers]).to include(Authorization: ['whatever']) + expect(specification[:headers]).to include(Authorization: ['whatever']) end end end |