Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
See what's new at GitLab
4
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Switch to GitLab Next
Sign in / Register
Toggle navigation
web security map
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
131
Issues
131
List
Boards
Labels
Service Desk
Milestones
Iterations
Merge Requests
2
Merge Requests
2
Requirements
Requirements
List
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Test Cases
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Operations
Operations
Incidents
Environments
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issue
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Internet Cleanup Foundation
web security map
Commits
7e29bd92
Verified
Commit
7e29bd92
authored
Oct 30, 2017
by
Johan Bloemberg
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add integration test suite for security headers scanner command.
parent
a7b0a69a
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
77 additions
and
0 deletions
+77
-0
tests/scanners/integration/conftest.py
tests/scanners/integration/conftest.py
+26
-0
tests/scanners/integration/test_security_headers.py
tests/scanners/integration/test_security_headers.py
+51
-0
No files found.
tests/scanners/integration/conftest.py
0 → 100644
View file @
7e29bd92
"""Shared fixtures used by different tests."""
import
pytest
from
failmap_admin.organizations.models
import
Organization
,
Url
from
failmap_admin.scanners.models
import
Endpoint
@
pytest
.
fixture
def
faalonië
():
"""A testing organization complete with URL's and endpoints."""
faalonië
=
Organization
(
name
=
'faalonië'
)
faalonië
.
save
()
url
=
Url
(
url
=
'www.faalonie.test'
)
url
.
save
()
url
.
organization
.
add
(
faalonië
)
endpoint
=
Endpoint
(
ip
=
'127.0.0.1'
,
protocol
=
'https'
,
url
=
url
)
endpoint
.
save
()
return
{
'organization'
:
faalonië
,
'url'
:
url
,
'endpoint'
:
endpoint
,
}
tests/scanners/integration/test_security_headers.py
0 → 100644
View file @
7e29bd92
"""Integration tests of scanner commands."""
import
json
import
os
import
pytest
from
django.core.management
import
call_command
SECURITY_HEADERS
=
{
'X-XSS-Protection'
:
'1'
,
}
TEST_ORGANIZATION
=
'faalonië'
NON_EXISTING_ORGANIZATION
=
'faaloniet'
def
test_security_headers
(
responses
,
db
,
faalonië
):
"""Test running security headers scan."""
responses
.
add
(
responses
.
GET
,
'https://'
+
faalonië
[
'url'
].
url
+
':443/'
,
headers
=
SECURITY_HEADERS
)
result
=
json
.
loads
(
call_command
(
'scan-security-headers'
,
'-v3'
,
'-o'
,
TEST_ORGANIZATION
))
assert
result
[
0
][
'status'
]
==
'success'
def
test_security_headers_all
(
responses
,
db
,
faalonië
):
"""Test defaulting to all organizations."""
responses
.
add
(
responses
.
GET
,
'https://'
+
faalonië
[
'url'
].
url
+
':443/'
,
headers
=
SECURITY_HEADERS
)
result
=
json
.
loads
(
call_command
(
'scan-security-headers'
,
'-v3'
))
assert
result
[
0
][
'status'
]
==
'success'
def
test_security_headers_notfound
(
responses
,
db
,
faalonië
):
"""Test invalid organization."""
with
pytest
.
raises
(
Exception
):
call_command
(
'scan-security-headers'
,
'-v3'
,
'-o'
,
NON_EXISTING_ORGANIZATION
)
def
test_security_headers
(
responses
,
db
,
faalonië
):
"""Test with failing endpoint."""
responses
.
add
(
responses
.
GET
,
'https://'
+
faalonië
[
'url'
].
url
+
':443/'
,
status
=
500
)
result
=
json
.
loads
(
call_command
(
'scan-security-headers'
,
'-v3'
,
'-o'
,
TEST_ORGANIZATION
))
assert
result
[
0
][
'cause'
][
'error'
]
==
'HTTPError'
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