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

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2022-05-21 03:08:00 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2022-05-21 03:08:00 +0300
commit0fd09fff507a22e2059bcfe11cfc4e657590c72c (patch)
tree2468ba28f97c59a9a4729bc7734cfdc5600f27b8 /spec
parent22fe7d7df6b91040d6cecbfd78f24c563afed463 (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec')
-rw-r--r--spec/frontend/packages_and_registries/settings/group/components/dependency_proxy_settings_spec.js12
-rw-r--r--spec/frontend/security_configuration/components/app_spec.js187
-rw-r--r--spec/frontend/security_configuration/mock_data.js9
-rw-r--r--spec/models/project_spec.rb8
4 files changed, 69 insertions, 147 deletions
diff --git a/spec/frontend/packages_and_registries/settings/group/components/dependency_proxy_settings_spec.js b/spec/frontend/packages_and_registries/settings/group/components/dependency_proxy_settings_spec.js
index 22754d31f93..e60989b0949 100644
--- a/spec/frontend/packages_and_registries/settings/group/components/dependency_proxy_settings_spec.js
+++ b/spec/frontend/packages_and_registries/settings/group/components/dependency_proxy_settings_spec.js
@@ -134,12 +134,6 @@ describe('DependencyProxySettings', () => {
mountComponent();
});
- it('has the help prop correctly set', () => {
- expect(findEnableProxyToggle().props()).toMatchObject({
- help: component.i18n.enabledProxyHelpText,
- });
- });
-
it('has help text with a link', () => {
expect(findEnableProxyToggle().text()).toContain(
'To see the image prefix and what is in the cache, visit the Dependency Proxy',
@@ -157,12 +151,6 @@ describe('DependencyProxySettings', () => {
});
});
- it('has the help prop set to empty', () => {
- expect(findEnableProxyToggle().props()).toMatchObject({
- help: '',
- });
- });
-
it('the help text is not visible', () => {
expect(findToggleHelpLink().exists()).toBe(false);
});
diff --git a/spec/frontend/security_configuration/components/app_spec.js b/spec/frontend/security_configuration/components/app_spec.js
index d7d46d0d415..161f1a405d1 100644
--- a/spec/frontend/security_configuration/components/app_spec.js
+++ b/spec/frontend/security_configuration/components/app_spec.js
@@ -2,7 +2,6 @@ import Vue, { nextTick } from 'vue';
import VueApollo from 'vue-apollo';
import { GlTab, GlTabs, GlLink } from '@gitlab/ui';
import { mount } from '@vue/test-utils';
-
import { useLocalStorageSpy } from 'helpers/local_storage_helper';
import { makeMockUserCalloutDismisser } from 'helpers/mock_user_callout_dismisser';
import stubChildren from 'helpers/stub_children';
@@ -20,22 +19,14 @@ import {
LICENSE_COMPLIANCE_DESCRIPTION,
LICENSE_COMPLIANCE_HELP_PATH,
AUTO_DEVOPS_ENABLED_ALERT_DISMISSED_STORAGE_KEY,
- LICENSE_ULTIMATE,
- LICENSE_PREMIUM,
- LICENSE_FREE,
} from '~/security_configuration/components/constants';
import FeatureCard from '~/security_configuration/components/feature_card.vue';
import TrainingProviderList from '~/security_configuration/components/training_provider_list.vue';
-import createMockApollo from 'helpers/mock_apollo_helper';
-import currentLicenseQuery from '~/security_configuration/graphql/current_license.query.graphql';
-import waitForPromises from 'helpers/wait_for_promises';
-
import UpgradeBanner from '~/security_configuration/components/upgrade_banner.vue';
import {
REPORT_TYPE_LICENSE_COMPLIANCE,
REPORT_TYPE_SAST,
} from '~/vue_shared/security_reports/constants';
-import { getCurrentLicensePlanResponse } from '../mock_data';
const upgradePath = '/upgrade';
const autoDevopsHelpPagePath = '/autoDevopsHelpPagePath';
@@ -50,31 +41,40 @@ Vue.use(VueApollo);
describe('App component', () => {
let wrapper;
let userCalloutDismissSpy;
- let mockApollo;
- const createComponent = ({
- shouldShowCallout = true,
- licenseQueryResponse = LICENSE_ULTIMATE,
- ...propsData
- }) => {
- userCalloutDismissSpy = jest.fn();
+ const securityFeaturesMock = [
+ {
+ name: SAST_NAME,
+ shortName: SAST_SHORT_NAME,
+ description: SAST_DESCRIPTION,
+ helpPath: SAST_HELP_PATH,
+ configurationHelpPath: SAST_CONFIG_HELP_PATH,
+ type: REPORT_TYPE_SAST,
+ available: true,
+ },
+ ];
- mockApollo = createMockApollo([
- [
- currentLicenseQuery,
- jest
- .fn()
- .mockResolvedValue(
- licenseQueryResponse instanceof Error
- ? licenseQueryResponse
- : getCurrentLicensePlanResponse(licenseQueryResponse),
- ),
- ],
- ]);
+ const complianceFeaturesMock = [
+ {
+ name: LICENSE_COMPLIANCE_NAME,
+ description: LICENSE_COMPLIANCE_DESCRIPTION,
+ helpPath: LICENSE_COMPLIANCE_HELP_PATH,
+ type: REPORT_TYPE_LICENSE_COMPLIANCE,
+ configurationHelpPath: LICENSE_COMPLIANCE_HELP_PATH,
+ },
+ ];
+
+ const createComponent = ({ shouldShowCallout = true, ...propsData } = {}) => {
+ userCalloutDismissSpy = jest.fn();
wrapper = extendedWrapper(
mount(SecurityConfigurationApp, {
- propsData,
+ propsData: {
+ augmentedSecurityFeatures: securityFeaturesMock,
+ augmentedComplianceFeatures: complianceFeaturesMock,
+ securityTrainingEnabled: true,
+ ...propsData,
+ },
provide: {
upgradePath,
autoDevopsHelpPagePath,
@@ -82,7 +82,6 @@ describe('App component', () => {
projectFullPath,
vulnerabilityTrainingDocsPath,
},
- apolloProvider: mockApollo,
stubs: {
...stubChildren(SecurityConfigurationApp),
GlLink: false,
@@ -133,40 +132,13 @@ describe('App component', () => {
const findAutoDevopsEnabledAlert = () => wrapper.findComponent(AutoDevopsEnabledAlert);
const findVulnerabilityManagementTab = () => wrapper.findByTestId('vulnerability-management-tab');
- const securityFeaturesMock = [
- {
- name: SAST_NAME,
- shortName: SAST_SHORT_NAME,
- description: SAST_DESCRIPTION,
- helpPath: SAST_HELP_PATH,
- configurationHelpPath: SAST_CONFIG_HELP_PATH,
- type: REPORT_TYPE_SAST,
- available: true,
- },
- ];
-
- const complianceFeaturesMock = [
- {
- name: LICENSE_COMPLIANCE_NAME,
- description: LICENSE_COMPLIANCE_DESCRIPTION,
- helpPath: LICENSE_COMPLIANCE_HELP_PATH,
- type: REPORT_TYPE_LICENSE_COMPLIANCE,
- configurationHelpPath: LICENSE_COMPLIANCE_HELP_PATH,
- },
- ];
-
afterEach(() => {
wrapper.destroy();
- mockApollo = null;
});
describe('basic structure', () => {
- beforeEach(async () => {
- createComponent({
- augmentedSecurityFeatures: securityFeaturesMock,
- augmentedComplianceFeatures: complianceFeaturesMock,
- });
- await waitForPromises();
+ beforeEach(() => {
+ createComponent();
});
it('renders main-heading with correct text', () => {
@@ -226,10 +198,7 @@ describe('App component', () => {
describe('Manage via MR Error Alert', () => {
beforeEach(() => {
- createComponent({
- augmentedSecurityFeatures: securityFeaturesMock,
- augmentedComplianceFeatures: complianceFeaturesMock,
- });
+ createComponent();
});
describe('on initial load', () => {
@@ -265,8 +234,6 @@ describe('App component', () => {
describe('given the right props', () => {
beforeEach(() => {
createComponent({
- augmentedSecurityFeatures: securityFeaturesMock,
- augmentedComplianceFeatures: complianceFeaturesMock,
autoDevopsEnabled: false,
gitlabCiPresent: false,
canEnableAutoDevops: true,
@@ -288,10 +255,7 @@ describe('App component', () => {
describe('given the wrong props', () => {
beforeEach(() => {
- createComponent({
- augmentedSecurityFeatures: securityFeaturesMock,
- augmentedComplianceFeatures: complianceFeaturesMock,
- });
+ createComponent();
});
it('should not show AutoDevopsAlert', () => {
expect(findAutoDevopsAlert().exists()).toBe(false);
@@ -315,11 +279,7 @@ describe('App component', () => {
);
}
- createComponent({
- augmentedSecurityFeatures: securityFeaturesMock,
- augmentedComplianceFeatures: complianceFeaturesMock,
- autoDevopsEnabled,
- });
+ createComponent({ autoDevopsEnabled });
});
it(shouldRender ? 'renders' : 'does not render', () => {
@@ -345,12 +305,7 @@ describe('App component', () => {
);
}
- createComponent({
- augmentedSecurityFeatures: securityFeaturesMock,
- augmentedComplianceFeatures: complianceFeaturesMock,
- autoDevopsEnabled: true,
- });
-
+ createComponent({ autoDevopsEnabled: true });
findAutoDevopsEnabledAlert().vm.$emit('dismiss');
});
@@ -375,7 +330,6 @@ describe('App component', () => {
describe('given at least one unavailable feature', () => {
beforeEach(() => {
createComponent({
- augmentedSecurityFeatures: securityFeaturesMock,
augmentedComplianceFeatures: complianceFeaturesMock.map(makeAvailable(false)),
});
});
@@ -396,7 +350,6 @@ describe('App component', () => {
describe('given at least one unavailable feature, but banner is already dismissed', () => {
beforeEach(() => {
createComponent({
- augmentedSecurityFeatures: securityFeaturesMock,
augmentedComplianceFeatures: complianceFeaturesMock.map(makeAvailable(false)),
shouldShowCallout: false,
});
@@ -423,11 +376,7 @@ describe('App component', () => {
describe('when given latestPipelinePath props', () => {
beforeEach(() => {
- createComponent({
- augmentedSecurityFeatures: securityFeaturesMock,
- augmentedComplianceFeatures: complianceFeaturesMock,
- latestPipelinePath: 'test/path',
- });
+ createComponent({ latestPipelinePath: 'test/path' });
});
it('should show latest pipeline info on the security tab with correct link when latestPipelinePath is defined', () => {
@@ -452,8 +401,6 @@ describe('App component', () => {
describe('given gitlabCiPresent & gitlabCiHistoryPath props', () => {
beforeEach(() => {
createComponent({
- augmentedSecurityFeatures: securityFeaturesMock,
- augmentedComplianceFeatures: complianceFeaturesMock,
gitlabCiPresent: true,
gitlabCiHistoryPath,
});
@@ -468,48 +415,36 @@ describe('App component', () => {
});
});
- describe('Vulnerability management', () => {
- beforeEach(async () => {
- createComponent({
- augmentedSecurityFeatures: securityFeaturesMock,
- augmentedComplianceFeatures: complianceFeaturesMock,
- });
- await waitForPromises();
- });
+ describe('Vulnerability management tab', () => {
+ it('does not show tab if security training is disabled', () => {
+ createComponent({ securityTrainingEnabled: false });
- it('renders TrainingProviderList component', () => {
- expect(findTrainingProviderList().exists()).toBe(true);
+ expect(findVulnerabilityManagementTab().exists()).toBe(false);
});
- it('renders security training description', () => {
- expect(findVulnerabilityManagementTab().text()).toContain(i18n.securityTrainingDescription);
- });
+ describe('security training enabled', () => {
+ beforeEach(() => {
+ createComponent();
+ });
- it('renders link to help docs', () => {
- const trainingLink = findVulnerabilityManagementTab().findComponent(GlLink);
+ it('shows the tab if security training is enabled', () => {
+ expect(findVulnerabilityManagementTab().exists()).toBe(true);
+ });
- expect(trainingLink.text()).toBe('Learn more about vulnerability training');
- expect(trainingLink.attributes('href')).toBe(vulnerabilityTrainingDocsPath);
- });
+ it('renders TrainingProviderList component', () => {
+ expect(findTrainingProviderList().exists()).toBe(true);
+ });
- it.each`
- licenseQueryResponse | display
- ${LICENSE_ULTIMATE} | ${true}
- ${LICENSE_PREMIUM} | ${false}
- ${LICENSE_FREE} | ${false}
- ${null} | ${true}
- ${new Error()} | ${true}
- `(
- 'displays $display for license $licenseQueryResponse',
- async ({ licenseQueryResponse, display }) => {
- createComponent({
- licenseQueryResponse,
- augmentedSecurityFeatures: securityFeaturesMock,
- augmentedComplianceFeatures: complianceFeaturesMock,
- });
- await waitForPromises();
- expect(findVulnerabilityManagementTab().exists()).toBe(display);
- },
- );
+ it('renders security training description', () => {
+ expect(findVulnerabilityManagementTab().text()).toContain(i18n.securityTrainingDescription);
+ });
+
+ it('renders link to help docs', () => {
+ const trainingLink = findVulnerabilityManagementTab().findComponent(GlLink);
+
+ expect(trainingLink.text()).toBe('Learn more about vulnerability training');
+ expect(trainingLink.attributes('href')).toBe(vulnerabilityTrainingDocsPath);
+ });
+ });
});
});
diff --git a/spec/frontend/security_configuration/mock_data.js b/spec/frontend/security_configuration/mock_data.js
index 94a36472a1d..18a480bf082 100644
--- a/spec/frontend/security_configuration/mock_data.js
+++ b/spec/frontend/security_configuration/mock_data.js
@@ -111,12 +111,3 @@ export const tempProviderLogos = {
svg: `<svg>${[testProviderName[1]]}</svg>`,
},
};
-
-export const getCurrentLicensePlanResponse = (plan) => ({
- data: {
- currentLicense: {
- id: 'gid://gitlab/License/1',
- plan,
- },
- },
-});
diff --git a/spec/models/project_spec.rb b/spec/models/project_spec.rb
index 5e4ffeb8455..5cbdba70815 100644
--- a/spec/models/project_spec.rb
+++ b/spec/models/project_spec.rb
@@ -8323,6 +8323,14 @@ RSpec.describe Project, factory_default: :keep do
end
end
+ describe '#security_training_available?' do
+ subject { build(:project) }
+
+ it 'returns false' do
+ expect(subject.security_training_available?).to eq false
+ end
+ end
+
private
def finish_job(export_job)