summaryrefslogtreecommitdiff
path: root/spec/frontend/fixtures/deploy_keys.rb
blob: bed6c798793dce0e851faad642a5746a5fbd6c7e (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
37
38
39
40
41
42
43
44
45
# frozen_string_literal: true

require 'spec_helper'

RSpec.describe Projects::DeployKeysController, '(JavaScript fixtures)', type: :controller do
  include JavaScriptFixturesHelpers
  include AdminModeHelper

  let(:admin) { create(:admin) }
  let(:namespace) { create(:namespace, name: 'frontend-fixtures' )}
  let(:project) { create(:project_empty_repo, namespace: namespace, path: 'todos-project') }
  let(:project2) { create(:project, :internal)}
  let(:project3) { create(:project, :internal)}
  let(:project4) { create(:project, :internal)}

  before do
    # Using an admin for these fixtures because they are used for verifying a frontend
    # component that would normally get its data from `Admin::DeployKeysController`
    sign_in(admin)
    enable_admin_mode!(admin)
  end

  after do
    remove_repository(project)
  end

  render_views

  it 'deploy_keys/keys.json' do
    create(:rsa_deploy_key_2048, public: true)
    project_key = create(:deploy_key, key: 'ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAAAgQCdMHEHyhRjbhEZVddFn6lTWdgEy5Q6Bz4nwGB76xWZI5YT/1WJOMEW+sL5zYd31kk7sd3FJ5L9ft8zWMWrr/iWXQikC2cqZK24H1xy+ZUmrRuJD4qGAaIVoyyzBL+avL+lF8J5lg6YSw8gwJY/lX64/vnJHUlWw2n5BF8IFOWhiw== dummy@gitlab.com')
    internal_key = create(:deploy_key, key: 'ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAAAgQDNd/UJWhPrpb+b/G5oL109y57yKuCxE+WUGJGYaj7WQKsYRJmLYh1mgjrl+KVyfsWpq4ylOxIfFSnN9xBBFN8mlb0Fma5DC7YsSsibJr3MZ19ZNBprwNcdogET7aW9I0In7Wu5f2KqI6e5W/spJHCy4JVxzVMUvk6Myab0LnJ2iQ== dummy@gitlab.com')
    create(:deploy_keys_project, project: project, deploy_key: project_key)
    create(:deploy_keys_project, project: project2, deploy_key: internal_key)
    create(:deploy_keys_project, project: project3, deploy_key: project_key)
    create(:deploy_keys_project, project: project4, deploy_key: project_key)

    get :index, params: {
      namespace_id: project.namespace.to_param,
      project_id: project
    }, format: :json

    expect(response).to be_successful
  end
end