summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2020-01-14 00:08:14 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2020-01-14 00:08:14 +0000
commit427c549b6396885fb60a687326b6cd62878e4ca3 (patch)
tree145713e2f6fdaf7499b0cb44010503e16b6248b9 /spec
parent74a89b1221eaf780374bd1d4c5b2ee4a0f488908 (diff)
downloadgitlab-ce-427c549b6396885fb60a687326b6cd62878e4ca3.tar.gz
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec')
-rw-r--r--spec/features/clusters/installing_applications_shared_examples.rb3
-rw-r--r--spec/finders/keys_finder_spec.rb34
-rw-r--r--spec/fixtures/api/schemas/cluster_status.json1
-rw-r--r--spec/frontend/clusters/components/applications_spec.js66
-rw-r--r--spec/frontend/clusters/services/mock_data.js2
-rw-r--r--spec/frontend/clusters/stores/clusters_store_spec.js12
-rw-r--r--spec/helpers/users_helper_spec.rb14
-rw-r--r--spec/models/clusters/applications/elastic_stack_spec.rb55
-rw-r--r--spec/requests/api/keys_spec.rb30
-rw-r--r--spec/serializers/deploy_key_entity_spec.rb1
-rw-r--r--spec/services/clusters/applications/create_service_spec.rb7
11 files changed, 86 insertions, 139 deletions
diff --git a/spec/features/clusters/installing_applications_shared_examples.rb b/spec/features/clusters/installing_applications_shared_examples.rb
index 988cd228c1c..20648ed3d46 100644
--- a/spec/features/clusters/installing_applications_shared_examples.rb
+++ b/spec/features/clusters/installing_applications_shared_examples.rb
@@ -181,11 +181,8 @@ shared_examples "installing applications on a cluster" do
context 'when user installs Elastic Stack' do
before do
allow(ClusterInstallAppWorker).to receive(:perform_async)
- allow(ClusterWaitForIngressIpAddressWorker).to receive(:perform_in)
- allow(ClusterWaitForIngressIpAddressWorker).to receive(:perform_async)
create(:clusters_applications_helm, :installed, cluster: cluster)
- create(:clusters_applications_ingress, :installed, external_ip: '127.0.0.1', cluster: cluster)
page.within('.js-cluster-application-row-elastic_stack') do
click_button 'Install'
diff --git a/spec/finders/keys_finder_spec.rb b/spec/finders/keys_finder_spec.rb
index f80abdcdb38..7605d066ddf 100644
--- a/spec/finders/keys_finder_spec.rb
+++ b/spec/finders/keys_finder_spec.rb
@@ -73,7 +73,15 @@ describe KeysFinder do
end
context 'with valid fingerprints' do
- context 'with valid MD5 params' do
+ let!(:deploy_key) do
+ create(:deploy_key,
+ user: user,
+ key: 'ssh-rsa AAAAB3NzaC1yc2EAAAABJQAAAIEAiPWx6WM4lhHNedGfBpPJNPpZ7yKu+dnn1SJejgt1017k6YjzGGphH2TUxwKzxcKDKKezwkpfnxPkSMkuEspGRt/aZZ9wa++Oi7Qkr8prgHc4soW6NUlfDzpvZK2H5E7eQaSeP3SAwGmQKUFHCddNaP0L+hM7zhFNzjFvpaMgJw0=',
+ fingerprint: '8a:4a:12:92:0b:50:47:02:d4:5a:8e:a9:44:4e:08:b4',
+ fingerprint_sha256: '4DPHOVNh53i9dHb5PpY2vjfyf5qniTx1/pBFPoZLDdk')
+ end
+
+ context 'personal key with valid MD5 params' do
context 'with an existent fingerprint' do
before do
params[:fingerprint] = 'ba:81:59:68:d7:6c:cd:02:02:bf:6a:9b:55:4e:af:d1'
@@ -85,6 +93,17 @@ describe KeysFinder do
end
end
+ context 'deploy key with an existent fingerprint' do
+ before do
+ params[:fingerprint] = '8a:4a:12:92:0b:50:47:02:d4:5a:8e:a9:44:4e:08:b4'
+ end
+
+ it 'returns the key' do
+ expect(subject).to eq(deploy_key)
+ expect(subject.user).to eq(user)
+ end
+ end
+
context 'with a non-existent fingerprint' do
before do
params[:fingerprint] = 'bb:81:59:68:d7:6c:cd:02:02:bf:6a:9b:55:4e:af:d2'
@@ -96,7 +115,7 @@ describe KeysFinder do
end
end
- context 'with valid SHA256 params' do
+ context 'personal key with valid SHA256 params' do
context 'with an existent fingerprint' do
before do
params[:fingerprint] = 'SHA256:nUhzNyftwADy8AH3wFY31tAKs7HufskYTte2aXo/lCg'
@@ -108,6 +127,17 @@ describe KeysFinder do
end
end
+ context 'deploy key with an existent fingerprint' do
+ before do
+ params[:fingerprint] = 'SHA256:4DPHOVNh53i9dHb5PpY2vjfyf5qniTx1/pBFPoZLDdk'
+ end
+
+ it 'returns key' do
+ expect(subject).to eq(deploy_key)
+ expect(subject.user).to eq(user)
+ end
+ end
+
context 'with a non-existent fingerprint' do
before do
params[:fingerprint] = 'SHA256:xTjuFqftwADy8AH3wFY31tAKs7HufskYTte2aXi/mNp'
diff --git a/spec/fixtures/api/schemas/cluster_status.json b/spec/fixtures/api/schemas/cluster_status.json
index fcb4f2b94cd..29c56b5c820 100644
--- a/spec/fixtures/api/schemas/cluster_status.json
+++ b/spec/fixtures/api/schemas/cluster_status.json
@@ -35,7 +35,6 @@
"external_ip": { "type": ["string", "null"] },
"external_hostname": { "type": ["string", "null"] },
"hostname": { "type": ["string", "null"] },
- "kibana_hostname": { "type": ["string", "null"] },
"email": { "type": ["string", "null"] },
"stack": { "type": ["string", "null"] },
"modsecurity_enabled": { "type": ["boolean", "null"] },
diff --git a/spec/frontend/clusters/components/applications_spec.js b/spec/frontend/clusters/components/applications_spec.js
index e8c5a2bd242..a646ea8c700 100644
--- a/spec/frontend/clusters/components/applications_spec.js
+++ b/spec/frontend/clusters/components/applications_spec.js
@@ -199,7 +199,7 @@ describe('Applications', () => {
prometheus: { title: 'Prometheus' },
jupyter: { title: 'JupyterHub', hostname: '' },
knative: { title: 'Knative', hostname: '' },
- elastic_stack: { title: 'Elastic Stack', kibana_hostname: '' },
+ elastic_stack: { title: 'Elastic Stack' },
},
});
@@ -433,81 +433,35 @@ describe('Applications', () => {
});
describe('Elastic Stack application', () => {
- describe('with ingress installed with ip & elastic stack installable', () => {
+ describe('with elastic stack installable', () => {
it('renders hostname active input', () => {
vm = mountComponent(Applications, {
applications: {
...APPLICATIONS_MOCK_STATE,
- ingress: {
- title: 'Ingress',
- status: 'installed',
- externalIp: '1.1.1.1',
- },
},
});
expect(
vm.$el
- .querySelector('.js-cluster-application-row-elastic_stack .js-hostname')
- .getAttribute('readonly'),
- ).toEqual(null);
- });
- });
-
- describe('with ingress installed without external ip', () => {
- it('does not render hostname input', () => {
- vm = mountComponent(Applications, {
- applications: {
- ...APPLICATIONS_MOCK_STATE,
- ingress: { title: 'Ingress', status: 'installed' },
- },
- });
-
- expect(vm.$el.querySelector('.js-cluster-application-row-elastic_stack .js-hostname')).toBe(
- null,
- );
+ .querySelector(
+ '.js-cluster-application-row-elastic_stack .js-cluster-application-install-button',
+ )
+ .getAttribute('disabled'),
+ ).toEqual('disabled');
});
});
- describe('with ingress & elastic stack installed', () => {
- it('renders readonly input', () => {
+ describe('elastic stack installed', () => {
+ it('renders uninstall button', () => {
vm = mountComponent(Applications, {
applications: {
...APPLICATIONS_MOCK_STATE,
- ingress: {
- title: 'Ingress',
- status: 'installed',
- externalIp: '1.1.1.1',
- modsecurity_enabled: false,
- },
- elastic_stack: { title: 'Elastic Stack', status: 'installed', kibana_hostname: '' },
+ elastic_stack: { title: 'Elastic Stack', status: 'installed' },
},
});
expect(
vm.$el
- .querySelector('.js-cluster-application-row-elastic_stack .js-hostname')
- .getAttribute('readonly'),
- ).toEqual('readonly');
- });
- });
-
- describe('without ingress installed', () => {
- beforeEach(() => {
- vm = mountComponent(Applications, {
- applications: APPLICATIONS_MOCK_STATE,
- });
- });
-
- it('does not render input', () => {
- expect(vm.$el.querySelector('.js-cluster-application-row-elastic_stack .js-hostname')).toBe(
- null,
- );
- });
-
- it('renders disabled install button', () => {
- expect(
- vm.$el
.querySelector(
'.js-cluster-application-row-elastic_stack .js-cluster-application-install-button',
)
diff --git a/spec/frontend/clusters/services/mock_data.js b/spec/frontend/clusters/services/mock_data.js
index 98fa0ec3b07..f0bcf5d980f 100644
--- a/spec/frontend/clusters/services/mock_data.js
+++ b/spec/frontend/clusters/services/mock_data.js
@@ -157,7 +157,7 @@ const APPLICATIONS_MOCK_STATE = {
prometheus: { title: 'Prometheus' },
jupyter: { title: 'JupyterHub', status: 'installable', hostname: '' },
knative: { title: 'Knative ', status: 'installable', hostname: '' },
- elastic_stack: { title: 'Elastic Stack', status: 'installable', kibana_hostname: '' },
+ elastic_stack: { title: 'Elastic Stack', status: 'installable' },
};
export { CLUSTERS_MOCK_DATA, DEFAULT_APPLICATION_STATE, APPLICATIONS_MOCK_STATE };
diff --git a/spec/frontend/clusters/stores/clusters_store_spec.js b/spec/frontend/clusters/stores/clusters_store_spec.js
index c7ec4ddc464..f2dbdd0638b 100644
--- a/spec/frontend/clusters/stores/clusters_store_spec.js
+++ b/spec/frontend/clusters/stores/clusters_store_spec.js
@@ -167,7 +167,6 @@ describe('Clusters Store', () => {
installFailed: true,
statusReason: mockResponseData.applications[7].status_reason,
requestReason: null,
- kibana_hostname: '',
installed: false,
uninstallable: false,
uninstallSuccessful: false,
@@ -216,16 +215,5 @@ describe('Clusters Store', () => {
`jupyter.${store.state.applications.ingress.externalIp}.nip.io`,
);
});
-
- it('sets default hostname for elastic stack when ingress has a ip address', () => {
- const mockResponseData =
- CLUSTERS_MOCK_DATA.GET['/gitlab-org/gitlab-shell/clusters/2/status.json'].data;
-
- store.updateStateFromServer(mockResponseData);
-
- expect(store.state.applications.elastic_stack.kibana_hostname).toEqual(
- `kibana.${store.state.applications.ingress.externalIp}.nip.io`,
- );
- });
});
});
diff --git a/spec/helpers/users_helper_spec.rb b/spec/helpers/users_helper_spec.rb
index 172ead158fb..8479f8509f5 100644
--- a/spec/helpers/users_helper_spec.rb
+++ b/spec/helpers/users_helper_spec.rb
@@ -7,6 +7,10 @@ describe UsersHelper do
let(:user) { create(:user) }
+ def filter_ee_badges(badges)
+ badges.reject { |badge| badge[:text] == 'Is using seat' }
+ end
+
describe '#user_link' do
subject { helper.user_link(user) }
@@ -118,7 +122,7 @@ describe UsersHelper do
badges = helper.user_badges_in_admin_section(blocked_user)
- expect(badges).to eq([text: "Blocked", variant: "danger"])
+ expect(filter_ee_badges(badges)).to eq([text: "Blocked", variant: "danger"])
end
end
@@ -128,7 +132,7 @@ describe UsersHelper do
badges = helper.user_badges_in_admin_section(admin_user)
- expect(badges).to eq([text: "Admin", variant: "success"])
+ expect(filter_ee_badges(badges)).to eq([text: "Admin", variant: "success"])
end
end
@@ -138,7 +142,7 @@ describe UsersHelper do
badges = helper.user_badges_in_admin_section(external_user)
- expect(badges).to eq([text: "External", variant: "secondary"])
+ expect(filter_ee_badges(badges)).to eq([text: "External", variant: "secondary"])
end
end
@@ -146,7 +150,7 @@ describe UsersHelper do
it 'returns the "It\'s You" badge' do
badges = helper.user_badges_in_admin_section(user)
- expect(badges).to eq([text: "It's you!", variant: nil])
+ expect(filter_ee_badges(badges)).to eq([text: "It's you!", variant: nil])
end
end
@@ -170,7 +174,7 @@ describe UsersHelper do
badges = helper.user_badges_in_admin_section(user)
- expect(badges).to be_empty
+ expect(filter_ee_badges(badges)).to be_empty
end
end
end
diff --git a/spec/models/clusters/applications/elastic_stack_spec.rb b/spec/models/clusters/applications/elastic_stack_spec.rb
index 2179e930691..d336dc752c8 100644
--- a/spec/models/clusters/applications/elastic_stack_spec.rb
+++ b/spec/models/clusters/applications/elastic_stack_spec.rb
@@ -10,45 +10,8 @@ describe Clusters::Applications::ElasticStack do
include_examples 'cluster application version specs', :clusters_applications_elastic_stack
include_examples 'cluster application helm specs', :clusters_applications_elastic_stack
- describe '#can_uninstall?' do
- let(:ingress) { create(:clusters_applications_ingress, :installed, external_hostname: 'localhost.localdomain') }
- let(:elastic_stack) { create(:clusters_applications_elastic_stack, cluster: ingress.cluster) }
-
- subject { elastic_stack.can_uninstall? }
-
- it { is_expected.to be_truthy }
- end
-
- describe '#set_initial_status' do
- before do
- elastic_stack.set_initial_status
- end
-
- context 'when ingress is not installed' do
- let(:cluster) { create(:cluster, :provided_by_gcp) }
- let(:elastic_stack) { create(:clusters_applications_elastic_stack, cluster: cluster) }
-
- it { expect(elastic_stack).to be_not_installable }
- end
-
- context 'when ingress is installed and external_ip is assigned' do
- let(:ingress) { create(:clusters_applications_ingress, :installed, external_ip: '127.0.0.1') }
- let(:elastic_stack) { create(:clusters_applications_elastic_stack, cluster: ingress.cluster) }
-
- it { expect(elastic_stack).to be_installable }
- end
-
- context 'when ingress is installed and external_hostname is assigned' do
- let(:ingress) { create(:clusters_applications_ingress, :installed, external_hostname: 'localhost.localdomain') }
- let(:elastic_stack) { create(:clusters_applications_elastic_stack, cluster: ingress.cluster) }
-
- it { expect(elastic_stack).to be_installable }
- end
- end
-
describe '#install_command' do
- let!(:ingress) { create(:clusters_applications_ingress, :installed, external_ip: '127.0.0.1') }
- let!(:elastic_stack) { create(:clusters_applications_elastic_stack, cluster: ingress.cluster) }
+ let!(:elastic_stack) { create(:clusters_applications_elastic_stack) }
subject { elastic_stack.install_command }
@@ -80,8 +43,7 @@ describe Clusters::Applications::ElasticStack do
end
describe '#uninstall_command' do
- let!(:ingress) { create(:clusters_applications_ingress, :installed, external_ip: '127.0.0.1') }
- let!(:elastic_stack) { create(:clusters_applications_elastic_stack, cluster: ingress.cluster) }
+ let!(:elastic_stack) { create(:clusters_applications_elastic_stack) }
subject { elastic_stack.uninstall_command }
@@ -100,19 +62,6 @@ describe Clusters::Applications::ElasticStack do
end
end
- describe '#files' do
- let!(:ingress) { create(:clusters_applications_ingress, :installed, external_ip: '127.0.0.1') }
- let!(:elastic_stack) { create(:clusters_applications_elastic_stack, cluster: ingress.cluster) }
-
- let(:values) { subject[:'values.yaml'] }
-
- subject { elastic_stack.files }
-
- it 'includes elastic stack specific keys in the values.yaml file' do
- expect(values).to include('ELASTICSEARCH_HOSTS')
- end
- end
-
describe '#elasticsearch_client' do
context 'cluster is nil' do
it 'returns nil' do
diff --git a/spec/requests/api/keys_spec.rb b/spec/requests/api/keys_spec.rb
index f7da1abcfdf..c743cb3f633 100644
--- a/spec/requests/api/keys_spec.rb
+++ b/spec/requests/api/keys_spec.rb
@@ -106,6 +106,36 @@ describe API::Keys do
expect(json_response['user']['is_admin']).to be_nil
end
+
+ context 'when searching a DeployKey' do
+ let(:project) { create(:project, :repository) }
+ let(:project_push) { create(:project, :repository) }
+ let(:deploy_key) { create(:deploy_key) }
+
+ let!(:deploy_keys_project) do
+ create(:deploy_keys_project, project: project, deploy_key: deploy_key)
+ end
+
+ let!(:deploy_keys_project_push) do
+ create(:deploy_keys_project, project: project_push, deploy_key: deploy_key, can_push: true)
+ end
+
+ it 'returns user and projects if SSH sha256 fingerprint for DeployKey found' do
+ user.keys << deploy_key
+
+ get api("/keys?fingerprint=#{URI.encode_www_form_component("SHA256:" + deploy_key.fingerprint_sha256)}", admin)
+
+ expect(response).to have_gitlab_http_status(200)
+ expect(json_response['title']).to eq(deploy_key.title)
+ expect(json_response['user']['id']).to eq(user.id)
+
+ expect(json_response['deploy_keys_projects'].count).to eq(2)
+ expect(json_response['deploy_keys_projects'][0]['project_id']).to eq(deploy_keys_project.project.id)
+ expect(json_response['deploy_keys_projects'][0]['can_push']).to eq(deploy_keys_project.can_push)
+ expect(json_response['deploy_keys_projects'][1]['project_id']).to eq(deploy_keys_project_push.project.id)
+ expect(json_response['deploy_keys_projects'][1]['can_push']).to eq(deploy_keys_project_push.can_push)
+ end
+ end
end
end
end
diff --git a/spec/serializers/deploy_key_entity_spec.rb b/spec/serializers/deploy_key_entity_spec.rb
index 607adfc2488..0dbbf0de59b 100644
--- a/spec/serializers/deploy_key_entity_spec.rb
+++ b/spec/serializers/deploy_key_entity_spec.rb
@@ -24,6 +24,7 @@ describe DeployKeyEntity do
user_id: deploy_key.user_id,
title: deploy_key.title,
fingerprint: deploy_key.fingerprint,
+ fingerprint_sha256: deploy_key.fingerprint_sha256,
destroyed_when_orphaned: true,
almost_orphaned: false,
created_at: deploy_key.created_at,
diff --git a/spec/services/clusters/applications/create_service_spec.rb b/spec/services/clusters/applications/create_service_spec.rb
index d5ad03a94ac..f62af86f1bf 100644
--- a/spec/services/clusters/applications/create_service_spec.rb
+++ b/spec/services/clusters/applications/create_service_spec.rb
@@ -163,8 +163,7 @@ describe Clusters::Applications::CreateService do
context 'elastic stack application' do
let(:params) do
{
- application: 'elastic_stack',
- kibana_hostname: 'example.com'
+ application: 'elastic_stack'
}
end
@@ -182,10 +181,6 @@ describe Clusters::Applications::CreateService do
cluster.reload
end.to change(cluster, :application_elastic_stack)
end
-
- it 'sets the kibana_hostname' do
- expect(subject.kibana_hostname).to eq('example.com')
- end
end
end