1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59
|
require 'spec_helper'
describe JIRA::JwtClient::JwtUriBuilder do
subject(:url_builder) do
JIRA::JwtClient::JwtUriBuilder.new(url, http_method, shared_secret, site, issuer)
end
let(:url) { '/foo' }
let(:http_method) { :get }
let(:shared_secret) { 'shared_secret' }
let(:site) { 'http://localhost:2990' }
let(:issuer) { nil }
describe '#build' do
subject { url_builder.build }
it 'includes the jwt param' do
expect(subject).to include('?jwt=')
end
context 'when the url already contains params' do
let(:url) { '/foo?expand=projects.issuetypes.fields' }
it 'includes the jwt param' do
expect(subject).to include('&jwt=')
end
end
context 'with a complete url' do
let(:url) { 'http://localhost:2990/rest/api/2/issue/createmeta' }
it 'includes the jwt param' do
expect(subject).to include('?jwt=')
end
it { is_expected.to start_with('/') }
it 'contains only one ?' do
expect(subject.count('?')).to eq(1)
end
end
context 'with a complete url containing a param' do
let(:url) do
'http://localhost:2990/rest/api/2/issue/createmeta?expand=projects.issuetypes.fields'
end
it 'includes the jwt param' do
expect(subject).to include('&jwt=')
end
it { is_expected.to start_with('/') }
it 'contains only one ?' do
expect(subject.count('?')).to eq(1)
end
end
end
end
|