Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
P
pleroma
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
jeff
pleroma
Commits
54fdce91
Commit
54fdce91
authored
6 years ago
by
kaniini
Browse files
Options
Downloads
Patches
Plain Diff
tests: add tests for CSPPlug
parent
e4bd5a69
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
test/plugs/csp_plug_test.exs
+61
-0
61 additions, 0 deletions
test/plugs/csp_plug_test.exs
with
61 additions
and
0 deletions
test/plugs/csp_plug_test.exs
0 → 100644
+
61
−
0
View file @
54fdce91
defmodule
Pleroma
.
Web
.
Plugs
.
CSPPlugTest
do
use
Pleroma
.
Web
.
ConnCase
alias
Pleroma
.
Config
alias
Plug
.
Conn
test
"it sends CSP headers when enabled"
,
%{
conn:
conn
}
do
Config
.
put
([
:csp
,
:enabled
],
true
)
conn
=
conn
|>
get
(
"/api/v1/instance"
)
refute
Conn
.
get_resp_header
(
conn
,
"x-xss-protection"
)
==
[]
refute
Conn
.
get_resp_header
(
conn
,
"x-permitted-cross-domain-policies"
)
==
[]
refute
Conn
.
get_resp_header
(
conn
,
"x-frame-options"
)
==
[]
refute
Conn
.
get_resp_header
(
conn
,
"x-content-type-options"
)
==
[]
refute
Conn
.
get_resp_header
(
conn
,
"x-download-options"
)
==
[]
refute
Conn
.
get_resp_header
(
conn
,
"referrer-policy"
)
==
[]
refute
Conn
.
get_resp_header
(
conn
,
"content-security-policy"
)
==
[]
end
test
"it does not send CSP headers when disabled"
,
%{
conn:
conn
}
do
Config
.
put
([
:csp
,
:enabled
],
false
)
conn
=
conn
|>
get
(
"/api/v1/instance"
)
assert
Conn
.
get_resp_header
(
conn
,
"x-xss-protection"
)
==
[]
assert
Conn
.
get_resp_header
(
conn
,
"x-permitted-cross-domain-policies"
)
==
[]
assert
Conn
.
get_resp_header
(
conn
,
"x-frame-options"
)
==
[]
assert
Conn
.
get_resp_header
(
conn
,
"x-content-type-options"
)
==
[]
assert
Conn
.
get_resp_header
(
conn
,
"x-download-options"
)
==
[]
assert
Conn
.
get_resp_header
(
conn
,
"referrer-policy"
)
==
[]
assert
Conn
.
get_resp_header
(
conn
,
"content-security-policy"
)
==
[]
end
test
"it sends STS headers when enabled"
,
%{
conn:
conn
}
do
Config
.
put
([
:csp
,
:enabled
],
true
)
Config
.
put
([
:csp
,
:sts
],
true
)
conn
=
conn
|>
get
(
"/api/v1/instance"
)
refute
Conn
.
get_resp_header
(
conn
,
"strict-transport-security"
)
==
[]
refute
Conn
.
get_resp_header
(
conn
,
"expect-ct"
)
==
[]
end
test
"it does not send STS headers when disabled"
,
%{
conn:
conn
}
do
Config
.
put
([
:csp
,
:enabled
],
true
)
Config
.
put
([
:csp
,
:sts
],
false
)
conn
=
conn
|>
get
(
"/api/v1/instance"
)
assert
Conn
.
get_resp_header
(
conn
,
"strict-transport-security"
)
==
[]
assert
Conn
.
get_resp_header
(
conn
,
"expect-ct"
)
==
[]
end
end
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment