summaryrefslogtreecommitdiff
path: root/spec/controllers/jira_connect/subscriptions_controller_spec.rb
diff options
context:
space:
mode:
Diffstat (limited to 'spec/controllers/jira_connect/subscriptions_controller_spec.rb')
-rw-r--r--spec/controllers/jira_connect/subscriptions_controller_spec.rb18
1 files changed, 15 insertions, 3 deletions
diff --git a/spec/controllers/jira_connect/subscriptions_controller_spec.rb b/spec/controllers/jira_connect/subscriptions_controller_spec.rb
index f548c1f399d..e9c94f09c99 100644
--- a/spec/controllers/jira_connect/subscriptions_controller_spec.rb
+++ b/spec/controllers/jira_connect/subscriptions_controller_spec.rb
@@ -75,6 +75,18 @@ RSpec.describe JiraConnect::SubscriptionsController do
expect(json_response).to include('login_path' => nil)
end
end
+
+ context 'with context qsh' do
+ # The JSON endpoint will be requested by frontend using a JWT that Atlassian provides via Javascript.
+ # This JWT will likely use a context-qsh because Atlassian don't know for which endpoint it will be used.
+ # Read more about context JWT here: https://developer.atlassian.com/cloud/jira/platform/understanding-jwt-for-connect-apps/
+
+ let(:qsh) { 'context-qsh' }
+
+ specify do
+ expect(response).to have_gitlab_http_status(:ok)
+ end
+ end
end
end
end
@@ -102,7 +114,7 @@ RSpec.describe JiraConnect::SubscriptionsController do
end
context 'with valid JWT' do
- let(:claims) { { iss: installation.client_key, sub: 1234 } }
+ let(:claims) { { iss: installation.client_key, sub: 1234, qsh: '123' } }
let(:jwt) { Atlassian::Jwt.encode(claims, installation.shared_secret) }
let(:jira_user) { { 'groups' => { 'items' => [{ 'name' => jira_group_name }] } } }
let(:jira_group_name) { 'site-admins' }
@@ -158,7 +170,7 @@ RSpec.describe JiraConnect::SubscriptionsController do
.stub_request(:get, "#{installation.base_url}/rest/api/3/user?accountId=1234&expand=groups")
.to_return(body: jira_user.to_json, status: 200, headers: { 'Content-Type' => 'application/json' })
- delete :destroy, params: { jwt: jwt, id: subscription.id }
+ delete :destroy, params: { jwt: jwt, id: subscription.id, format: :json }
end
context 'without JWT' do
@@ -170,7 +182,7 @@ RSpec.describe JiraConnect::SubscriptionsController do
end
context 'with valid JWT' do
- let(:claims) { { iss: installation.client_key, sub: 1234 } }
+ let(:claims) { { iss: installation.client_key, sub: 1234, qsh: '123' } }
let(:jwt) { Atlassian::Jwt.encode(claims, installation.shared_secret) }
it 'deletes the subscription' do