Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
S
swh-web
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
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
Jérémy Bobbio (Lunar)
swh-web
Commits
0c348aa8
Commit
0c348aa8
authored
5 years ago
by
Kalpit Kothari
Browse files
Options
Downloads
Patches
Plain Diff
cypress: Test Admin authentication
parent
d0369f04
No related branches found
Branches containing commit
Tags
debian/upstream/0.0.206
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
cypress/integration/admin.spec.js
+71
-0
71 additions, 0 deletions
cypress/integration/admin.spec.js
with
71 additions
and
0 deletions
cypress/integration/admin.spec.js
0 → 100644
+
71
−
0
View file @
0c348aa8
/**
* Copyright (C) 2019 The Software Heritage developers
* See the AUTHORS file at the top-level directory of this distribution
* License: GNU Affero General Public License version 3, or any later version
* See top-level LICENSE file for more information
*/
const
username
=
'
admin
'
;
const
password
=
'
admin
'
;
const
defaultRedirect
=
'
/admin/origin/save/
'
;
let
url
;
function
login
(
username
,
password
)
{
cy
.
visit
(
url
);
cy
.
get
(
'
input[name="username"]
'
)
.
type
(
username
)
.
get
(
'
input[name="password"]
'
)
.
type
(
password
)
.
get
(
'
form
'
)
.
submit
();
}
function
logout
()
{
cy
.
contains
(
'
a
'
,
'
logout
'
)
.
click
();
}
describe
(
'
Test Admin Features
'
,
function
()
{
before
(
function
()
{
url
=
this
.
Urls
.
admin
();
});
beforeEach
(
function
()
{
login
(
username
,
password
);
});
it
(
'
should redirect to default page
'
,
function
()
{
cy
.
location
(
'
pathname
'
)
.
should
(
'
be.equal
'
,
defaultRedirect
);
logout
();
});
it
(
'
should display admin-origin-save and deposit in sidebar
'
,
function
()
{
cy
.
get
(
`.sidebar a[href="
${
this
.
Urls
.
admin_origin_save
()}
"]`
)
.
should
(
'
be.visible
'
);
cy
.
get
(
`.sidebar a[href="
${
this
.
Urls
.
admin_deposit
()}
"]`
)
.
should
(
'
be.visible
'
);
logout
();
});
it
(
'
should display username on top-right
'
,
function
()
{
cy
.
get
(
'
.swh-position-right
'
)
.
should
(
'
contain
'
,
username
);
logout
();
});
it
(
'
should prevent unauthorized access after logout
'
,
function
()
{
logout
();
cy
.
visit
(
this
.
Urls
.
admin_origin_save
())
.
location
(
'
pathname
'
)
.
should
(
'
be.equal
'
,
'
/admin/login/
'
);
cy
.
visit
(
this
.
Urls
.
admin_deposit
())
.
location
(
'
pathname
'
)
.
should
(
'
be.equal
'
,
'
/admin/login/
'
);
});
});
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