@live-change/db-admin 0.5.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/e2e/codecept.conf.js +60 -0
- package/e2e/connectEmailCode.test.js +61 -0
- package/e2e/connectEmailLink.test.js +60 -0
- package/e2e/delete.test.js +44 -0
- package/e2e/disconnectEmail.test.js +42 -0
- package/e2e/resetPasswordWithEmailCode.test.js +62 -0
- package/e2e/resetPasswordWithEmailLink.test.js +62 -0
- package/e2e/setPassword.test.js +70 -0
- package/e2e/signInEmailCode.test.js +52 -0
- package/e2e/signInEmailLink.test.js +52 -0
- package/e2e/signInEmailPassword.test.js +47 -0
- package/e2e/signOut.test.js +41 -0
- package/e2e/signUpEmailCode.test.js +41 -0
- package/e2e/signUpEmailLink.test.js +41 -0
- package/e2e/steps.d.ts +12 -0
- package/e2e/steps_file.js +85 -0
- package/front/assets/images/empty-photo.svg +38 -0
- package/front/assets/images/empty-user-photo.svg +33 -0
- package/front/assets/images/logo.svg +34 -0
- package/front/index.html +11 -0
- package/front/public/favicon.ico +0 -0
- package/front/public/images/empty-photo.svg +38 -0
- package/front/public/images/empty-user-photo.svg +33 -0
- package/front/public/images/logo.svg +34 -0
- package/front/public/images/logo128.png +0 -0
- package/front/src/App.vue +93 -0
- package/front/src/CodeEditor.vue +92 -0
- package/front/src/Data.vue +74 -0
- package/front/src/DataRangeView.vue +58 -0
- package/front/src/DataView.vue +51 -0
- package/front/src/Database.vue +364 -0
- package/front/src/DatabaseAdmin.vue +135 -0
- package/front/src/Databases.vue +110 -0
- package/front/src/NavBar.vue +105 -0
- package/front/src/ObjectEditor.vue +143 -0
- package/front/src/Page.vue +39 -0
- package/front/src/PathEditor.vue +210 -0
- package/front/src/dbSugar.js +75 -0
- package/front/src/entry-client.js +24 -0
- package/front/src/entry-server.js +59 -0
- package/front/src/isClientSide.js +3 -0
- package/front/src/main.js +61 -0
- package/front/src/path.js +68 -0
- package/front/src/router.js +42 -0
- package/front/src/routes.js +31 -0
- package/front/vite.config.js +107 -0
- package/package.json +71 -0
- package/server/init.js +16 -0
- package/server/services.config.js +4 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2021 Michał Łaszczewski
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
const { devices } = require('playwright');
|
|
2
|
+
|
|
3
|
+
const testServerPort = process.env.TEST_URL ? 0 : require('get-port-sync')()
|
|
4
|
+
const testServerUrl = process.env.TEST_URL || `http://localhost:${testServerPort}`
|
|
5
|
+
|
|
6
|
+
const device = devices['Pixel 2']
|
|
7
|
+
|
|
8
|
+
exports.config = {
|
|
9
|
+
tests: './*.test.js',
|
|
10
|
+
output: './output',
|
|
11
|
+
helpers: {
|
|
12
|
+
LiveChange: {
|
|
13
|
+
require: '@live-change/codeceptjs-helper',
|
|
14
|
+
startServer: !process.env.TEST_URL,
|
|
15
|
+
enableSessions: true,
|
|
16
|
+
initScript: "./init.js",
|
|
17
|
+
port: testServerPort,
|
|
18
|
+
dev: true
|
|
19
|
+
},
|
|
20
|
+
VideoHelper: {
|
|
21
|
+
require: 'codeceptjs-video-helper'
|
|
22
|
+
},
|
|
23
|
+
AssertWrapper : {
|
|
24
|
+
require: "codeceptjs-assert"
|
|
25
|
+
},
|
|
26
|
+
Playwright: {
|
|
27
|
+
browser: 'chromium',
|
|
28
|
+
url: testServerUrl,
|
|
29
|
+
show: true,
|
|
30
|
+
emulate: {
|
|
31
|
+
...device,
|
|
32
|
+
recordVideo: process.env.RECORD_TESTS ? {
|
|
33
|
+
dir: "./output",
|
|
34
|
+
//size: { width: 1080, height: 1920 }
|
|
35
|
+
} : undefined,
|
|
36
|
+
},
|
|
37
|
+
chromium: {
|
|
38
|
+
args: [`--force-device-scale-factor=${device.deviceScaleFactor}`]
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
},
|
|
42
|
+
include: {
|
|
43
|
+
I: './steps_file.js'
|
|
44
|
+
},
|
|
45
|
+
bootstrap: null,
|
|
46
|
+
mocha: {},
|
|
47
|
+
name: 'e2e',
|
|
48
|
+
plugins: {
|
|
49
|
+
pauseOnFail: {},
|
|
50
|
+
retryFailedStep: {
|
|
51
|
+
enabled: true
|
|
52
|
+
},
|
|
53
|
+
tryTo: {
|
|
54
|
+
enabled: true
|
|
55
|
+
},
|
|
56
|
+
screenshotOnFail: {
|
|
57
|
+
enabled: true
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
const app = require('@live-change/framework').app()
|
|
2
|
+
const randomProfile = require('random-profile-generator')
|
|
3
|
+
|
|
4
|
+
const email = randomProfile.profile().firstName.toLowerCase() + '@test.com' // test domain - emails not sent
|
|
5
|
+
const email2 = randomProfile.profile().firstName.toLowerCase() + '2@test.com' // test domain - emails not sent
|
|
6
|
+
|
|
7
|
+
const happyPath = false
|
|
8
|
+
|
|
9
|
+
Feature('user')
|
|
10
|
+
|
|
11
|
+
Scenario('connect email with code', async ({ I }) => {
|
|
12
|
+
|
|
13
|
+
const user = app.generateUid()
|
|
14
|
+
|
|
15
|
+
const User = await I.haveModel('user', 'User')
|
|
16
|
+
const Email = await I.haveModel('email', 'Email')
|
|
17
|
+
const AuthenticatedUser = await I.haveModel('user', 'AuthenticatedUser')
|
|
18
|
+
|
|
19
|
+
await User.create({ id: user, roles: [] })
|
|
20
|
+
await Email.create({ id: email, email, user })
|
|
21
|
+
I.amOnPage('/')
|
|
22
|
+
const session = await I.executeScript(() => api.client.value.session)
|
|
23
|
+
await AuthenticatedUser.create({ id: session, user, session })
|
|
24
|
+
|
|
25
|
+
I.amOnPage('/connected')
|
|
26
|
+
I.see(email)
|
|
27
|
+
I.dontSee(email2)
|
|
28
|
+
|
|
29
|
+
I.click('button#connect')
|
|
30
|
+
|
|
31
|
+
I.seeInCurrentUrl('/connect')
|
|
32
|
+
|
|
33
|
+
if(!happyPath) {
|
|
34
|
+
I.fillField('input#email', email)
|
|
35
|
+
I.click('button[type=submit]')
|
|
36
|
+
I.seeInCurrentUrl('/connect')
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
I.fillField('input#email', email2)
|
|
40
|
+
I.click('button[type=submit]')
|
|
41
|
+
|
|
42
|
+
I.seeInCurrentUrl('/sent/')
|
|
43
|
+
|
|
44
|
+
const url = await I.grabCurrentUrl()
|
|
45
|
+
const authentication = url.split('/').pop()
|
|
46
|
+
|
|
47
|
+
const authenticationData = await I.grabObject('messageAuthentication', 'Authentication', authentication)
|
|
48
|
+
console.log("AUTHENTICATION DATA", authenticationData)
|
|
49
|
+
I.assert(!!authenticationData, true, 'authentication created')
|
|
50
|
+
I.assert(authenticationData?.messageData?.user, user, 'authentication contains user')
|
|
51
|
+
|
|
52
|
+
await I.useSecretCode(authentication, happyPath)
|
|
53
|
+
|
|
54
|
+
I.seeInCurrentUrl('/connect-finished')
|
|
55
|
+
|
|
56
|
+
if(!happyPath) {
|
|
57
|
+
I.amOnPage(url)
|
|
58
|
+
I.seeInCurrentUrl('/connect-finished')
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
})
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
const app = require('@live-change/framework').app()
|
|
2
|
+
const randomProfile = require('random-profile-generator')
|
|
3
|
+
|
|
4
|
+
const email = randomProfile.profile().firstName.toLowerCase() + '@test.com' // test domain - emails not sent
|
|
5
|
+
const email2 = randomProfile.profile().firstName.toLowerCase() + '2@test.com' // test domain - emails not sent
|
|
6
|
+
|
|
7
|
+
const happyPath = false
|
|
8
|
+
|
|
9
|
+
Feature('user')
|
|
10
|
+
|
|
11
|
+
Scenario('sign in with email link', async ({ I }) => {
|
|
12
|
+
|
|
13
|
+
const user = app.generateUid()
|
|
14
|
+
|
|
15
|
+
const User = await I.haveModel('user', 'User')
|
|
16
|
+
const Email = await I.haveModel('email', 'Email')
|
|
17
|
+
const AuthenticatedUser = await I.haveModel('user', 'AuthenticatedUser')
|
|
18
|
+
|
|
19
|
+
await User.create({ id: user, roles: [] })
|
|
20
|
+
await Email.create({ id: email, email, user })
|
|
21
|
+
I.amOnPage('/')
|
|
22
|
+
const session = await I.executeScript(() => api.client.value.session)
|
|
23
|
+
await AuthenticatedUser.create({ id: session, user, session })
|
|
24
|
+
|
|
25
|
+
I.amOnPage('/connected')
|
|
26
|
+
I.see(email)
|
|
27
|
+
I.dontSee(email2)
|
|
28
|
+
|
|
29
|
+
I.click('button#connect')
|
|
30
|
+
|
|
31
|
+
I.seeInCurrentUrl('/connect')
|
|
32
|
+
|
|
33
|
+
if(!happyPath) {
|
|
34
|
+
I.fillField('input#email', email)
|
|
35
|
+
I.click('button[type=submit]')
|
|
36
|
+
I.see('')
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
I.fillField('input#email', email2)
|
|
40
|
+
I.click('button[type=submit]')
|
|
41
|
+
|
|
42
|
+
I.seeInCurrentUrl('/sent/')
|
|
43
|
+
const url = await I.grabCurrentUrl()
|
|
44
|
+
const authentication = url.split('/').pop()
|
|
45
|
+
|
|
46
|
+
const authenticationData = await I.grabObject('messageAuthentication', 'Authentication', authentication)
|
|
47
|
+
console.log("AUTHENTICATION DATA", authenticationData)
|
|
48
|
+
I.assert(!!authenticationData, true, 'authentication created')
|
|
49
|
+
I.assert(authenticationData?.messageData?.user, user, 'authentication contains user')
|
|
50
|
+
|
|
51
|
+
const linkData = await I.useSecretLink(authentication, happyPath)
|
|
52
|
+
|
|
53
|
+
I.seeInCurrentUrl('/connect-finished')
|
|
54
|
+
|
|
55
|
+
if(!happyPath) {
|
|
56
|
+
I.amOnPage('/link/' + linkData.secretCode)
|
|
57
|
+
I.see('Link used')
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
})
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
const app = require('@live-change/framework').app()
|
|
2
|
+
const randomProfile = require('random-profile-generator')
|
|
3
|
+
|
|
4
|
+
const name = randomProfile.profile().firstName.toLowerCase()
|
|
5
|
+
const email = name + '@test.com' // test domain - emails not sent
|
|
6
|
+
|
|
7
|
+
const happyPath = false
|
|
8
|
+
|
|
9
|
+
Feature('user')
|
|
10
|
+
|
|
11
|
+
Scenario('delete account', async ({ I }) => {
|
|
12
|
+
|
|
13
|
+
const user = app.generateUid()
|
|
14
|
+
|
|
15
|
+
const User = await I.haveModel('user', 'User')
|
|
16
|
+
const Email = await I.haveModel('email', 'Email')
|
|
17
|
+
const AuthenticatedUser = await I.haveModel('user', 'AuthenticatedUser')
|
|
18
|
+
|
|
19
|
+
await User.create({ id: user, roles: [] })
|
|
20
|
+
await Email.create({ id: email, email, user })
|
|
21
|
+
I.amOnPage('/')
|
|
22
|
+
const session = await I.executeScript(() => api.client.value.session)
|
|
23
|
+
await AuthenticatedUser.create({ id: session, user, session })
|
|
24
|
+
|
|
25
|
+
await I.wait(0.2)
|
|
26
|
+
const clientUser = await I.executeScript(() => api.client.value.user)
|
|
27
|
+
I.assert(user, clientUser, 'client logged in')
|
|
28
|
+
|
|
29
|
+
I.amOnPage('/delete')
|
|
30
|
+
I.click('.p-checkbox-box')
|
|
31
|
+
I.click('button#delete')
|
|
32
|
+
|
|
33
|
+
I.seeInCurrentUrl('/delete-finished')
|
|
34
|
+
|
|
35
|
+
await I.wait(0.3)
|
|
36
|
+
const clientUserAfterDelete = await I.executeScript(() => api.client.value.user)
|
|
37
|
+
I.assert(!!clientUserAfterDelete, false, 'user logged out')
|
|
38
|
+
|
|
39
|
+
const deletedUser = await User.get(user)
|
|
40
|
+
I.assert(!!deletedUser, false, 'user deleted')
|
|
41
|
+
|
|
42
|
+
const deletedEmail = await Email.get(email)
|
|
43
|
+
I.assert(!!deletedEmail, false, 'email deleted')
|
|
44
|
+
})
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
const app = require('@live-change/framework').app()
|
|
2
|
+
const randomProfile = require('random-profile-generator')
|
|
3
|
+
|
|
4
|
+
const name = randomProfile.profile().firstName.toLowerCase()
|
|
5
|
+
const email = name + '@test.com' // test domain - emails not sent
|
|
6
|
+
const email2 = name + '2@test.com' // test domain - emails not sent
|
|
7
|
+
|
|
8
|
+
const happyPath = false
|
|
9
|
+
|
|
10
|
+
Feature('user')
|
|
11
|
+
|
|
12
|
+
Scenario('disconnect email', async ({ I }) => {
|
|
13
|
+
|
|
14
|
+
const user = app.generateUid()
|
|
15
|
+
|
|
16
|
+
const User = await I.haveModel('user', 'User')
|
|
17
|
+
const Email = await I.haveModel('email', 'Email')
|
|
18
|
+
const AuthenticatedUser = await I.haveModel('user', 'AuthenticatedUser')
|
|
19
|
+
|
|
20
|
+
await User.create({ id: user, roles: [] })
|
|
21
|
+
await Email.create({ id: email, email, user })
|
|
22
|
+
await Email.create({ id: email2, email: email2, user })
|
|
23
|
+
I.amOnPage('/')
|
|
24
|
+
const session = await I.executeScript(() => api.client.value.session)
|
|
25
|
+
await AuthenticatedUser.create({ id: session, user, session })
|
|
26
|
+
|
|
27
|
+
I.amOnPage('/connected')
|
|
28
|
+
I.see(email)
|
|
29
|
+
I.see(email2)
|
|
30
|
+
|
|
31
|
+
I.click('span.pi-times') // delete button
|
|
32
|
+
I.click('Yes')
|
|
33
|
+
|
|
34
|
+
I.dontSee(email2)
|
|
35
|
+
|
|
36
|
+
if(!happyPath) {
|
|
37
|
+
I.dontSeeElement('span.pi-times') // delete button
|
|
38
|
+
//I.click('Yes')
|
|
39
|
+
//I.see(email)
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
})
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
const app = require('@live-change/framework').app()
|
|
2
|
+
const randomProfile = require('random-profile-generator')
|
|
3
|
+
const passwordGenerator = require('generate-password')
|
|
4
|
+
|
|
5
|
+
const email = randomProfile.profile().firstName.toLowerCase() + '@test.com' // test domain - emails not sent
|
|
6
|
+
const email2 = randomProfile.profile().firstName.toLowerCase() + '2@test.com' // test domain - emails not sent
|
|
7
|
+
|
|
8
|
+
const happyPath = false
|
|
9
|
+
|
|
10
|
+
Feature('user')
|
|
11
|
+
|
|
12
|
+
Scenario('reset password with email code', async ({ I }) => {
|
|
13
|
+
|
|
14
|
+
const user = app.generateUid()
|
|
15
|
+
|
|
16
|
+
const User = await I.haveModel('user', 'User')
|
|
17
|
+
const Email = await I.haveModel('email', 'Email')
|
|
18
|
+
|
|
19
|
+
await User.create({ id: user, roles: [] })
|
|
20
|
+
await Email.create({ id: email, email, user })
|
|
21
|
+
I.amOnPage('/')
|
|
22
|
+
const session = await I.executeScript(() => api.client.value.session)
|
|
23
|
+
|
|
24
|
+
I.amOnPage('/reset-password')
|
|
25
|
+
I.fillField('input#email', email)
|
|
26
|
+
|
|
27
|
+
I.click('button[type=submit]')
|
|
28
|
+
|
|
29
|
+
I.seeInCurrentUrl('/sent')
|
|
30
|
+
let url = await I.grabCurrentUrl()
|
|
31
|
+
const authentication = url.split('/').pop()
|
|
32
|
+
|
|
33
|
+
const authenticationData = await I.grabObject('messageAuthentication', 'Authentication', authentication)
|
|
34
|
+
console.log("AUTHENTICATION DATA", authenticationData)
|
|
35
|
+
I.assert(!!authenticationData, true, 'authentication created')
|
|
36
|
+
I.assert(authenticationData?.messageData?.user, user, 'authentication message data contains user')
|
|
37
|
+
I.assert(authenticationData?.actionProperties?.user, user, 'authentication action properties contains user')
|
|
38
|
+
|
|
39
|
+
await I.useSecretCode(authentication, happyPath)
|
|
40
|
+
|
|
41
|
+
I.seeInCurrentUrl('/set-new-password/')
|
|
42
|
+
url = await I.grabCurrentUrl()
|
|
43
|
+
const resetPasswordAuthentication = url.split('/').pop()
|
|
44
|
+
await I.wait(0.1)
|
|
45
|
+
const ResetPasswordAuthentication = await I.haveModel('passwordAuthentication', 'ResetPasswordAuthentication')
|
|
46
|
+
const resetPasswordAuthenticationData =
|
|
47
|
+
await ResetPasswordAuthentication.indexObjectGet('byKey', resetPasswordAuthentication)
|
|
48
|
+
I.assert(!!resetPasswordAuthenticationData, true, 'reset password authentication created')
|
|
49
|
+
|
|
50
|
+
I.see('Reset password')
|
|
51
|
+
|
|
52
|
+
const password = passwordGenerator.generate({
|
|
53
|
+
length: 10,
|
|
54
|
+
numbers: true
|
|
55
|
+
})+(Math.random()*10).toFixed()
|
|
56
|
+
I.fillField('input#newPassword', password)
|
|
57
|
+
I.fillField('input#reenterPassword', password)
|
|
58
|
+
|
|
59
|
+
I.click('button[type=submit]')
|
|
60
|
+
I.seeInCurrentUrl('/reset-password-finished')
|
|
61
|
+
|
|
62
|
+
})
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
const app = require('@live-change/framework').app()
|
|
2
|
+
const randomProfile = require('random-profile-generator')
|
|
3
|
+
const passwordGenerator = require('generate-password')
|
|
4
|
+
|
|
5
|
+
const email = randomProfile.profile().firstName.toLowerCase() + '@test.com' // test domain - emails not sent
|
|
6
|
+
const email2 = randomProfile.profile().firstName.toLowerCase() + '2@test.com' // test domain - emails not sent
|
|
7
|
+
|
|
8
|
+
const happyPath = false
|
|
9
|
+
|
|
10
|
+
Feature('user')
|
|
11
|
+
|
|
12
|
+
Scenario('reset password with email code', async ({ I }) => {
|
|
13
|
+
|
|
14
|
+
const user = app.generateUid()
|
|
15
|
+
|
|
16
|
+
const User = await I.haveModel('user', 'User')
|
|
17
|
+
const Email = await I.haveModel('email', 'Email')
|
|
18
|
+
|
|
19
|
+
await User.create({ id: user, roles: [] })
|
|
20
|
+
await Email.create({ id: email, email, user })
|
|
21
|
+
I.amOnPage('/')
|
|
22
|
+
const session = await I.executeScript(() => api.client.value.session)
|
|
23
|
+
|
|
24
|
+
I.amOnPage('/reset-password')
|
|
25
|
+
I.fillField('input#email', email)
|
|
26
|
+
|
|
27
|
+
I.click('button[type=submit]')
|
|
28
|
+
|
|
29
|
+
I.seeInCurrentUrl('/sent')
|
|
30
|
+
let url = await I.grabCurrentUrl()
|
|
31
|
+
const authentication = url.split('/').pop()
|
|
32
|
+
|
|
33
|
+
const authenticationData = await I.grabObject('messageAuthentication', 'Authentication', authentication)
|
|
34
|
+
console.log("AUTHENTICATION DATA", authenticationData)
|
|
35
|
+
I.assert(!!authenticationData, true, 'authentication created')
|
|
36
|
+
I.assert(authenticationData?.messageData?.user, user, 'authentication message data contains user')
|
|
37
|
+
I.assert(authenticationData?.actionProperties?.user, user, 'authentication action properties contains user')
|
|
38
|
+
|
|
39
|
+
await I.useSecretLink(authentication, happyPath)
|
|
40
|
+
|
|
41
|
+
I.seeInCurrentUrl('/set-new-password/')
|
|
42
|
+
url = await I.grabCurrentUrl()
|
|
43
|
+
const resetPasswordAuthentication = url.split('/').pop()
|
|
44
|
+
await I.wait(0.1)
|
|
45
|
+
const ResetPasswordAuthentication = await I.haveModel('passwordAuthentication', 'ResetPasswordAuthentication')
|
|
46
|
+
const resetPasswordAuthenticationData =
|
|
47
|
+
await ResetPasswordAuthentication.indexObjectGet('byKey', resetPasswordAuthentication)
|
|
48
|
+
I.assert(!!resetPasswordAuthenticationData, true, 'reset password authentication created')
|
|
49
|
+
|
|
50
|
+
I.see('Reset password')
|
|
51
|
+
|
|
52
|
+
const password = passwordGenerator.generate({
|
|
53
|
+
length: 10,
|
|
54
|
+
numbers: true
|
|
55
|
+
})+(Math.random()*10).toFixed()
|
|
56
|
+
I.fillField('input#newPassword', password)
|
|
57
|
+
I.fillField('input#reenterPassword', password)
|
|
58
|
+
I.click('button[type=submit]')
|
|
59
|
+
|
|
60
|
+
I.seeInCurrentUrl('/reset-password-finished')
|
|
61
|
+
|
|
62
|
+
})
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
const app = require('@live-change/framework').app()
|
|
2
|
+
const randomProfile = require('random-profile-generator')
|
|
3
|
+
const passwordGenerator = require('generate-password')
|
|
4
|
+
|
|
5
|
+
const name = randomProfile.profile().firstName.toLowerCase()
|
|
6
|
+
const email = name + '@test.com' // test domain - emails not sent
|
|
7
|
+
|
|
8
|
+
const happyPath = false
|
|
9
|
+
|
|
10
|
+
Feature('user')
|
|
11
|
+
|
|
12
|
+
Scenario('setPassword', async ({ I }) => {
|
|
13
|
+
|
|
14
|
+
const user = app.generateUid()
|
|
15
|
+
|
|
16
|
+
const User = await I.haveModel('user', 'User')
|
|
17
|
+
const Email = await I.haveModel('email', 'Email')
|
|
18
|
+
const AuthenticatedUser = await I.haveModel('user', 'AuthenticatedUser')
|
|
19
|
+
const PasswordAuthentication = await I.haveModel('passwordAuthentication', 'PasswordAuthentication')
|
|
20
|
+
|
|
21
|
+
await User.create({ id: user, roles: [] })
|
|
22
|
+
await Email.create({ id: email, email, user })
|
|
23
|
+
I.amOnPage('/')
|
|
24
|
+
const session = await I.executeScript(() => api.client.value.session)
|
|
25
|
+
await AuthenticatedUser.create({ id: session, user, session })
|
|
26
|
+
|
|
27
|
+
await I.wait(0.2)
|
|
28
|
+
const clientUser = await I.executeScript(() => api.client.value.user)
|
|
29
|
+
I.assert(user, clientUser, 'client logged in')
|
|
30
|
+
|
|
31
|
+
const emptyPasswordAuthenticationData = await PasswordAuthentication.get(user)
|
|
32
|
+
I.assert(emptyPasswordAuthenticationData, null, 'password not set')
|
|
33
|
+
|
|
34
|
+
I.amOnPage('/change-password')
|
|
35
|
+
I.see('Set password')
|
|
36
|
+
|
|
37
|
+
const firstPassword = passwordGenerator.generate({
|
|
38
|
+
length: 10,
|
|
39
|
+
numbers: true
|
|
40
|
+
})+(Math.random()*10).toFixed()
|
|
41
|
+
I.fillField('input#newPassword', firstPassword)
|
|
42
|
+
I.fillField('input#reenterPassword', firstPassword)
|
|
43
|
+
I.click('button[type=submit]')
|
|
44
|
+
|
|
45
|
+
I.seeInCurrentUrl('/change-password-finished')
|
|
46
|
+
|
|
47
|
+
await I.wait(0.2)
|
|
48
|
+
const firstPasswordAuthenticationData = await PasswordAuthentication.get(user)
|
|
49
|
+
I.assert(!!firstPasswordAuthenticationData, true, 'password set')
|
|
50
|
+
|
|
51
|
+
I.amOnPage('/change-password')
|
|
52
|
+
I.see('Change password')
|
|
53
|
+
|
|
54
|
+
const secondPassword = passwordGenerator.generate({
|
|
55
|
+
length: 10,
|
|
56
|
+
numbers: true
|
|
57
|
+
})+(Math.random()*10).toFixed()
|
|
58
|
+
|
|
59
|
+
I.fillField('input#currentPassword', firstPassword)
|
|
60
|
+
I.fillField('input#newPassword', secondPassword)
|
|
61
|
+
I.fillField('input#reenterPassword', secondPassword)
|
|
62
|
+
I.click('button[type=submit]')
|
|
63
|
+
|
|
64
|
+
await I.wait(0.2)
|
|
65
|
+
const secondPasswordAuthenticationData = await PasswordAuthentication.get(user)
|
|
66
|
+
I.assert(!!secondPasswordAuthenticationData, true, 'password set')
|
|
67
|
+
I.assertNotEqual(secondPasswordAuthenticationData.passwordHash, firstPasswordAuthenticationData.passwordHash,
|
|
68
|
+
'password changed')
|
|
69
|
+
|
|
70
|
+
})
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
const app = require('@live-change/framework').app()
|
|
2
|
+
const randomProfile = require('random-profile-generator')
|
|
3
|
+
|
|
4
|
+
const randomUserData = randomProfile.profile()
|
|
5
|
+
randomUserData.email = randomUserData.firstName.toLowerCase() + '@test.com' // test domain - emails not sent
|
|
6
|
+
|
|
7
|
+
const happyPath = false
|
|
8
|
+
|
|
9
|
+
Feature('user')
|
|
10
|
+
|
|
11
|
+
Scenario('sign in with email code', async ({ I }) => {
|
|
12
|
+
|
|
13
|
+
const user = app.generateUid()
|
|
14
|
+
const email = randomUserData.email
|
|
15
|
+
|
|
16
|
+
const User = await I.haveModel('user', 'User')
|
|
17
|
+
const Email = await I.haveModel('email', 'Email')
|
|
18
|
+
|
|
19
|
+
await User.create({ id: user, roles: [] })
|
|
20
|
+
await Email.create({ id: email, email, user })
|
|
21
|
+
|
|
22
|
+
I.amOnPage('/sign-in')
|
|
23
|
+
I.fillField('input#email', email)
|
|
24
|
+
I.click('button[type=submit]')
|
|
25
|
+
|
|
26
|
+
I.seeInCurrentUrl('/sent/')
|
|
27
|
+
const url = await I.grabCurrentUrl()
|
|
28
|
+
const authentication = url.split('/').pop()
|
|
29
|
+
|
|
30
|
+
const authenticationData = await I.grabObject('messageAuthentication', 'Authentication', authentication)
|
|
31
|
+
console.log("AUTHENTICATION DATA", authenticationData)
|
|
32
|
+
I.assert(!!authenticationData, true, 'authentication created')
|
|
33
|
+
I.assert(authenticationData?.messageData?.user, user, 'authentication contains user')
|
|
34
|
+
|
|
35
|
+
await I.useSecretCode(authentication, happyPath)
|
|
36
|
+
|
|
37
|
+
I.seeInCurrentUrl('/sign-in-finished')
|
|
38
|
+
const clientSession = await I.executeScript(() => api.client.value.session)
|
|
39
|
+
const AuthenticatedUser = await I.haveModel('user', 'AuthenticatedUser')
|
|
40
|
+
const authenticatedUserData = await AuthenticatedUser.get(clientSession)
|
|
41
|
+
I.assert(!!authenticatedUserData, true, 'user authenticated server-side')
|
|
42
|
+
const clientUser = await I.executeScript(() => api.client.value.user)
|
|
43
|
+
console.log("CLIENT USER", clientUser)
|
|
44
|
+
console.log("SERVER AUTHENTICATION", authenticatedUserData)
|
|
45
|
+
I.assert(clientUser, authenticatedUserData.user, 'user authenticated')
|
|
46
|
+
|
|
47
|
+
if(!happyPath) {
|
|
48
|
+
I.amOnPage(url)
|
|
49
|
+
I.seeInCurrentUrl('/sign-in-finished')
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
})
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
const app = require('@live-change/framework').app()
|
|
2
|
+
const randomProfile = require('random-profile-generator')
|
|
3
|
+
|
|
4
|
+
const randomUserData = randomProfile.profile()
|
|
5
|
+
randomUserData.email = randomUserData.firstName.toLowerCase() + '@test.com' // test domain - emails not sent
|
|
6
|
+
|
|
7
|
+
const happyPath = false
|
|
8
|
+
|
|
9
|
+
Feature('user')
|
|
10
|
+
|
|
11
|
+
Scenario('sign in with email link', async ({ I }) => {
|
|
12
|
+
|
|
13
|
+
const user = app.generateUid()
|
|
14
|
+
const email = randomUserData.email
|
|
15
|
+
|
|
16
|
+
const User = await I.haveModel('user', 'User')
|
|
17
|
+
const Email = await I.haveModel('email', 'Email')
|
|
18
|
+
|
|
19
|
+
await User.create({ id: user, roles: [] })
|
|
20
|
+
await Email.create({ id: email, email, user })
|
|
21
|
+
|
|
22
|
+
I.amOnPage('/sign-in')
|
|
23
|
+
I.fillField('input#email', email)
|
|
24
|
+
I.click('button[type=submit]')
|
|
25
|
+
|
|
26
|
+
I.seeInCurrentUrl('/sent/')
|
|
27
|
+
const url = await I.grabCurrentUrl()
|
|
28
|
+
const authentication = url.split('/').pop()
|
|
29
|
+
|
|
30
|
+
const authenticationData = await I.grabObject('messageAuthentication', 'Authentication', authentication)
|
|
31
|
+
console.log("AUTHENTICATION DATA", authenticationData)
|
|
32
|
+
I.assert(!!authenticationData, true, 'authentication created')
|
|
33
|
+
I.assert(authenticationData?.messageData?.user, user, 'authentication contains user')
|
|
34
|
+
|
|
35
|
+
const linkData = await I.useSecretLink(authentication, happyPath)
|
|
36
|
+
|
|
37
|
+
I.seeInCurrentUrl('/sign-in-finished')
|
|
38
|
+
const clientSession = await I.executeScript(() => api.client.value.session)
|
|
39
|
+
const AuthenticatedUser = await I.haveModel('user', 'AuthenticatedUser')
|
|
40
|
+
const authenticatedUserData = await AuthenticatedUser.get(clientSession)
|
|
41
|
+
I.assert(!!authenticatedUserData, true, 'user authenticated server-side')
|
|
42
|
+
const clientUser = await I.executeScript(() => api.client.value.user)
|
|
43
|
+
console.log("CLIENT USER", clientUser)
|
|
44
|
+
console.log("SERVER AUTHENTICATION", authenticatedUserData)
|
|
45
|
+
I.assert(clientUser, authenticatedUserData.user, 'user authenticated')
|
|
46
|
+
|
|
47
|
+
if(!happyPath) {
|
|
48
|
+
I.amOnPage('/link/' + linkData.secretCode)
|
|
49
|
+
I.see('Link used')
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
})
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
const app = require('@live-change/framework').app()
|
|
2
|
+
const randomProfile = require('random-profile-generator')
|
|
3
|
+
const crypto = require('crypto')
|
|
4
|
+
const passwordGenerator = require('generate-password')
|
|
5
|
+
|
|
6
|
+
const randomUserData = randomProfile.profile()
|
|
7
|
+
randomUserData.email = randomUserData.firstName.toLowerCase() + '@test.com' // test domain - emails not sent
|
|
8
|
+
|
|
9
|
+
const happyPath = false
|
|
10
|
+
|
|
11
|
+
Feature('user')
|
|
12
|
+
|
|
13
|
+
Scenario('sign in with email and password', async ({ I }) => {
|
|
14
|
+
|
|
15
|
+
const user = app.generateUid()
|
|
16
|
+
const email = randomUserData.email
|
|
17
|
+
const password = passwordGenerator.generate({
|
|
18
|
+
length: 10,
|
|
19
|
+
numbers: true
|
|
20
|
+
})+(Math.random()*10).toFixed()
|
|
21
|
+
const passwordHash = crypto.createHash('sha256').update(password).digest('hex')
|
|
22
|
+
|
|
23
|
+
const User = await I.haveModel('user', 'User')
|
|
24
|
+
const Email = await I.haveModel('email', 'Email')
|
|
25
|
+
const PasswordAuthentication = await I.haveModel('passwordAuthentication', 'PasswordAuthentication')
|
|
26
|
+
|
|
27
|
+
await User.create({ id: user, roles: [] })
|
|
28
|
+
await Email.create({ id: email, email, user })
|
|
29
|
+
await PasswordAuthentication.create({ id: user, user, passwordHash })
|
|
30
|
+
|
|
31
|
+
I.amOnPage('/sign-in')
|
|
32
|
+
I.fillField('input#email', email)
|
|
33
|
+
I.fillField('input#password', password)
|
|
34
|
+
I.click('button[type=submit]')
|
|
35
|
+
|
|
36
|
+
I.seeInCurrentUrl('/sign-in-finished')
|
|
37
|
+
await I.wait(0.2)
|
|
38
|
+
const clientSession = await I.executeScript(() => api.client.value.session)
|
|
39
|
+
const AuthenticatedUser = await I.haveModel('user', 'AuthenticatedUser')
|
|
40
|
+
const authenticatedUserData = await AuthenticatedUser.get(clientSession)
|
|
41
|
+
I.assert(!!authenticatedUserData, true, 'user authenticated server-side')
|
|
42
|
+
const clientUser = await I.executeScript(() => api.client.value.user)
|
|
43
|
+
console.log("CLIENT USER", clientUser)
|
|
44
|
+
console.log("SERVER AUTHENTICATION", authenticatedUserData)
|
|
45
|
+
I.assert(clientUser, authenticatedUserData.user, 'user authenticated')
|
|
46
|
+
|
|
47
|
+
})
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
const app = require('@live-change/framework').app()
|
|
2
|
+
const randomProfile = require('random-profile-generator')
|
|
3
|
+
|
|
4
|
+
const name = randomProfile.profile().firstName.toLowerCase()
|
|
5
|
+
const email = name + '@test.com' // test domain - emails not sent
|
|
6
|
+
|
|
7
|
+
const happyPath = false
|
|
8
|
+
|
|
9
|
+
Feature('user')
|
|
10
|
+
|
|
11
|
+
Scenario('sign out', async ({ I }) => {
|
|
12
|
+
|
|
13
|
+
const user = app.generateUid()
|
|
14
|
+
|
|
15
|
+
const User = await I.haveModel('user', 'User')
|
|
16
|
+
const Email = await I.haveModel('email', 'Email')
|
|
17
|
+
const AuthenticatedUser = await I.haveModel('user', 'AuthenticatedUser')
|
|
18
|
+
|
|
19
|
+
await User.create({ id: user, roles: [] })
|
|
20
|
+
await Email.create({ id: email, email, user })
|
|
21
|
+
I.amOnPage('/')
|
|
22
|
+
const session = await I.executeScript(() => api.client.value.session)
|
|
23
|
+
await AuthenticatedUser.create({ id: session, user, session })
|
|
24
|
+
|
|
25
|
+
await I.wait(0.2)
|
|
26
|
+
const clientUser = await I.executeScript(() => api.client.value.user)
|
|
27
|
+
I.assert(user, clientUser, 'client logged in')
|
|
28
|
+
|
|
29
|
+
I.amOnPage('/sign-out')
|
|
30
|
+
I.seeInCurrentUrl('/sign-out-finished')
|
|
31
|
+
|
|
32
|
+
await I.wait(1.0)
|
|
33
|
+
const clientUser2 = await I.executeScript(() => api.client.value.user)
|
|
34
|
+
console.log("CLIENT USER2", clientUser2)
|
|
35
|
+
const authenticatedUserData = await AuthenticatedUser.get(session)
|
|
36
|
+
console.log("AUTHENTICATED USER", authenticatedUserData)
|
|
37
|
+
|
|
38
|
+
I.assert(!!authenticatedUserData, false, 'no server user')
|
|
39
|
+
I.assert(!!clientUser2, false, 'no client user')
|
|
40
|
+
|
|
41
|
+
})
|