diff --git a/e2e/suites/actions/create-folder.test.ts b/e2e/suites/actions/create-folder.test.ts index 694a10879..7a25749c1 100755 --- a/e2e/suites/actions/create-folder.test.ts +++ b/e2e/suites/actions/create-folder.test.ts @@ -55,7 +55,7 @@ describe('Create folder', () => { const { dataTable } = personalFilesPage; beforeAll(done => { - apis.admin.people.createUser(username) + apis.admin.people.createUser({ username }) .then(() => apis.admin.sites.createSite(siteName, SITE_VISIBILITY.PRIVATE)) .then(() => apis.admin.nodes.createFolders([ folderName1 ], `Sites/${siteName}/documentLibrary`)) .then(() => apis.admin.sites.addSiteMember(siteName, username, SITE_ROLES.SITE_CONSUMER)) diff --git a/e2e/suites/actions/delete-undo-delete.test.ts b/e2e/suites/actions/delete-undo-delete.test.ts index acc6e2ba4..18b6676c4 100755 --- a/e2e/suites/actions/delete-undo-delete.test.ts +++ b/e2e/suites/actions/delete-undo-delete.test.ts @@ -43,7 +43,7 @@ describe('Delete and undo delete', () => { const { dataTable, toolbar } = page; beforeAll(done => { - apis.admin.people.createUser(username).then(done); + apis.admin.people.createUser({ username }).then(done); }); afterAll(done => { diff --git a/e2e/suites/actions/edit-folder.test.ts b/e2e/suites/actions/edit-folder.test.ts index 8cf99a544..47b21189a 100755 --- a/e2e/suites/actions/edit-folder.test.ts +++ b/e2e/suites/actions/edit-folder.test.ts @@ -58,7 +58,7 @@ describe('Edit folder', () => { const editButton = personalFilesPage.toolbar.actions.getButtonByTitleAttribute('Edit'); beforeAll(done => { - apis.admin.people.createUser(username) + apis.admin.people.createUser({ username }) .then(() => apis.admin.sites.createSite(siteName, SITE_VISIBILITY.PRIVATE)) .then(() => apis.admin.nodes.createFolders([ folderName ], `Sites/${siteName}/documentLibrary`)) .then(() => apis.admin.sites.addSiteMember(siteName, username, SITE_ROLES.SITE_CONSUMER)) diff --git a/e2e/suites/actions/mark-favorite.test.ts b/e2e/suites/actions/mark-favorite.test.ts index 0659c238d..5c172e96a 100644 --- a/e2e/suites/actions/mark-favorite.test.ts +++ b/e2e/suites/actions/mark-favorite.test.ts @@ -51,7 +51,7 @@ describe('Mark items as favorites', () => { const { dataTable, toolbar } = page; beforeAll(done => { - apis.admin.people.createUser(username) + apis.admin.people.createUser({ username }) .then(() => apis.user.nodes.createFile( file1NotFav ).then(resp => file1Id = resp.data.entry.id)) .then(() => apis.user.nodes.createFile( file2NotFav ).then(resp => file2Id = resp.data.entry.id)) .then(() => apis.user.nodes.createFile( file3Fav ).then(resp => file3Id = resp.data.entry.id)) diff --git a/e2e/suites/actions/permanently-delete.test.ts b/e2e/suites/actions/permanently-delete.test.ts index b8542d651..1faf493c0 100755 --- a/e2e/suites/actions/permanently-delete.test.ts +++ b/e2e/suites/actions/permanently-delete.test.ts @@ -50,7 +50,7 @@ describe('Permanently delete from Trash', () => { const { dataTable, toolbar } = trashPage; beforeAll(done => { - apis.admin.people.createUser(username) + apis.admin.people.createUser({ username }) .then(() => apis.user.nodes.createFiles([ file1, file2 ])) .then(resp => filesIds = resp.data.list.entries.map(entries => entries.entry.id)) .then(() => apis.user.nodes.createFolders([ folder1, folder2 ])) diff --git a/e2e/suites/actions/restore.test.ts b/e2e/suites/actions/restore.test.ts index 93cfaf8e6..90a349b6e 100755 --- a/e2e/suites/actions/restore.test.ts +++ b/e2e/suites/actions/restore.test.ts @@ -43,7 +43,7 @@ describe('Restore from Trash', () => { const { dataTable, toolbar } = page; beforeAll(done => { - apis.admin.people.createUser(username) + apis.admin.people.createUser({ username }) .then(() => loginPage.loginWith(username)) .then(done); }); diff --git a/e2e/suites/actions/toolbar-multiple-selection.test.ts b/e2e/suites/actions/toolbar-multiple-selection.test.ts index d8337d26d..1cbd8082c 100755 --- a/e2e/suites/actions/toolbar-multiple-selection.test.ts +++ b/e2e/suites/actions/toolbar-multiple-selection.test.ts @@ -66,7 +66,7 @@ describe('Toolbar actions - multiple selection : ', () => { const { toolbar } = page; beforeAll(done => { - apis.admin.people.createUser(user1) + apis.admin.people.createUser({ username: user1 }) .then(() => apis.user.nodes.createFiles([ file1 ]).then(resp => file1Id = resp.data.entry.id)) .then(() => apis.user.nodes.createFiles([ file2 ]).then(resp => file2Id = resp.data.entry.id)) .then(() => apis.user.nodes.createFolders([ folder1 ]).then(resp => folder1Id = resp.data.entry.id)) @@ -198,7 +198,7 @@ describe('Toolbar actions - multiple selection : ', () => { describe('File Libraries', () => { beforeAll(done => { apis.admin.sites.createSite(siteName, SITE_VISIBILITY.PUBLIC) - .then(() => apis.admin.people.createUser(user2)) + .then(() => apis.admin.people.createUser({ username: user2 })) .then(() => apis.admin.sites.addSiteMember(siteName, user1, SITE_ROLES.SITE_MANAGER)) .then(() => apis.admin.sites.addSiteMember(siteName, user2, SITE_ROLES.SITE_CONSUMER)) .then(() => apis.admin.nodes.createFiles([ file1Admin, file2Admin ], `Sites/${siteName}/documentLibrary`)) diff --git a/e2e/suites/actions/toolbar-single-selection.test.ts b/e2e/suites/actions/toolbar-single-selection.test.ts index 0c1bf5cf4..030d2900a 100755 --- a/e2e/suites/actions/toolbar-single-selection.test.ts +++ b/e2e/suites/actions/toolbar-single-selection.test.ts @@ -53,7 +53,7 @@ describe('Toolbar actions - single selection : ', () => { const { dataTable, toolbar } = page; beforeAll(async (done) => { - await apis.admin.people.createUser(username); + await apis.admin.people.createUser({ username }); fileUserId = (await apis.user.nodes.createFiles([fileUser])).data.entry.id; fileForDeleteId = (await apis.user.nodes.createFiles([fileForDelete])).data.entry.id; @@ -356,7 +356,7 @@ describe('Toolbar actions - single selection : ', () => { await apis.admin.sites.createSite(siteName, SITE_VISIBILITY.PUBLIC); const docLibId = await apis.admin.sites.getDocLibId(siteName); - await apis.admin.people.createUser(username2); + await apis.admin.people.createUser({ username: username2 }); await apis.admin.sites.addSiteMember(siteName, username, SITE_ROLES.SITE_MANAGER); await apis.admin.sites.addSiteMember(siteName, username2, SITE_ROLES.SITE_CONSUMER); diff --git a/e2e/suites/actions/upload-file.test.ts b/e2e/suites/actions/upload-file.test.ts index ea39da12c..2263c2f95 100755 --- a/e2e/suites/actions/upload-file.test.ts +++ b/e2e/suites/actions/upload-file.test.ts @@ -45,7 +45,7 @@ describe('Upload files', () => { const { dataTable } = page; beforeAll(done => { - apis.admin.people.createUser(username) + apis.admin.people.createUser({ username }) .then(() => apis.user.nodes.createFolder(folder1).then(resp => folder1Id = resp.data.entry.id)) .then(() => loginPage.loginWith(username)) diff --git a/e2e/suites/authentication/login.test.ts b/e2e/suites/authentication/login.test.ts index 9407b8481..3e0d31c72 100755 --- a/e2e/suites/authentication/login.test.ts +++ b/e2e/suites/authentication/login.test.ts @@ -61,14 +61,12 @@ describe('Login', () => { beforeAll(done => { Promise .all([ - peopleApi.createUser(testUser), - peopleApi.createUser(russianUser.username, russianUser.password), - peopleApi.createUser(johnDoe.username, johnDoe.password, { - firstName: johnDoe.firstName, - lastName: johnDoe.lastName - }), - peopleApi.createUser(disabledUser).then(() => peopleApi.disableUser(disabledUser)), - peopleApi.createUser(testUser2.username, testUser2.password) + peopleApi.createUser({ username: testUser }), + peopleApi.createUser(russianUser), + peopleApi.createUser(johnDoe), + peopleApi.createUser({ username: disabledUser }) + .then(() => peopleApi.disableUser(disabledUser)), + peopleApi.createUser(testUser2) ]) .then(done); }); diff --git a/e2e/suites/authentication/logout.test.ts b/e2e/suites/authentication/logout.test.ts index be6bd2690..523a303f7 100755 --- a/e2e/suites/authentication/logout.test.ts +++ b/e2e/suites/authentication/logout.test.ts @@ -40,7 +40,7 @@ describe('Logout', () => { beforeAll((done) => { peopleApi - .createUser(johnDoe) + .createUser({ username: johnDoe }) .then(done); }); diff --git a/e2e/suites/list-views/empty-list.test.ts b/e2e/suites/list-views/empty-list.test.ts index 4fc84ebe4..b6dfaee22 100755 --- a/e2e/suites/list-views/empty-list.test.ts +++ b/e2e/suites/list-views/empty-list.test.ts @@ -43,7 +43,7 @@ describe('Empty list views', () => { const { dataTable } = page; beforeAll(done => { - apis.admin.people.createUser(username) + apis.admin.people.createUser({ username }) .then(() => loginPage.loginWith(username)) .then(done); }); diff --git a/e2e/suites/list-views/favorites.test.ts b/e2e/suites/list-views/favorites.test.ts index e83517d9c..aaabe6669 100755 --- a/e2e/suites/list-views/favorites.test.ts +++ b/e2e/suites/list-views/favorites.test.ts @@ -52,7 +52,7 @@ describe('Favorites', () => { const { breadcrumb } = favoritesPage.toolbar; beforeAll(async (done) => { - await apis.admin.people.createUser(username); + await apis.admin.people.createUser({ username }); await apis.admin.sites.createSite(siteName, SITE_VISIBILITY.PUBLIC); const docLibId = await apis.admin.sites.getDocLibId(siteName); diff --git a/e2e/suites/list-views/file-libraries.test.ts b/e2e/suites/list-views/file-libraries.test.ts index 5e25da58d..15c14385c 100755 --- a/e2e/suites/list-views/file-libraries.test.ts +++ b/e2e/suites/list-views/file-libraries.test.ts @@ -55,7 +55,7 @@ describe('File Libraries', () => { beforeAll(done => { Promise .all([ - apis.admin.people.createUser(username), + apis.admin.people.createUser({ username }), apis.admin.sites.createSite(sitePublic, SITE_VISIBILITY.PUBLIC), apis.admin.sites.createSite(siteModerated, SITE_VISIBILITY.MODERATED, siteDescription), apis.admin.sites.createSite(sitePrivate, SITE_VISIBILITY.PRIVATE, null), diff --git a/e2e/suites/list-views/permissions.test.ts b/e2e/suites/list-views/permissions.test.ts index 6facf0fa4..2c2a0a84c 100755 --- a/e2e/suites/list-views/permissions.test.ts +++ b/e2e/suites/list-views/permissions.test.ts @@ -47,7 +47,7 @@ describe('Special permissions', () => { xit(''); beforeAll(done => { - apis.admin.people.createUser(username).then(done); + apis.admin.people.createUser({ username }).then(done); }); describe('file not displayed if user no longer has permissions on it', () => { diff --git a/e2e/suites/list-views/personal-files.test.ts b/e2e/suites/list-views/personal-files.test.ts index ba4509d4c..23db53145 100755 --- a/e2e/suites/list-views/personal-files.test.ts +++ b/e2e/suites/list-views/personal-files.test.ts @@ -51,7 +51,7 @@ describe('Personal Files', () => { beforeAll(done => { Promise .all([ - apis.admin.people.createUser(username), + apis.admin.people.createUser({ username }), apis.admin.nodes.createFolders([ adminFolder ]) ]) .then(() => apis.user.nodes.createFolders([ userFolder ])) diff --git a/e2e/suites/list-views/recent-files.test.ts b/e2e/suites/list-views/recent-files.test.ts index 1ef5dcef4..4f7a86487 100755 --- a/e2e/suites/list-views/recent-files.test.ts +++ b/e2e/suites/list-views/recent-files.test.ts @@ -52,7 +52,7 @@ describe('Recent Files', () => { const { breadcrumb } = recentFilesPage.toolbar; beforeAll(done => { - apis.admin.people.createUser(username) + apis.admin.people.createUser({ username }) .then(() => apis.user.nodes.createFolders([ folderName ])).then(resp => folderId = resp.data.entry.id) .then(() => apis.user.nodes.createFiles([ fileName1 ], folderName)) .then(() => apis.user.nodes.createFiles([ fileName2 ])).then(resp => file2Id = resp.data.entry.id) diff --git a/e2e/suites/list-views/shared-files.test.ts b/e2e/suites/list-views/shared-files.test.ts index bc20ee4c4..6466cc731 100755 --- a/e2e/suites/list-views/shared-files.test.ts +++ b/e2e/suites/list-views/shared-files.test.ts @@ -53,7 +53,7 @@ describe('Shared Files', () => { const { breadcrumb } = sharedFilesPage.toolbar; beforeAll(done => { - apis.admin.people.createUser(username) + apis.admin.people.createUser({ username }) .then(() => apis.admin.sites.createSite(siteName, SITE_VISIBILITY.PUBLIC)) .then(() => apis.admin.sites.addSiteMember(siteName, username, SITE_ROLES.SITE_CONSUMER)) .then(() => apis.admin.nodes.createFiles([ fileAdmin ], `Sites/${siteName}/documentLibrary`)) diff --git a/e2e/suites/list-views/tooltips.test.ts b/e2e/suites/list-views/tooltips.test.ts index 2798efaeb..d9823d3d6 100755 --- a/e2e/suites/list-views/tooltips.test.ts +++ b/e2e/suites/list-views/tooltips.test.ts @@ -57,7 +57,7 @@ describe('File / folder tooltips', () => { const { dataTable } = page; beforeAll(done => { - apis.admin.people.createUser(username) + apis.admin.people.createUser({ username }) .then(() => apis.user.nodes.createFolder( parent )) .then(resp => parentId = resp.data.entry.id) diff --git a/e2e/suites/list-views/trash.test.ts b/e2e/suites/list-views/trash.test.ts index b36ba8666..722ea5509 100755 --- a/e2e/suites/list-views/trash.test.ts +++ b/e2e/suites/list-views/trash.test.ts @@ -59,7 +59,7 @@ describe('Trash', () => { const { breadcrumb } = trashPage.toolbar; beforeAll(done => { - apis.admin.people.createUser(username) + apis.admin.people.createUser({ username }) .then(() => apis.admin.nodes.createFiles([ fileAdmin ]).then(resp => fileAdminId = resp.data.entry.id)) .then(() => apis.admin.nodes.createFolders([ folderAdmin ]).then(resp => folderAdminId = resp.data.entry.id)) .then(() => apis.admin.sites.createSite(siteName, SITE_VISIBILITY.PUBLIC)) diff --git a/e2e/suites/navigation/breadcrumb.test.ts b/e2e/suites/navigation/breadcrumb.test.ts index 63c152348..e6b53403e 100755 --- a/e2e/suites/navigation/breadcrumb.test.ts +++ b/e2e/suites/navigation/breadcrumb.test.ts @@ -55,7 +55,7 @@ describe('Breadcrumb', () => { }; beforeAll(done => { - apis.admin.people.createUser(username) + apis.admin.people.createUser({ username }) .then(() => apis.user.nodes.createFolder(parent)).then(resp => parentId = resp.data.entry.id) .then(() => apis.user.nodes.createFolder(subFolder1, parentId)).then(resp => subFolder1Id = resp.data.entry.id) .then(() => apis.user.nodes.createFolder(subFolder2, subFolder1Id)).then(resp => subFolder2Id = resp.data.entry.id) @@ -219,7 +219,7 @@ describe('Breadcrumb', () => { beforeAll(done => { logoutPage.load() - .then(() => apis.admin.people.createUser(user2)) + .then(() => apis.admin.people.createUser({ username: user2 })) .then(() => user2Api.nodes.createFolder(userFolder).then(resp => userFolderId = resp.data.entry.id)) .then(() => loginPage.loginWithAdmin()) .then(done); diff --git a/e2e/suites/pagination/pag-favorites.test.ts b/e2e/suites/pagination/pag-favorites.test.ts index 63b2209ff..77ef20da4 100755 --- a/e2e/suites/pagination/pag-favorites.test.ts +++ b/e2e/suites/pagination/pag-favorites.test.ts @@ -52,7 +52,7 @@ describe('Pagination on Favorites', () => { const file = `file-${Utils.random()}.txt`; let fileId; beforeAll(done => { - apis.admin.people.createUser(username).then(done); + apis.admin.people.createUser({ username }).then(done); }); xit(''); diff --git a/e2e/suites/pagination/pag-personal-files.test.ts b/e2e/suites/pagination/pag-personal-files.test.ts index 4fa2300b9..c2144594c 100755 --- a/e2e/suites/pagination/pag-personal-files.test.ts +++ b/e2e/suites/pagination/pag-personal-files.test.ts @@ -51,7 +51,7 @@ describe('Pagination on Personal Files', () => { const file = `file-${Utils.random()}.txt`; let fileId; beforeAll(done => { - apis.admin.people.createUser(username).then(done); + apis.admin.people.createUser({ username }).then(done); }); xit(''); diff --git a/e2e/suites/pagination/pag-recent-files.test.ts b/e2e/suites/pagination/pag-recent-files.test.ts index 9c72c32ed..ed90ac028 100755 --- a/e2e/suites/pagination/pag-recent-files.test.ts +++ b/e2e/suites/pagination/pag-recent-files.test.ts @@ -51,7 +51,7 @@ describe('Pagination on Recent Files', () => { const file = `file-${Utils.random()}.txt`; let fileId; beforeAll(done => { - apis.admin.people.createUser(username).then(done); + apis.admin.people.createUser({ username }).then(done); }); xit(''); diff --git a/e2e/suites/pagination/pag-shared-files.test.ts b/e2e/suites/pagination/pag-shared-files.test.ts index 4232e74b1..9906c93c2 100755 --- a/e2e/suites/pagination/pag-shared-files.test.ts +++ b/e2e/suites/pagination/pag-shared-files.test.ts @@ -52,7 +52,7 @@ describe('Pagination on Shared Files', () => { const file = `file-${Utils.random()}.txt`; let fileId; beforeAll(done => { - apis.admin.people.createUser(username).then(done); + apis.admin.people.createUser({ username }).then(done); }); xit(''); diff --git a/e2e/suites/pagination/pag-trash.test.ts b/e2e/suites/pagination/pag-trash.test.ts index 60a9f4e7b..0e39f4a1e 100755 --- a/e2e/suites/pagination/pag-trash.test.ts +++ b/e2e/suites/pagination/pag-trash.test.ts @@ -51,7 +51,7 @@ describe('Pagination on Trash', () => { const file = `file-${Utils.random()}.txt`; let fileId; beforeAll(done => { - apis.admin.people.createUser(username).then(done); + apis.admin.people.createUser({ username }).then(done); }); xit(''); diff --git a/e2e/utilities/repo-client/apis/people/people-api-models.ts b/e2e/utilities/repo-client/apis/people/people-api-models.ts index 93be7980c..f5155843c 100755 --- a/e2e/utilities/repo-client/apis/people/people-api-models.ts +++ b/e2e/utilities/repo-client/apis/people/people-api-models.ts @@ -23,21 +23,31 @@ * along with Alfresco. If not, see . */ -export class Person { - id?: string; +export interface PersonModel { + username?: string; password?: string; firstName?: string; lastName?: string; email?: string; + enabled?: boolean; properties?: any; +} - constructor(username: string, password: string, details: Person) { - this.id = username; - this.password = password || username; - this.firstName = username; - this.lastName = username; - this.email = `${username}@alfresco.com`; +export class Person { + id: string; + password: string; + firstName: string; + lastName: string; + email: string; + enabled: boolean; + properties: any; - Object.assign(this, details); + constructor(user: PersonModel) { + this.id = user.username; + this.password = user.password || user.username; + this.firstName = user.firstName || user.username; + this.lastName = user.lastName || user.username; + this.email = user.email || `${user.username}@alfresco.com`; + this.enabled = user.enabled || true; } } diff --git a/e2e/utilities/repo-client/apis/people/people-api.ts b/e2e/utilities/repo-client/apis/people/people-api.ts index 2ede55982..75e750647 100755 --- a/e2e/utilities/repo-client/apis/people/people-api.ts +++ b/e2e/utilities/repo-client/apis/people/people-api.ts @@ -23,48 +23,36 @@ * along with Alfresco. If not, see . */ -import { RepoApi } from '../repo-api'; -import { Person } from './people-api-models'; +import { PersonModel, Person } from './people-api-models'; +import { RepoApiNew } from '../repo-api-new'; -export class PeopleApi extends RepoApi { - getUser(username: string) { - return this - .get(`/people/${username}`) - .catch(this.handleError); +export class PeopleApi extends RepoApiNew { + + constructor(username?, password?) { + super(username, password); } - updateUser(username: string, details?: Person): Promise { - if (details.id) { - delete details.id; - } - - return this - .put(`/people/${username}`, { data: details }) - .catch(this.handleError); + async createUser(user: PersonModel) { + const person = new Person(user); + await this.apiAuth(); + return await this.alfrescoJsApi.core.peopleApi.addPerson(person); } - createUser(username: string, password?: string, details?: Person): Promise { - const person: Person = new Person(username, password, details); - const onSuccess = (response) => response; - const onError = (response) => { - return (response.statusCode === 409) - ? Promise.resolve(this.updateUser(username, person)) - : Promise.reject(response); - }; - - return this - .post(`/people`, { data: person }) - .then(onSuccess, onError) - .catch(this.handleError); + async getUser(username: string) { + await this.apiAuth(); + return await this.alfrescoJsApi.core.peopleApi.getPerson(username); } - disableUser(username: string): Promise { - return this.put(`/people/${username}`, { data: { enabled: false } }) - .catch(this.handleError); + async updateUser(username: string, userDetails?: PersonModel) { + await this.apiAuth(); + return this.alfrescoJsApi.core.peopleApi.updatePerson(username, userDetails); } - changePassword(username: string, newPassword: string) { - return this.put(`/people/${username}`, { data: { password: newPassword } }) - .catch(this.handleError); + async disableUser(username: string) { + return await this.updateUser(username, { enabled: false }); + } + + async changePassword(username: string, newPassword: string) { + return await this.updateUser(username, { password: newPassword }); } } diff --git a/e2e/utilities/repo-client/repo-client.ts b/e2e/utilities/repo-client/repo-client.ts index bc940ee9f..8cdbe542d 100755 --- a/e2e/utilities/repo-client/repo-client.ts +++ b/e2e/utilities/repo-client/repo-client.ts @@ -46,7 +46,7 @@ export class RepoClient { } get people () { - return new PeopleApi(this.auth, this.config); + return new PeopleApi(this.auth.username, this.auth.password); } get nodes() {