Page Menu
Home
Sealhub
Search
Configure Global Search
Log In
Files
F996611
password.subtest.js
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
1 KB
Referenced Files
None
Subscribers
None
password.subtest.js
View Options
const
assert
=
require
(
"assert"
);
const
locreq
=
require
(
"locreq"
)(
__dirname
);
const
{
with_running_app
}
=
locreq
(
"test_utils/with-test-app.js"
);
const
SecureHasher
=
locreq
(
"lib/utils/secure-hasher.js"
);
describe
(
"password"
,
()
=>
{
const
password
=
"it-really-doesnt-matter"
;
const
username
=
"some-user"
;
let
user_id
;
async
function
setup
(
app
,
rest_api
,
base_url
)
{
user_id
=
(
await
app
.
run_action
(
new
app
.
Sealious
.
SuperContext
(),
[
"collections"
,
"users"
],
"create"
,
{
username
,
password
,
email
:
"some-user@example.com"
,
}
)).
id
;
}
it
(
"Hides password"
,
async
()
=>
with_running_app
(
async
({
app
,
rest_api
,
base_url
})
=>
{
await
setup
(
app
,
rest_api
,
base_url
);
const
session
=
await
rest_api
.
login
({
username
,
password
,
});
assert
.
ok
(
!
(
await
rest_api
.
get
(
`/api/v1/collections/users/
${
user_id
}
`
,
session
)).
password
);
assert
.
ok
(
!
(
await
app
.
run_action
(
new
app
.
Sealious
.
SuperContext
(),
[
"collections"
,
"users"
,
user_id
],
"show"
)).
password
);
}));
it
(
"Stores correct password value"
,
async
()
=>
with_running_app
(
async
({
app
,
rest_api
,
base_url
})
=>
{
await
setup
(
app
,
rest_api
,
base_url
);
const
hashed_password
=
(
await
app
.
Datastore
.
find
(
"users"
,
{
sealious_id
:
user_id
,
}))[
0
].
password
;
assert
.
ok
(
await
SecureHasher
.
matches
(
password
,
hashed_password
));
assert
.
ok
(
!
(
await
SecureHasher
.
matches
(
"wrong-password"
,
hashed_password
))
);
assert
.
ok
(
!
(
await
SecureHasher
.
matches
(
""
,
hashed_password
)));
}));
});
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Tue, Dec 24, 14:05 (34 m, 5 s)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
557341
Default Alt Text
password.subtest.js (1 KB)
Attached To
Mode
rS Sealious
Attached
Detach File
Event Timeline
Log In to Comment