Welcome to mirror list, hosted at ThFree Co, Russian Federation.

client_spec.rb « jira_connect « atlassian « lib « spec - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 40ffec21b269f00f57a181a9b050a40a3441c7a5 (plain)
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
# frozen_string_literal: true

require 'spec_helper'

RSpec.describe Atlassian::JiraConnect::Client do
  include StubRequests

  subject { described_class.new('https://gitlab-test.atlassian.net', 'sample_secret') }

  around do |example|
    Timecop.freeze { example.run }
  end

  describe '#store_dev_info' do
    it "calls the API with auth headers" do
      expected_jwt = Atlassian::Jwt.encode(
        Atlassian::Jwt.build_claims(
          Atlassian::JiraConnect.app_key,
          '/rest/devinfo/0.10/bulk',
          'POST'
        ),
        'sample_secret'
      )

      stub_full_request('https://gitlab-test.atlassian.net/rest/devinfo/0.10/bulk', method: :post)
        .with(
          headers: {
            'Authorization' => "JWT #{expected_jwt}",
            'Content-Type' => 'application/json'
          }
        )

      subject.store_dev_info(project: create(:project))
    end
  end
end