Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
T
texjs-web
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
David Mehren
texjs-web
Commits
46b41187
Commit
46b41187
authored
Sep 11, 2017
by
Shane Kilkelly
Browse files
Options
Downloads
Patches
Plain Diff
add csrf acceptance test
parent
34095bc4
Branches
meta-export
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
test/acceptance/coffee/SessionTests.coffee
+30
-0
30 additions, 0 deletions
test/acceptance/coffee/SessionTests.coffee
test/acceptance/coffee/helpers/User.coffee
+2
-2
2 additions, 2 deletions
test/acceptance/coffee/helpers/User.coffee
with
32 additions
and
2 deletions
test/acceptance/coffee/SessionTests.coffee
+
30
−
0
View file @
46b41187
...
...
@@ -15,6 +15,36 @@ describe "Sessions", ->
(
cb
)
=>
@
user1
.
logout
cb
],
done
describe
"csrf invalidation"
,
->
before
->
@
token
=
null
it
'should not accept csrf token from a previous session'
,
(
done
)
->
async
.
series
(
[
(
cb
)
=>
@
user1
.
login
cb
,
(
cb
)
=>
@
user1
.
getCsrfToken
(
err
,
token
)
=>
@
token
=
token
cb
()
,
(
cb
)
=>
@
user1
.
logout
cb
,
(
cb
)
=>
@
user1
.
login
cb
,
(
cb
)
=>
request
.
post
{
url
:
"/project/new"
,
json
:
projectName
:
"Shouldn't be created"
headers
:
"x-csrf-token"
:
@
token
},
(
error
,
response
,
body
)
->
expect
(
error
).
to
.
not
.
exist
expect
(
response
.
statusCode
).
to
.
equal
403
cb
()
],
(
err
,
result
)
=>
expect
(
err
).
to
.
not
.
exist
done
()
)
describe
"one session"
,
->
it
"should have one session in UserSessions set"
,
(
done
)
->
...
...
This diff is collapsed.
Click to expand it.
test/acceptance/coffee/helpers/User.coffee
+
2
−
2
View file @
46b41187
...
...
@@ -128,7 +128,7 @@ class User
return
callback
(
error
)
if
error
?
callback
(
null
)
getCsrfToken
:
(
callback
=
(
error
)
->
)
->
getCsrfToken
:
(
callback
=
(
error
,
token
)
->
)
->
@
request
.
get
{
url
:
"/register"
},
(
err
,
response
,
body
)
=>
...
...
@@ -140,7 +140,7 @@ class User
headers
:
"x-csrf-token"
:
csrfMatches
[
1
]
})
callback
()
callback
(
null
,
csrfMatches
[
1
]
)
changePassword
:
(
callback
=
(
error
)
->
)
->
@
getCsrfToken
(
error
)
=>
...
...
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