Commit 413163f9 authored by Ramya Authappan's avatar Ramya Authappan

Merge branch 'dependency-proxy-test' into 'master'

Dependency proxy test

See merge request gitlab-org/gitlab!66468
parents 83fe069e a9cd8c89
......@@ -8,5 +8,5 @@
= clipboard_button(text: "#{proxy_url}", title: _("Copy %{proxy_url}") % { proxy_url: proxy_url })
.row
.col-12.help-block.gl-mt-3
.col-12.help-block.gl-mt-3{ data: { qa_selector: 'dependency_proxy_count' } }
= _('Contains %{count} blobs of images (%{size})') % { count: @blobs_count, size: number_to_human_size(@blobs_total_size) }
......@@ -13,7 +13,7 @@
.form-group
%h5.prepend-top-20= _('Enable proxy')
.js-dependency-proxy-toggle-area
= render "shared/buttons/project_feature_toggle", is_checked: @dependency_proxy.enabled?, label: s_("DependencyProxy|Toggle Dependency Proxy") do
= render "shared/buttons/project_feature_toggle", is_checked: @dependency_proxy.enabled?, label: s_("DependencyProxy|Toggle Dependency Proxy"), data: { qa_selector: 'dependency_proxy_setting_toggle' } do
= f.hidden_field :enabled, { class: 'js-project-feature-toggle-input'}
- if @dependency_proxy.enabled
......
......@@ -239,6 +239,7 @@ module QA
autoload :Menu, 'qa/page/group/menu'
autoload :Members, 'qa/page/group/members'
autoload :BulkImport, 'qa/page/group/bulk_import'
autoload :DependencyProxy, 'qa/page/group/dependency_proxy'
module Milestone
autoload :Index, 'qa/page/group/milestone/index'
......
# frozen_string_literal: true
module QA
module Page
module Group
class DependencyProxy < QA::Page::Base
view 'app/views/groups/dependency_proxies/show.html.haml' do
element :dependency_proxy_setting_toggle
end
view 'app/views/groups/dependency_proxies/_url.html.haml' do
element :dependency_proxy_count
end
def has_dependency_proxy_enabled?
toggle = find_element(:dependency_proxy_setting_toggle)
toggle[:class].include?('is-checked')
end
def has_blob_count?(blob_text)
has_element?(:dependency_proxy_count, text: blob_text)
end
end
end
end
end
......@@ -70,6 +70,14 @@ module QA
end
end
def go_to_dependency_proxy
hover_group_packages do
within_submenu do
click_element(:sidebar_menu_item_link, menu_item: 'Dependency Proxy')
end
end
end
private
def hover_issues
......
# frozen_string_literal: true
module QA
RSpec.describe 'Package', :orchestrated, :registry do
describe 'Dependency Proxy' do
let(:project) do
Resource::Project.fabricate_via_api! do |project|
project.name = 'dependency-proxy-project'
project.visibility = :private
end
end
let!(:runner) do
Resource::Runner.fabricate! do |runner|
runner.name = "qa-runner-#{Time.now.to_i}"
runner.tags = ["runner-for-#{project.name}"]
runner.executor = :docker
runner.project = project
end
end
let(:uri) { URI.parse(Runtime::Scenario.gitlab_address) }
let(:gitlab_host_with_port) { "#{uri.host}:#{uri.port}" }
let(:dependency_proxy_url) { "#{gitlab_host_with_port}/#{project.group.full_path}/dependency_proxy/containers" }
before do
Flow::Login.sign_in
project.group.visit!
Page::Group::Menu.perform(&:go_to_dependency_proxy)
Page::Group::DependencyProxy.perform do |index|
expect(index).to have_dependency_proxy_enabled
end
end
after do
runner.remove_via_api!
end
where(:docker_client_version) do
%w[docker:19.03.12 docker:20.10]
end
with_them do
it "pulls an image using the dependency proxy", testcase: 'https://gitlab.com/gitlab-org/quality/testcases/-/issues/1862' do
Resource::Repository::Commit.fabricate_via_api! do |commit|
commit.project = project
commit.commit_message = 'Add .gitlab-ci.yml'
commit.add_files([{
file_path: '.gitlab-ci.yml',
content:
<<~YAML
dependency-proxy-pull-test:
image: "#{docker_client_version}"
services:
- name: "#{docker_client_version}-dind"
command:
- /bin/sh
- -c
- |
apk add --no-cache openssl
true | openssl s_client -showcerts -connect gitlab.test:5050 > /usr/local/share/ca-certificates/gitlab.test.crt
update-ca-certificates
dockerd-entrypoint.sh || exit
before_script:
- apk add curl jq grep
- docker login -u "$CI_DEPENDENCY_PROXY_USER" -p "$CI_DEPENDENCY_PROXY_PASSWORD" "$CI_DEPENDENCY_PROXY_SERVER"
script:
- docker pull #{dependency_proxy_url}/alpine:latest
- TOKEN=$(curl "https://auth.docker.io/token?service=registry.docker.io&scope=repository:ratelimitpreview/test:pull" | jq --raw-output .token)
- 'curl --head --header "Authorization: Bearer $TOKEN" "https://registry-1.docker.io/v2/ratelimitpreview/test/manifests/latest" 2>&1'
- docker pull #{dependency_proxy_url}/alpine:latest
- 'curl --head --header "Authorization: Bearer $TOKEN" "https://registry-1.docker.io/v2/ratelimitpreview/test/manifests/latest" 2>&1'
tags:
- "runner-for-#{project.name}"
YAML
}])
end
project.visit!
Flow::Pipeline.visit_latest_pipeline
Page::Project::Pipeline::Show.perform do |pipeline|
pipeline.click_job('dependency-proxy-pull-test')
end
Page::Project::Job::Show.perform do |job|
expect(job).to be_successful(timeout: 800)
end
project.group.visit!
Page::Group::Menu.perform(&:go_to_dependency_proxy)
Page::Group::DependencyProxy.perform do |index|
expect(index).to have_blob_count("Contains 2 blobs of images")
end
end
end
end
end
end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment