Skip to content

Commit 0622874

Browse files
Update OAuth and User tests to store authtoken after successful login
1 parent 65ded8c commit 0622874

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

test/sanity-check/api/oauth-test.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ const oauthClient = client.oauth({
2424
describe('OAuth Authentication API Test', () => {
2525
it('should login with credentials', done => {
2626
client.login({ email: process.env.EMAIL, password: process.env.PASSWORD }, { include_orgs: true, include_orgs_roles: true, include_stack_roles: true, include_user_settings: true }).then((response) => {
27+
authtoken = response.user.authtoken
2728
expect(response.notice).to.be.equal('Login Successful.', 'Login success messsage does not match.')
2829
done()
2930
})
@@ -32,7 +33,7 @@ describe('OAuth Authentication API Test', () => {
3233

3334
it('should get Current user info test', done => {
3435
client.getUser().then((user) => {
35-
authtoken = user.authtoken
36+
expect(user.uid).not.to.be(undefined)
3637
done()
3738
})
3839
.catch(done)

test/sanity-check/api/user-test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ describe('Contentstack User Session api Test', () => {
5050
client.login({ email: process.env.EMAIL, password: process.env.PASSWORD }, { include_orgs: true, include_orgs_roles: true, include_stack_roles: true, include_user_settings: true }).then((response) => {
5151
loggedinUserID = response.user.uid
5252
jsonWrite(response.user, 'loggedinuser.json')
53+
authtoken = response.user.authtoken
5354
expect(response.notice).to.be.equal('Login Successful.', 'Login success messsage does not match.')
5455
done()
5556
})
@@ -58,7 +59,6 @@ describe('Contentstack User Session api Test', () => {
5859

5960
it('should get Current user info test', done => {
6061
client.getUser().then((user) => {
61-
authtoken = user.authtoken
6262
expect(user.uid).to.be.equal(loggedinUserID)
6363
done()
6464
})

0 commit comments

Comments
 (0)