Page Menu
Home
Sealhub
Search
Configure Global Search
Log In
Files
F996319
finalize-registration-intent.subtest.ts
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
1 KB
Referenced Files
None
Subscribers
None
finalize-registration-intent.subtest.ts
View Options
import
*
as
assert
from
"assert"
;
import
{
withProdApp
}
from
"../../test_utils/with-prod-app"
;
describe
(
"finalize registration"
,
()
=>
{
it
(
"allows to register an account (entire flow)"
,
async
()
=>
withProdApp
(
async
({
app
,
mail_api
,
rest_api
})
=>
{
app
.
ConfigManager
.
set
(
"roles"
,
[
"admin"
]);
await
rest_api
.
post
(
"/api/v1/collections/registration-intents"
,
{
email
:
"user@example.com"
,
role
:
"admin"
,
});
const
message_metadata
=
(
await
mail_api
.
getMessages
()).
filter
(
(
message
)
=>
message
.
recipients
[
0
]
==
"<user@example.com>"
)[
0
];
assert
.
ok
(
message_metadata
?
.
subject
);
const
message
=
await
mail_api
.
getMessageById
(
message_metadata
.
id
);
const
match_result
=
/token=([^?&]+)/
.
exec
(
message
);
if
(
!
match_result
)
{
throw
new
Error
(
"Didn't find a token"
);
}
const
token
=
match_result
[
1
];
await
rest_api
.
post
(
"/finalize-registration-intent"
,
{
email
:
"user@example.com"
,
token
,
password
:
"password"
,
username
:
"user"
,
});
const
options
=
await
rest_api
.
login
({
username
:
"user"
,
password
:
"password"
,
});
const
response
=
await
rest_api
.
get
(
"/api/v1/collections/users/me?attachments[roles]=true"
,
options
);
assert
.
equal
(
response
.
items
[
0
].
roles
.
length
,
1
);
assert
.
equal
(
response
.
attachments
[
response
.
items
[
0
].
roles
[
0
]].
role
,
"admin"
);
}));
});
File Metadata
Details
Attached
Mime Type
text/x-java
Expires
Tue, Dec 24, 14:02 (16 h, 42 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
557177
Default Alt Text
finalize-registration-intent.subtest.ts (1 KB)
Attached To
Mode
rREWRITE Configurable rewriter
Attached
Detach File
Event Timeline
Log In to Comment