mirror of
https://github.com/mattermost/mattermost.git
synced 2025-02-25 18:55:24 -06:00
Migration typescript/enterprise/ldap (#25840)
* refactor: migrate file ldap_group_sync_spec.js to ts - migrate file to typescript * refactor: migrate file ldap_guest_spec.ts to ts - migrate file to typescript - update data types * refactor: migrate ldap_login_spec.js to ts * refactor: migrate ldap_setting_spec.js file to ts - convert file to typescript * Fix: type error --------- Co-authored-by: Mattermost Build <build@mattermost.com> Co-authored-by: yasserfaraazkhan <attitude3cena.yf@gmail.com>
This commit is contained in:
parent
1e794136c8
commit
0aaa047ea3
@ -10,9 +10,13 @@
|
|||||||
// Stage: @prod
|
// Stage: @prod
|
||||||
// Group: @channels @enterprise @ldap
|
// Group: @channels @enterprise @ldap
|
||||||
|
|
||||||
|
import {Channel} from '@mattermost/types/channels';
|
||||||
|
import {Team} from '@mattermost/types/teams';
|
||||||
|
import {UserProfile} from '@mattermost/types/users';
|
||||||
|
import {AdminConfig} from '@mattermost/types/config';
|
||||||
import * as TIMEOUTS from '../../../../fixtures/timeouts';
|
import * as TIMEOUTS from '../../../../fixtures/timeouts';
|
||||||
|
|
||||||
function setLDAPTestSettings(config) {
|
function setLDAPTestSettings(config: AdminConfig) {
|
||||||
return {
|
return {
|
||||||
siteName: config.TeamSettings.SiteName,
|
siteName: config.TeamSettings.SiteName,
|
||||||
siteUrl: config.ServiceSettings.SiteURL,
|
siteUrl: config.ServiceSettings.SiteURL,
|
||||||
@ -25,9 +29,9 @@ function setLDAPTestSettings(config) {
|
|||||||
// assumes that E20 license is uploaded
|
// assumes that E20 license is uploaded
|
||||||
// for setup with AWS: Follow the instructions mentioned in the mattermost/platform-private/config/ldap-test-setup.txt file
|
// for setup with AWS: Follow the instructions mentioned in the mattermost/platform-private/config/ldap-test-setup.txt file
|
||||||
context('ldap', () => {
|
context('ldap', () => {
|
||||||
let testChannel;
|
let testChannel: Channel;
|
||||||
let testTeam;
|
let testTeam: Team;
|
||||||
let testUser;
|
let testUser: UserProfile;
|
||||||
|
|
||||||
describe('LDAP Group Sync Automated Tests', () => {
|
describe('LDAP Group Sync Automated Tests', () => {
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
@ -161,7 +165,7 @@ context('ldap', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('MM-T2621 - Team List Management Column', () => {
|
it('MM-T2621 - Team List Management Column', () => {
|
||||||
let testTeam2;
|
let testTeam2: Team;
|
||||||
|
|
||||||
// # Go to testTeam config page
|
// # Go to testTeam config page
|
||||||
cy.visit(`/admin_console/user_management/teams/${testTeam.id}`);
|
cy.visit(`/admin_console/user_management/teams/${testTeam.id}`);
|
@ -14,6 +14,7 @@ import ldapUsers from '../../../../fixtures/ldap_users.json';
|
|||||||
import * as TIMEOUTS from '../../../../fixtures/timeouts';
|
import * as TIMEOUTS from '../../../../fixtures/timeouts';
|
||||||
import {getAdminAccount} from '../../../../support/env';
|
import {getAdminAccount} from '../../../../support/env';
|
||||||
import {getRandomId} from '../../../../utils';
|
import {getRandomId} from '../../../../utils';
|
||||||
|
import {UserProfile} from '@mattermost/types/users';
|
||||||
|
|
||||||
// assumes that E20 license is uploaded
|
// assumes that E20 license is uploaded
|
||||||
// for setup with AWS: Follow the instructions mentioned in the mattermost/platform-private/config/ldap-test-setup.txt file
|
// for setup with AWS: Follow the instructions mentioned in the mattermost/platform-private/config/ldap-test-setup.txt file
|
||||||
@ -41,7 +42,7 @@ describe('LDAP guest', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
// # Get user1 data
|
// # Get user1 data
|
||||||
cy.apiLogin(user1).then(({user}) => {
|
cy.apiLogin(user1 as unknown as UserProfile).then((user) => {
|
||||||
user1Data = user;
|
user1Data = user;
|
||||||
|
|
||||||
// # Remove user1 from all the teams
|
// # Remove user1 from all the teams
|
||||||
@ -49,7 +50,7 @@ describe('LDAP guest', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
// # Get user2 data
|
// # Get user2 data
|
||||||
cy.apiLogin(user2).then(({user}) => {
|
cy.apiLogin(user2 as unknown as UserProfile).then((user) => {
|
||||||
user2Data = user;
|
user2Data = user;
|
||||||
|
|
||||||
// # Remove user2 fromm all the teams
|
// # Remove user2 fromm all the teams
|
||||||
@ -262,13 +263,15 @@ function demoteUserToGuest(user) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function removeUserFromAllTeams(user) {
|
function removeUserFromAllTeams(user: { id: string }) {
|
||||||
// # Get all teams of a user
|
// # Get all teams of a user
|
||||||
cy.apiGetTeamsForUser(user.id).then(({teams}) => {
|
cy.apiGetTeamsForUser(user.id).then((teams) => {
|
||||||
// # Remove user from all the teams
|
// # Remove user from all the teams
|
||||||
teams.forEach((team) => {
|
if (teams.length > 0) {
|
||||||
cy.apiDeleteUserFromTeam(team.id, user.id);
|
teams.forEach((team: { id: string }) => {
|
||||||
});
|
cy.apiDeleteUserFromTeam(team.id, user.id);
|
||||||
|
});
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
@ -158,7 +158,7 @@ context('ldap', () => {
|
|||||||
before(() => {
|
before(() => {
|
||||||
cy.apiAdminLogin();
|
cy.apiAdminLogin();
|
||||||
|
|
||||||
cy.apiGetTeamByName(testSettings.teamName).then(({team}) => {
|
cy.apiGetTeamByName(testSettings.teamName).then((team) => {
|
||||||
cy.apiGetChannelByName(testSettings.teamName, 'town-square').then(({channel}) => {
|
cy.apiGetChannelByName(testSettings.teamName, 'town-square').then(({channel}) => {
|
||||||
cy.apiGetUserByEmail(guest1.email).then(({user}) => {
|
cy.apiGetUserByEmail(guest1.email).then(({user}) => {
|
||||||
cy.apiAddUserToTeam(team.id, user.id).then(() => {
|
cy.apiAddUserToTeam(team.id, user.id).then(() => {
|
||||||
@ -220,7 +220,7 @@ function setLDAPTestSettings(config) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function disableOnboardingTaskList(ldapLogin) {
|
function disableOnboardingTaskList(ldapLogin) {
|
||||||
cy.apiLogin(ldapLogin).then(({user}) => {
|
cy.apiLogin(ldapLogin).then((user) => {
|
||||||
cy.apiSaveOnboardingTaskListPreference(user.id, 'onboarding_task_list_open', 'false');
|
cy.apiSaveOnboardingTaskListPreference(user.id, 'onboarding_task_list_open', 'false');
|
||||||
cy.apiSaveOnboardingTaskListPreference(user.id, 'onboarding_task_list_show', 'false');
|
cy.apiSaveOnboardingTaskListPreference(user.id, 'onboarding_task_list_show', 'false');
|
||||||
cy.apiSaveSkipStepsPreference(user.id, 'true');
|
cy.apiSaveSkipStepsPreference(user.id, 'true');
|
||||||
@ -228,13 +228,15 @@ function disableOnboardingTaskList(ldapLogin) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function removeUserFromAllTeams(testUser) {
|
function removeUserFromAllTeams(testUser) {
|
||||||
cy.apiGetUsersByUsernames([testUser.username]).then(({users}) => {
|
cy.apiGetUsersByUsernames([testUser.username]).then((users) => {
|
||||||
users.forEach((user) => {
|
if (users.length > 0) {
|
||||||
cy.apiGetTeamsForUser(user.id).then(({teams}) => {
|
users.forEach((user) => {
|
||||||
teams.forEach((team) => {
|
cy.apiGetTeamsForUser(user.id).then((teams) => {
|
||||||
cy.apiDeleteUserFromTeam(team.id, user.id);
|
teams.forEach((team) => {
|
||||||
|
cy.apiDeleteUserFromTeam(team.id, user.id);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
@ -70,6 +70,17 @@ declare namespace Cypress {
|
|||||||
*/
|
*/
|
||||||
apiSaveOnboardingTaskListPreference(userId: string, name: string, value: string): Chainable<Response>;
|
apiSaveOnboardingTaskListPreference(userId: string, name: string, value: string): Chainable<Response>;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Save skip steps preference.
|
||||||
|
* @param userId - User ID
|
||||||
|
* @param {string} value - options are 'true' or 'false'
|
||||||
|
* @returns {Response} response: Cypress-chainable response which should have successful HTTP status of 200 OK to continue or pass.
|
||||||
|
*
|
||||||
|
* @example
|
||||||
|
* cy.apiSaveSkipStepsPreference('user-id', 'true');
|
||||||
|
*/
|
||||||
|
apiSaveSkipStepsPreference(userId: string, value: string): Chainable<Response>;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Save DM channel show preference.
|
* Save DM channel show preference.
|
||||||
* See https://api.mattermost.com/#tag/preferences/paths/~1users~1{user_id}~1preferences/put
|
* See https://api.mattermost.com/#tag/preferences/paths/~1users~1{user_id}~1preferences/put
|
||||||
|
@ -21,6 +21,11 @@ declare namespace Cypress {
|
|||||||
* @returns {boolean} - true if error successfully found.
|
* @returns {boolean} - true if error successfully found.
|
||||||
*/
|
*/
|
||||||
checkForLDAPError(): Chainable;
|
checkForLDAPError(): Chainable;
|
||||||
|
|
||||||
|
skipOrCreateTeam: typeof skipOrCreateTeam;
|
||||||
|
checkLoginFailed: typeof checkLoginFailed;
|
||||||
|
doMemberLogoutFromSignUp: typeof doMemberLogoutFromSignUp;
|
||||||
|
doLogoutFromSignUp: typeof doLogoutFromSignUp;
|
||||||
checkLoginPage: typeof checkLoginPage;
|
checkLoginPage: typeof checkLoginPage;
|
||||||
checkLeftSideBar: typeof checkLeftSideBar;
|
checkLeftSideBar: typeof checkLeftSideBar;
|
||||||
checkInvitePeoplePage: typeof checkInvitePeoplePage;
|
checkInvitePeoplePage: typeof checkInvitePeoplePage;
|
||||||
|
@ -31,6 +31,24 @@ declare namespace Cypress {
|
|||||||
*/
|
*/
|
||||||
getLdapSyncJobStatus(start: number): string;
|
getLdapSyncJobStatus(start: number): string;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* doLDAPLogin is a task that runs LDAP login
|
||||||
|
* @param {object} settings - login settings
|
||||||
|
* @param {boolean} useEmail - true if uses email
|
||||||
|
*/
|
||||||
|
doLDAPLogin(settings: object = {}, useEmail = false): Chainable<void>;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* doLDAPLogout is a task that runs LDAP logout
|
||||||
|
* @param {Object} settings - logout settings
|
||||||
|
*/
|
||||||
|
doLDAPLogout(settings: object = {}): Chainable<void>;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* visitLDAPSettings is a task that navigates to LDAP settings Page
|
||||||
|
*/
|
||||||
|
visitLDAPSettings(): Chainable<void>;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* waitForLdapSyncCompletion is a task that runs recursively
|
* waitForLdapSyncCompletion is a task that runs recursively
|
||||||
* until getLdapSyncJobStatus completes or timeouts.
|
* until getLdapSyncJobStatus completes or timeouts.
|
||||||
|
Loading…
Reference in New Issue
Block a user