Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
632b0878
Commit
632b0878
authored
Jan 13, 2022
by
Samantha Ming
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Hide training section in vulnerability details
Issue:
https://gitlab.com/gitlab-org/gitlab/-/issues/349608
parent
da120cce
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
59 additions
and
12 deletions
+59
-12
ee/app/assets/javascripts/security_dashboard/graphql/provider.js
...assets/javascripts/security_dashboard/graphql/provider.js
+4
-1
ee/app/assets/javascripts/vulnerabilities/components/vulnerability_training.vue
...pts/vulnerabilities/components/vulnerability_training.vue
+16
-1
ee/spec/frontend/vulnerabilities/vulnerability_training_spec.js
...c/frontend/vulnerabilities/vulnerability_training_spec.js
+39
-10
No files found.
ee/app/assets/javascripts/security_dashboard/graphql/provider.js
View file @
632b0878
...
...
@@ -3,6 +3,7 @@ import Vue from 'vue';
import
VueApollo
from
'
vue-apollo
'
;
import
createDefaultClient
from
'
~/lib/graphql
'
;
import
{
vulnerabilityLocationTypes
}
from
'
~/graphql_shared/fragment_types/vulnerability_location_types
'
;
import
tempResolvers
from
'
~/security_configuration/resolver
'
;
Vue
.
use
(
VueApollo
);
...
...
@@ -13,7 +14,9 @@ const fragmentMatcher = new IntrospectionFragmentMatcher({
});
const
defaultClient
=
createDefaultClient
(
{},
{
...
tempResolvers
,
},
{
cacheConfig
:
{
fragmentMatcher
,
...
...
ee/app/assets/javascripts/vulnerabilities/components/vulnerability_training.vue
View file @
632b0878
<
script
>
import
{
s__
}
from
'
~/locale
'
;
import
securityTrainingProvidersQuery
from
'
~/security_configuration/graphql/security_training_providers.query.graphql
'
;
import
glFeatureFlagsMixin
from
'
~/vue_shared/mixins/gl_feature_flags_mixin
'
;
import
{
SUPPORTED_REFERENCE_SCHEMA
}
from
'
../constants
'
;
...
...
@@ -20,9 +21,23 @@ export default {
required
:
true
,
},
},
apollo
:
{
securityTrainingProviders
:
{
query
:
securityTrainingProvidersQuery
,
},
},
data
()
{
return
{
securityTrainingProviders
:
[],
};
},
computed
:
{
hasTraining
()
{
return
this
.
glFeatures
.
secureVulnerabilityTraining
&&
this
.
identifiers
?.
length
;
return
(
this
.
glFeatures
.
secureVulnerabilityTraining
&&
this
.
securityTrainingProviders
?.
length
&&
this
.
identifiers
?.
length
);
},
isSupportedReferenceSchema
()
{
return
this
.
referenceSchemas
?.
some
(
...
...
ee/spec/frontend/vulnerabilities/vulnerability_training_spec.js
View file @
632b0878
import
Vue
from
'
vue
'
;
import
VueApollo
from
'
vue-apollo
'
;
import
VulnerabilityTraining
,
{
i18n
,
}
from
'
ee/vulnerabilities/components/vulnerability_training.vue
'
;
import
{
shallowMountExtended
}
from
'
helpers/vue_test_utils_helper
'
;
import
{
SUPPORTED_REFERENCE_SCHEMA
}
from
'
ee/vulnerabilities/constants
'
;
import
createMockApollo
from
'
helpers/mock_apollo_helper
'
;
import
waitForPromises
from
'
helpers/wait_for_promises
'
;
import
{
createMockResolvers
}
from
'
jest/security_configuration/mock_data
'
;
const
defaultProps
=
{
identifiers
:
[{
externalType
:
SUPPORTED_REFERENCE_SCHEMA
.
cwe
},
{
externalType
:
'
cve
'
}],
};
Vue
.
use
(
VueApollo
);
describe
(
'
VulnerabilityTraining component
'
,
()
=>
{
let
wrapper
;
let
apolloProvider
;
const
createApolloProvider
=
({
resolvers
}
=
{})
=>
{
apolloProvider
=
createMockApollo
([],
createMockResolvers
({
resolvers
}));
};
const
createComponent
=
(
props
=
{},
{
secureVulnerabilityTraining
=
true
}
=
{})
=>
{
wrapper
=
shallowMountExtended
(
VulnerabilityTraining
,
{
...
...
@@ -17,6 +29,7 @@ describe('VulnerabilityTraining component', () => {
...
defaultProps
,
...
props
,
},
apolloProvider
,
provide
:
{
glFeatures
:
{
secureVulnerabilityTraining
,
...
...
@@ -25,10 +38,16 @@ describe('VulnerabilityTraining component', () => {
});
};
beforeEach
(
async
()
=>
{
createApolloProvider
();
});
afterEach
(()
=>
{
wrapper
.
destroy
();
apolloProvider
=
null
;
});
const
waitForQueryToBeLoaded
=
()
=>
waitForPromises
();
const
findTitle
=
()
=>
wrapper
.
findByRole
(
'
heading
'
,
i18n
.
trainingTitle
);
const
findDescription
=
()
=>
wrapper
.
findByTestId
(
'
description
'
);
const
findUnavailableMessage
=
()
=>
wrapper
.
findByTestId
(
'
unavailable-message
'
);
...
...
@@ -38,11 +57,13 @@ describe('VulnerabilityTraining component', () => {
createComponent
();
});
it
(
'
displays the title
'
,
()
=>
{
it
(
'
displays the title
'
,
async
()
=>
{
await
waitForQueryToBeLoaded
();
expect
(
findTitle
().
text
()).
toBe
(
i18n
.
trainingTitle
);
});
it
(
'
displays the description
'
,
()
=>
{
it
(
'
displays the description
'
,
async
()
=>
{
await
waitForQueryToBeLoaded
();
expect
(
findDescription
().
text
()).
toBe
(
i18n
.
trainingDescription
);
});
...
...
@@ -50,21 +71,29 @@ describe('VulnerabilityTraining component', () => {
createComponent
({
identifiers
:
[]
});
expect
(
wrapper
.
html
()).
toBeFalsy
();
});
it
(
'
does not render component when there are no securityTrainingProviders
'
,
()
=>
{
expect
(
wrapper
.
html
()).
toBeFalsy
();
});
});
describe
(
'
training availability message
'
,
()
=>
{
it
(
'
displays the message
'
,
()
=>
{
createComponent
({
identifiers
:
[{
externalType
:
'
not supported identifier
'
}]
});
it
(
'
displays the message
'
,
async
()
=>
{
createComponent
({
identifiers
:
[{
externalType
:
'
not supported identifier
'
}],
});
await
waitForQueryToBeLoaded
();
expect
(
findUnavailableMessage
().
text
()).
toBe
(
i18n
.
trainingUnavailable
);
});
it
.
each
`
identifiers | exists
${[{
externalType
:
'
cve
'
}]}
|
${
true
}
${[{
externalType
:
SUPPORTED_REFERENCE_SCHEMA
.
cwe
.
toUpperCase
()
}]}
|
${
false
}
${[{
externalType
:
SUPPORTED_REFERENCE_SCHEMA
.
cwe
.
toLowerCase
()
}]}
|
${
false
}
`
(
'
sets it to "$exists" for "$identifiers"
'
,
({
identifiers
,
exists
})
=>
{
createComponent
({
identifiers
});
identifier | exists
${
'
not supported identifier
'
}
|
${
true
}
${
SUPPORTED_REFERENCE_SCHEMA
.
cwe
.
toUpperCase
()}
|
${
false
}
${
SUPPORTED_REFERENCE_SCHEMA
.
cwe
.
toLowerCase
()}
|
${
false
}
`
(
'
sets it to "$exists" for "$identifier"
'
,
async
({
identifier
,
exists
})
=>
{
createComponent
({
identifiers
:
[{
externalType
:
identifier
}]
});
await
waitForQueryToBeLoaded
();
expect
(
findUnavailableMessage
().
exists
()).
toBe
(
exists
);
});
});
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment