Этот коммит содержится в:
Mario Vitale
2023-03-27 16:28:42 +02:00
родитель da7a6825ce
Коммит ba6b97fb62
1142 изменённых файлов: 44 добавлений и 44 удалений

Просмотреть файл

@@ -0,0 +1,507 @@
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
// ***************************************************************
// - [#] indicates a test step (e.g. #. Go to a page)
// - [*] indicates an assertion (e.g. * Check the title)
// - Use element ID when selecting an element. Create one if none.
// ***************************************************************
// Stage: @prod
// Group: @channels @enterprise @ldap
import * as TIMEOUTS from '../../../../fixtures/timeouts';
function setLDAPTestSettings(config) {
return {
siteName: config.TeamSettings.SiteName,
siteUrl: config.ServiceSettings.SiteURL,
teamName: '',
user: null,
};
}
// assumes the CYPRESS_* variables are set
// 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
context('ldap', () => {
let testChannel;
let testTeam;
let testUser;
describe('LDAP Group Sync Automated Tests', () => {
beforeEach(() => {
// # Login as sysadmin and add board-one to test team
cy.apiAdminLogin();
// * Check if server has license for LDAP
cy.apiRequireLicenseForFeature('LDAP');
// # Initial api setup
cy.apiInitSetup().then(({team, user}) => {
testTeam = team;
testUser = user;
// # Update LDAP settings
cy.apiGetConfig().then(({config}) => {
setLDAPTestSettings(config);
});
// # Link board group
cy.visit('/admin_console/user_management/groups');
cy.get('#board_group').then((el) => {
if (!el.text().includes('Edit')) {
// # Link the Group if its not linked before
if (el.find('.icon.fa-unlink').length > 0) {
el.find('.icon.fa-unlink').click();
}
}
});
// # Link developers group
cy.visit('/admin_console/user_management/groups');
cy.get('#developers_group').then((el) => {
if (!el.text().includes('Edit')) {
// # Link the Group if its not linked before
if (el.find('.icon.fa-unlink').length > 0) {
el.find('.icon.fa-unlink').click();
}
}
});
// # Create a test channel
cy.apiCreateChannel(testTeam.id, 'ldap-group-sync-automated-tests', 'ldap-group-sync-automated-tests').then(({channel}) => {
testChannel = channel;
});
});
});
it('MM-T1537 - Sync Group Removal from Channel Configuration Page', () => {
// # Link 2 groups to testChannel
cy.visit(`/admin_console/user_management/channels/${testChannel.id}`);
cy.get('.admin-console__header', {timeout: TIMEOUTS.ONE_MIN}).should('be.visible').and('have.text', 'Channel Configuration');
cy.wait(TIMEOUTS.TWO_SEC); //eslint-disable-line cypress/no-unnecessary-waiting
// # Link first group
cy.get('#addGroupsToChannelToggle').click();
cy.get('#multiSelectList').should('be.visible');
cy.get('#multiSelectList>div').children().eq(0).click();
cy.uiGetButton('Add').click();
// # Link second group
cy.get('#addGroupsToChannelToggle').click();
cy.get('#multiSelectList').should('be.visible');
cy.get('#multiSelectList>div').children().eq(0).click();
cy.uiGetButton('Add').click();
// # Click save settings on bottom screen to save settings
cy.get('#saveSetting').should('be.enabled').click();
cy.get('.admin-console__header', {timeout: TIMEOUTS.ONE_MIN}).should('be.visible').and('have.text', 'Mattermost Channels');
// # Go back to the testChannel management page
cy.visit(`/admin_console/user_management/channels/${testChannel.id}`);
cy.get('.admin-console__header', {timeout: TIMEOUTS.ONE_MIN}).should('be.visible').and('have.text', 'Channel Configuration');
// # Remove the board group we have added
cy.get('.group-row').eq(0).scrollIntoView().should('be.visible').within(() => {
cy.get('.group-name').should('have.text', 'board');
cy.get('.group-actions > a').should('have.text', 'Remove').click();
});
// # Save settings
cy.get('#saveSetting').should('be.enabled').click();
cy.get('.admin-console__header', {timeout: TIMEOUTS.ONE_MIN}).should('be.visible').and('have.text', 'Mattermost Channels');
// # Go back to testChannel management page
cy.visit(`/admin_console/user_management/channels/${testChannel.id}`);
cy.get('.admin-console__header', {timeout: TIMEOUTS.ONE_MIN}).should('be.visible').and('have.text', 'Channel Configuration');
// * Ensure we only have one group row (other group is not there)
cy.get('.group-row').should('have.length', 1);
});
it('MM-T2618 - Team Configuration Page: Group removal User removed from sync\'ed team', () => {
// # Add board-one to test team
cy.visit(`/admin_console/user_management/teams/${testTeam.id}`);
cy.get('.admin-console__header', {timeout: TIMEOUTS.ONE_MIN}).should('be.visible').and('have.text', 'Team Configuration');
cy.wait(TIMEOUTS.TWO_SEC); //eslint-disable-line cypress/no-unnecessary-waiting
// # Turn on sync group members
cy.findByTestId('syncGroupSwitch').
scrollIntoView().
findByRole('button').
click({force: true});
// # Add board group to team
cy.get('#addGroupsToTeamToggle').scrollIntoView().click();
cy.get('#multiSelectList').should('be.visible');
cy.get('#multiSelectList>div').children().eq(0).click();
cy.uiGetButton('Add').click().wait(TIMEOUTS.ONE_SEC);
// # Save settings
cy.get('#saveSetting').should('be.enabled').click();
// # Accept confirmation modal
cy.get('#confirmModalButton').should('be.visible').click();
cy.get('.admin-console__header', {timeout: TIMEOUTS.ONE_MIN}).should('be.visible').and('have.text', 'Mattermost Teams');
// # Go to board group edit page
cy.visit('/admin_console/user_management/groups');
cy.get('#board_edit').click();
// # Remove the group
cy.findByTestId(`${testTeam.display_name}_groupsyncable_remove`).click();
// * Ensure the confirmation modal shows with the following text
cy.get('#confirmModalBody').should('be.visible').and('have.text', `Removing this membership will prevent future users in this group from being added to the ${testTeam.display_name} team.`);
// # Accept the modal and save settings
cy.get('#confirmModalButton').should('be.visible').click();
cy.get('#saveSetting').click();
});
it('MM-T2621 - Team List Management Column', () => {
let testTeam2;
// # Go to testTeam config page
cy.visit(`/admin_console/user_management/teams/${testTeam.id}`);
cy.get('.admin-console__header', {timeout: TIMEOUTS.ONE_MIN}).should('be.visible').and('have.text', 'Team Configuration');
cy.wait(TIMEOUTS.TWO_SEC); //eslint-disable-line cypress/no-unnecessary-waiting
// # Make the team so anyone can join it
cy.findByTestId('allowAllToggleSwitch').scrollIntoView().click();
// # Save the settings
cy.get('#saveSetting').should('be.enabled').click();
cy.get('.admin-console__header', {timeout: TIMEOUTS.ONE_MIN}).should('be.visible').and('have.text', 'Mattermost Teams');
// # Start with a new team
cy.apiCreateTeam('team', 'Team').then(({team}) => {
testTeam2 = team;
// # Go to team management
cy.visit('/admin_console/user_management/teams');
// # Search for the team testTeam
cy.get('.DataGrid_searchBar').within(() => {
cy.findByPlaceholderText('Search').should('be.visible').type(`${testTeam.display_name}{enter}`);
});
// * Ensure anyone can join text shows
cy.findByTestId(`${testTeam.name}Management`).should('have.text', 'Anyone Can Join');
// * Search for second team we just made
cy.get('.DataGrid_searchBar').within(() => {
cy.findByPlaceholderText('Search').should('be.visible').clear().type(`${testTeam2.display_name}{enter}`);
});
// * Ensure the management text shows Invite only
cy.findByTestId(`${testTeam2.name}Management`).should('have.text', 'Invite Only');
});
});
it('MM-T2628 - List of Channels', () => {
// # Add board-one to test team
cy.visit(`/admin_console/user_management/channels/${testChannel.id}`);
cy.get('.admin-console__header', {timeout: TIMEOUTS.ONE_MIN}).should('be.visible').and('have.text', 'Channel Configuration');
cy.wait(TIMEOUTS.TWO_SEC); //eslint-disable-line cypress/no-unnecessary-waiting
// Make it private and then cancel
cy.findByTestId('allow-all-toggle').click();
cy.get('#cancelButtonSettings').click();
cy.get('#confirmModalButton').click();
cy.visit(`/admin_console/user_management/channels/${testChannel.id}`);
cy.get('.admin-console__header', {timeout: TIMEOUTS.ONE_MIN}).should('be.visible').and('have.text', 'Channel Configuration');
// * Ensure it still public
cy.findByTestId('allow-all-toggle').should('has.have.text', 'Public');
// Make it private and save
cy.findByTestId('allow-all-toggle').click();
cy.get('#saveSetting').should('be.enabled').click();
cy.get('#confirmModalButton').click();
// # Visit the channel config page for testChannel
cy.visit(`/admin_console/user_management/channels/${testChannel.id}`);
cy.get('.admin-console__header', {timeout: TIMEOUTS.ONE_MIN}).should('be.visible').and('have.text', 'Channel Configuration');
// * Ensure it is Private
cy.findByTestId('allow-all-toggle').should('has.have.text', 'Private');
// # Go to team page to look for this channel in public channel directory
cy.visit(`/${testTeam.name}`);
cy.uiBrowseOrCreateChannel('Browse Channels').click();
// * Search private channel name and make sure it isn't there in public channel directory
cy.get('#searchChannelsTextbox').type(testChannel.display_name);
cy.get('#moreChannelsList').should('include.text', 'No more channels to join');
});
it('MM-T2629 - Private to public - More....', () => {
// # Create new test channel that is private
cy.apiCreateChannel(
testTeam.id,
'private-channel-test',
'Private channel',
'P',
).then(({channel}) => {
const privateChannel = channel;
// # Visit channel configuration of private channel
cy.visit(`/admin_console/user_management/channels/${privateChannel.id}`);
cy.get('.admin-console__header', {timeout: TIMEOUTS.ONE_MIN}).should('be.visible').and('have.text', 'Channel Configuration');
// Make it public and then cancel
cy.findByTestId('allow-all-toggle').click();
cy.get('#cancelButtonSettings').click();
cy.get('#confirmModalButton').click();
cy.get('.admin-console__header', {timeout: TIMEOUTS.ONE_MIN}).should('be.visible').and('have.text', 'Mattermost Channels');
// Reload
cy.visit(`/admin_console/user_management/channels/${privateChannel.id}`);
cy.get('.admin-console__header', {timeout: TIMEOUTS.ONE_MIN}).should('be.visible').and('have.text', 'Channel Configuration');
cy.wait(TIMEOUTS.THREE_SEC); //eslint-disable-line cypress/no-unnecessary-waiting
// Make it public and save
// * Ensure it still showing the channel as private
cy.findByTestId('allow-all-toggle').should('has.have.text', 'Private').click();
cy.get('#saveSetting').should('be.enabled').click();
cy.get('#confirmModalButton').click();
cy.get('.admin-console__header', {timeout: TIMEOUTS.ONE_MIN}).should('be.visible').and('have.text', 'Mattermost Channels');
// Reload
cy.visit(`/admin_console/user_management/channels/${privateChannel.id}`);
cy.get('.admin-console__header', {timeout: TIMEOUTS.ONE_MIN}).should('be.visible').and('have.text', 'Channel Configuration');
// * Ensure it still showing the channel as private
cy.findByTestId('allow-all-toggle').should('has.have.text', 'Public');
// # Ensure the last message in the message says that it was converted to a public channel
cy.visit(`/${testTeam.name}/channels/${privateChannel.name}`);
cy.getLastPostId().then((id) => {
// * The system message should contain 'This channel has been converted to a Public Channel and can be joined by any team member'
cy.get(`#postMessageText_${id}`).should('contain', 'This channel has been converted to a Public Channel and can be joined by any team member');
});
});
});
it('MM-T2630 - Default channel cannot be toggled to private', () => {
cy.visit('/admin_console/user_management/channels');
// # Search for the channel town square
cy.get('.DataGrid_searchBar').within(() => {
cy.findByPlaceholderText('Search').should('be.visible').type('Town Square');
});
cy.wait(TIMEOUTS.FIVE_SEC); //eslint-disable-line cypress/no-unnecessary-waiting
cy.findAllByTestId('town-squareedit').then((elements) => {
elements[0].click();
cy.get('.admin-console__header', {timeout: TIMEOUTS.ONE_MIN}).should('be.visible').and('have.text', 'Channel Configuration');
// * Ensure the toggle to private/public is disabled
cy.findByTestId('allow-all-toggle-button').should('be.disabled');
});
});
it('MM-T2638 - Permalink from when public does not auto-join (non-system-admin) after converting to private', () => {
cy.apiLogin(testUser);
cy.visit(`/${testTeam.name}/channels/${testChannel.name}`);
// # Post message to use
cy.postMessage('DONT YOU SEE I GOT EVERYTHING YOU NEED .... BABY BABY DONT YOU SEE SEE I GOT EVERYTHING YOU NEED NEED ... ;)');
cy.getLastPostId().then((id) => {
const postId = id;
// # Visit the channel
cy.visit(`/${testTeam.name}/channels/${testChannel.name}`);
// # Post /leave command in testChannel to leave it
cy.postMessage('/leave ');
cy.get('#channelHeaderTitle', {timeout: TIMEOUTS.ONE_MIN}).should('be.visible').and('contain', 'Town Square');
// Visit the permalink link
cy.visit(`/${testTeam.name}/pl/${postId}`);
// * Ensure the header of the permalink channel is what we expect it to be (testChannel)
cy.get('#channelHeaderTitle', {timeout: TIMEOUTS.ONE_MIN}).should('be.visible').and('contain', testChannel.display_name);
// # Leave the channel again
cy.postMessage('/leave ');
cy.get('#channelHeaderTitle', {timeout: TIMEOUTS.ONE_MIN}).should('be.visible').and('contain', 'Town Square');
// # Login as sysadmin and convert testChannel to private channel
cy.apiAdminLogin();
cy.apiPatchChannelPrivacy(testChannel.id, 'P');
// # Login as normal user and try to visit the permalink
cy.apiLogin(testUser);
cy.visit(`/${testTeam.name}/pl/${postId}`);
// * We expect an error that says "Message not found"
cy.findByTestId('errorMessageTitle').contains('Message Not Found');
});
});
it('MM-T2639 - Policy settings (in System Console tests, likely)', () => {
// # Reset system scheme permission
cy.uiResetPermissionsToDefault();
// # Login as testUser and go to channel configuration page of testChannel
cy.apiLogin(testUser);
cy.visit(`/${testTeam.name}/channels/${testChannel.name}`);
// # Go to manage members rhs and ensure that we can add members to it
cy.get('.member-rhs__trigger').click();
cy.uiGetRHS().contains('button', 'Add').should('exist').click();
// * Assess that label is visible and it says we can add new members
cy.get('#addUsersToChannelModal').should('be.visible').findByText(`Add people to ${testChannel.display_name}`);
// # Login as sysadmin and navigate to system scheme page and check off all users can manage private manage channels
cy.apiAdminLogin();
cy.visit('/admin_console/user_management/permissions/system_scheme');
cy.findByTestId('all_users-private_channel-checkbox').click();
// # Save the settings
cy.uiSaveConfig();
// # Login as sysadmin and convert testChannel to private channel
cy.apiPatchChannelPrivacy(testChannel.id, 'P');
// # Go back to the channel
cy.apiLogin(testUser);
cy.visit(`/${testTeam.name}/channels/${testChannel.name}`);
// # Go to manage member modal
cy.get('.member-rhs__trigger').click();
// * Assert that the label doesn't exist anymore mentioning we can invite members
cy.uiGetRHS().contains('button', 'Add').should('not.exist');
});
it('MM-T2640 - Channel appears in channel switcher before conversion but not after (for non-members of the channel)', () => {
// # Reset system scheme permissions
cy.uiResetPermissionsToDefault();
// # Create new test channel that is public
cy.apiCreateChannel(
testTeam.id,
'a-channel-im-not-apart-off',
'Public channel',
'O',
).then(({channel: publicChannel}) => {
cy.apiLogin(testUser);
cy.visit(`/${testTeam.name}/channels/${testChannel.name}`);
// # Open Find Channels
cy.uiOpenFindChannels();
// * Channel switcher hint should be visible
cy.get('#quickSwitchHint', {timeout: TIMEOUTS.TWO_SEC}).should('be.visible').should('contain', 'Type to find a channel. Use UP/DOWN to browse, ENTER to select, ESC to dismiss.');
cy.wait(TIMEOUTS.THREE_SEC);
// # Type channel display name on Channel switcher input
cy.findByRole('textbox', {name: 'quick switch input'}).type(publicChannel.display_name);
cy.wait(TIMEOUTS.HALF_SEC);
// * Should open up suggestion list for channels
// * Should match each channel item and group label
cy.get('#suggestionList').should('be.visible').children().within((el) => {
cy.wrap(el).should('contain', publicChannel.display_name);
});
// # Login as a admin and make channel private
cy.apiAdminLogin();
cy.apiPatchChannelPrivacy(publicChannel.id, 'P');
// # Login as normal user
cy.apiLogin(testUser);
cy.visit(`/${testTeam.name}/channels/${testChannel.name}`);
// # Open Find Channels
cy.uiOpenFindChannels();
// * Channel switcher hint should be visible
cy.get('#quickSwitchHint', {timeout: TIMEOUTS.TWO_SEC}).should('be.visible').should('contain', 'Type to find a channel. Use UP/DOWN to browse, ENTER to select, ESC to dismiss.');
cy.wait(TIMEOUTS.THREE_SEC);
// # Type channel display name on Channel switcher input
cy.findByRole('textbox', {name: 'quick switch input'}).type(publicChannel.display_name);
cy.wait(TIMEOUTS.HALF_SEC);
// * Should open up suggestion list for channels
// * should no results after looking for channel
cy.get('.no-results__title').should('be.visible').and('contain.text', 'No results for');
});
});
it('MM-T2641 - Channel appears in More... under Public Channels before conversion but not after', () => {
// # Create new test channel that is public
cy.apiCreateChannel(
testTeam.id,
'a-channel-im-not-apart-off',
'Public channel',
'O',
).then(({channel: publicChannel}) => {
cy.apiLogin(testUser);
// # Visit off-topic channel
cy.visit(`/${testTeam.name}/channels/off-topic`);
// # Go to LHS and click 'Browse Channels'
cy.uiBrowseOrCreateChannel('Browse Channels').click();
// * Search public channel and ensure it appears in the list
cy.get('#searchChannelsTextbox').type(publicChannel.display_name);
cy.get('#moreChannelsList').should('include.text', publicChannel.display_name);
// # login as a admin and revert to private channel
cy.apiAdminLogin();
cy.apiPatchChannelPrivacy(publicChannel.id, 'P');
// # Login as a normal user
cy.apiLogin(testUser);
// # Visit off-topic channel
cy.visit(`/${testTeam.name}/channels/off-topic`);
// # Go to LHS and click 'Browse Channels'
cy.uiBrowseOrCreateChannel('Browse Channels').click();
// * Search private channel name and make sure it isn't there in public channel directory
cy.get('#searchChannelsTextbox').type(publicChannel.display_name);
cy.get('#moreChannelsList').should('include.text', 'No more channels to join');
});
});
it('MM-T2642 - Channel appears in Integrations options before conversion but not after', () => {
cy.visit(`/${testTeam.name}/channels/${testChannel.name}`);
// # Go to integrations
cy.visit(`/${testTeam.name}/integrations`);
// # Go to outgoing webhooks and then add out going web hooks page
cy.get('#outgoingWebhooks', {timeout: TIMEOUTS.ONE_MIN}).should('be.visible').click();
cy.get('#addOutgoingWebhook', {timeout: TIMEOUTS.ONE_MIN}).should('be.visible').click();
// * In the channel select options, ensure our display name appears
cy.get('#channelSelect').children().should('contain.text', testChannel.display_name);
// # Make channel private
cy.apiPatchChannelPrivacy(testChannel.id, 'P');
// # Go to integrations
cy.visit(`/${testTeam.name}/integrations`);
// # Go to outgoing webhooks and then add out going web hooks page
cy.get('#outgoingWebhooks', {timeout: TIMEOUTS.ONE_MIN}).should('be.visible').click();
cy.get('#addOutgoingWebhook', {timeout: TIMEOUTS.ONE_MIN}).should('be.visible').click();
// * Ensure that our channel name doesn't appear in the list of options
cy.get('#channelSelect').children().should('not.contain.text', testChannel.display_name);
});
});
});

Просмотреть файл

@@ -0,0 +1,322 @@
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
// ***************************************************************
// - [#] indicates a test step (e.g. #. Go to a page)
// - [*] indicates an assertion (e.g. * Check the title)
// - Use element ID when selecting an element. Create one if none.
// ***************************************************************
// Stage: @prod
// Group: @channels @enterprise @ldap
import ldapUsers from '../../../../fixtures/ldap_users.json';
import * as TIMEOUTS from '../../../../fixtures/timeouts';
import {getAdminAccount} from '../../../../support/env';
import {getRandomId} from '../../../../utils';
// 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
describe('LDAP guest', () => {
let testSettings;
let user1Data;
let user2Data;
const user1 = ldapUsers['test-2'];
const user2 = ldapUsers['test-3'];
const userBoard1 = ldapUsers['board-1'];
before(() => {
// * Check if server has license for LDAP
cy.apiRequireLicenseForFeature('LDAP');
// # Test LDAP configuration and server connection
// # Synchronize user attributes
cy.apiLDAPTest();
cy.apiLDAPSync();
// # Get testSettings
cy.apiGetConfig().then(({config}) => {
testSettings = setLDAPTestSettings(config);
});
// # Get user1 data
cy.apiLogin(user1).then(({user}) => {
user1Data = user;
// # Remove user1 from all the teams
removeUserFromAllTeams(user1Data);
});
// # Get user2 data
cy.apiLogin(user2).then(({user}) => {
user2Data = user;
// # Remove user2 fromm all the teams
removeUserFromAllTeams(user2Data);
});
});
beforeEach(() => {
// # Login as admin
cy.apiAdminLogin();
// # Make sure LDAP users are not guests
promoteGuestToUser(user1Data);
promoteGuestToUser(user2Data);
});
it('MM-T1422 LDAP Guest Filter', () => {
// # Go to LDAP settings page and update guest filter as user1
gotoLDAPSettings();
updateGuestFilter(`(uid=${user1.username})`);
// # Login as LDAP user1
testSettings.user = user1;
cy.doLDAPLogin(testSettings);
// * Verify select teams page is loaded
cy.get('.select-team__container', {timeout: TIMEOUTS.ONE_MIN}).should('be.visible');
// * Verify user does not have access to any team or channel
cy.get('.signup__content').should('have.text', 'Your guest account has no channels assigned. Please contact an administrator.');
// # Logout of LDAP user
cy.apiLogout().then(() => {
// # Login as admin
cy.apiAdminLogin();
// # Go to LDAP settings page and EMPTY guest filter value
gotoLDAPSettings();
updateGuestFilter('');
// # Login again as LDAP user1
testSettings.user = user1;
cy.doLDAPLogin(testSettings);
// * Verify select teams page is loaded
cy.get('.select-team__container', {timeout: TIMEOUTS.ONE_MIN}).should('be.visible');
// * Verify user1 is still a guest user
cy.get('#createNewTeamLink').should('not.exist');
cy.apiLogout().then(() => {
// # Login again as LDAP user2
testSettings.user = user2;
cy.doLDAPLogin(testSettings);
// * Verify select teams page is loaded
cy.get('.select-team__container', {timeout: TIMEOUTS.ONE_MIN}).should('be.visible');
// * Verify user2 is not a guest
cy.get('#createNewTeamLink').should('exist');
});
});
});
it('MM-T1424 LDAP Guest Filter behavior when Guest Access is disabled', () => {
// # Go to Guest access page and enable guest access
gotoGuestAccessSettings();
setGuestAccess(true);
// # Go to LDAP settings page and update guest filter as user1
gotoLDAPSettings();
updateGuestFilter(`(uid=${user1.username})`);
// # Go to Guest access page and disable guest access
gotoGuestAccessSettings();
setGuestAccess(false);
// # Go to LDAP settings page
gotoLDAPSettings();
cy.findByTestId('LdapSettings.GuestFilterinput').should('have.attr', 'disabled');
// # Go to SAML settings page
cy.visit('/admin_console/authentication/saml');
cy.get('.admin-console__header', {timeout: TIMEOUTS.ONE_MIN}).should('be.visible').and('have.text', 'SAML 2.0');
cy.findByTestId('SamlSettings.GuestAttributeinput').should('be.disabled');
// # Login again as LDAP user1
testSettings.user = user1;
cy.doLDAPLogin(testSettings);
// * Verify select teams page is loaded
cy.get('.select-team__container', {timeout: TIMEOUTS.ONE_MIN}).should('be.visible');
// * Verify user1 is not a guest
cy.get('#createNewTeamLink').should('exist');
});
it('MM-T1425 LDAP Guest Filter Change', () => {
// # Go to Guest access page and enable guest access
gotoGuestAccessSettings();
setGuestAccess(true);
// # Login as LDAP user2
testSettings.user = user2;
cy.doLDAPLogin(testSettings);
// # Create team if no membership
cy.skipOrCreateTeam(testSettings, getRandomId()).then(() => {
// * Verify user is a member
cy.findByRole('button', {name: 'Add Channel Dropdown'}).should('exist');
// # Demote the user
demoteUserToGuest(user2Data);
// # Logout of LDAP user
cy.apiLogout().then(() => {
// # Login again
cy.doLDAPLogin(testSettings);
// * Check if user is in the team
cy.uiAddDirectMessage().should('exist');
// * Check the user is a guest
cy.findByRole('button', {name: 'Add Channel Dropdown'}).should('not.exist');
});
});
});
it('MM-T1427 Prevent Invite Guest for LDAP Group Synced Teams', () => {
// # Create a new team
cy.apiCreateTeam('team', 'Team').then(({team}) => {
// # Get available ldap groups
cy.apiGetLDAPGroups().then((result) => {
// # Find "board" group
const board = result.body.groups.find((group) => group.name === 'board');
// # Link group
cy.apiLinkGroup(board.primary_key).then(() => {
// # Add board-one to test team
cy.visit(`/admin_console/user_management/teams/${team.id}`);
cy.get('.admin-console__header', {timeout: TIMEOUTS.ONE_MIN}).should('be.visible').and('have.text', 'Team Configuration');
// # Turn on sync group members
cy.findByTestId('syncGroupSwitch').scrollIntoView().click();
// # Add board group to team
cy.get('#addGroupsToTeamToggle').scrollIntoView().click();
cy.get('#multiSelectList').should('be.visible');
cy.get('#multiSelectList>div').children().eq(0).click();
cy.uiGetButton('Add').click();
// # Save settings
cy.get('#saveSetting').should('be.enabled').click();
// # Accept confirmation modal
cy.get('#confirmModalButton').should('be.visible').click();
cy.get('.admin-console__header', {timeout: TIMEOUTS.ONE_MIN}).should('be.visible').and('have.text', 'Mattermost Teams');
// # Login as board.one user
testSettings.user = userBoard1;
cy.doLDAPLogin(testSettings);
cy.wait(TIMEOUTS.TWO_SEC);
// # Go to the new team
cy.visit(`/${team.name}/channels/town-square`);
// # Open team menu and click 'Invite People'
cy.uiOpenTeamMenu('Invite People');
cy.wait(TIMEOUTS.TWO_SEC);
// # Option to invite guest should not be visible
cy.findByTestId('inviteGuestLink').should('not.exist');
});
});
});
});
});
function gotoGuestAccessSettings() {
cy.visit('/admin_console/authentication/guest_access');
cy.get('.admin-console__header', {timeout: TIMEOUTS.ONE_MIN}).should('be.visible').and('have.text', 'Guest Access');
}
function gotoLDAPSettings() {
// # Go to settings page and wait until page is loaded
cy.visit('/admin_console/authentication/ldap');
cy.get('.admin-console__header', {timeout: TIMEOUTS.ONE_MIN}).should('be.visible').and('have.text', 'AD/LDAP');
}
function promoteGuestToUser(user) {
// # Issue a Request to promote the guest to user
// Ignoring the response status as it won't be 200 if user is not a guest
cy.task('externalRequest', {
user: getAdminAccount(),
method: 'post',
baseUrl: Cypress.config('baseUrl'),
path: `users/${user.id}/promote`,
});
}
function demoteUserToGuest(user) {
// # Issue a Request to demote the user to guest
cy.task('externalRequest', {
user: getAdminAccount(),
method: 'post',
baseUrl: Cypress.config('baseUrl'),
path: `users/${user.id}/demote`,
});
}
function removeUserFromAllTeams(user) {
// # Get all teams of a user
cy.apiGetTeamsForUser(user.id).then(({teams}) => {
// # Remove user from all the teams
teams.forEach((team) => {
cy.apiDeleteUserFromTeam(team.id, user.id);
});
});
}
function setGuestAccess(enable) {
const inputId = 'GuestAccountsSettings.' + (enable ? 'Enabletrue' : 'Enablefalse');
cy.findByTestId(inputId).then((elem) => {
// Proceed only if it's not already checked
if (!Cypress.$(elem).is(':checked')) {
// # Check the radio button
cy.findByTestId(inputId).check().should('be.checked');
// # Save settings
cy.findByTestId('saveSetting').click();
if (!enable) {
// # Confirm the modal button
cy.get('#confirmModalButton').click();
}
waitUntilConfigSave();
}
});
}
function setLDAPTestSettings(config) {
return {
siteName: config.TeamSettings.SiteName,
siteUrl: config.ServiceSettings.SiteURL,
teamName: '',
user: null,
};
}
function updateGuestFilter(value) {
// # Set guest filter value
if (value) {
cy.findByTestId('LdapSettings.GuestFilterinput').type(value);
} else {
cy.findByTestId('LdapSettings.GuestFilterinput').clear();
}
// # Save config settings and wait until saved
cy.findByTestId('saveSetting').click();
waitUntilConfigSave();
}
// # Wait's until the Saving text becomes Save
const waitUntilConfigSave = () => {
cy.waitUntil(() => cy.findByTestId('saveSetting').then((el) => {
return el[0].innerText === 'Save';
}));
};

Просмотреть файл

@@ -0,0 +1,240 @@
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
// ***************************************************************
// - [#] indicates a test step (e.g. #. Go to a page)
// - [*] indicates an assertion (e.g. * Check the title)
// - Use element ID when selecting an element. Create one if none.
// ***************************************************************
// Stage: @prod
// Group: @channels @enterprise @ldap
import ldapUsers from '../../../../fixtures/ldap_users.json';
import {getRandomId} from '../../../../utils';
// assumes the CYPRESS_* variables are set
// 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
context('ldap', () => {
const user1 = ldapUsers['test-1'];
const guest1 = ldapUsers['board-1'];
const admin1 = ldapUsers['dev-1'];
let testSettings;
before(() => {
// * Check if server has license for LDAP
cy.apiRequireLicenseForFeature('LDAP');
// # Test LDAP configuration and server connection
// # Synchronize user attributes
cy.apiLDAPTest();
cy.apiLDAPSync();
cy.apiGetConfig().then(({config}) => {
testSettings = setLDAPTestSettings(config);
});
removeUserFromAllTeams(user1);
removeUserFromAllTeams(guest1);
removeUserFromAllTeams(admin1);
disableOnboardingTaskList(user1);
disableOnboardingTaskList(guest1);
disableOnboardingTaskList(admin1);
cy.apiAdminLogin();
});
describe('LDAP Login flow - Admin Login', () => {
it('MM-T2821 LDAP Admin Filter', () => {
testSettings.user = admin1;
const ldapSetting = {
LdapSettings: {
EnableAdminFilter: true,
AdminFilter: '(cn=dev*)',
},
};
cy.apiUpdateConfig(ldapSetting).then(() => {
cy.doLDAPLogin(testSettings).then(() => {
// # Skip or create team
cy.skipOrCreateTeam(testSettings, getRandomId()).then(() => {
cy.uiGetLHSHeader().then((teamName) => {
testSettings.teamName = teamName.text();
});
// # Do LDAP logout
cy.doLDAPLogout(testSettings);
});
});
});
});
it('LDAP login existing MM admin', () => {
// existing user, verify and logout
cy.doLDAPLogin(testSettings).then(() => {
// # Do LDAP logout
cy.doLDAPLogout(testSettings);
});
});
});
describe('LDAP Login flow - Member Login)', () => {
it('Invalid login with user filter', () => {
testSettings.user = user1;
const ldapSetting = {
LdapSettings: {
UserFilter: '(cn=no_users)',
},
};
cy.apiAdminLogin().then(() => {
cy.apiUpdateConfig(ldapSetting).then(() => {
cy.doLDAPLogin(testSettings).then(() => {
// * Verify login failed
cy.checkLoginFailed(testSettings);
});
});
});
});
it('LDAP login, new MM user, no channels', () => {
testSettings.user = user1;
const ldapSetting = {
LdapSettings: {
UserFilter: '(cn=test*)',
},
};
cy.apiAdminLogin().then(() => {
cy.apiUpdateConfig(ldapSetting).then(() => {
cy.doLDAPLogin(testSettings).then(() => {
// # Do member logout from sign up
cy.doMemberLogoutFromSignUp(testSettings);
});
});
});
});
});
describe('LDAP Login flow - Guest Login', () => {
it('Invalid login with guest filter', () => {
testSettings.user = guest1;
const ldapSetting = {
LdapSettings: {
UserFilter: '(cn=no_users)',
GuestFilter: '(cn=no_guests)',
},
};
cy.apiAdminLogin().then(() => {
cy.apiUpdateConfig(ldapSetting).then(() => {
cy.doLDAPLogin(testSettings).then(() => {
// * Verify login failed
cy.checkLoginFailed(testSettings);
});
});
});
});
it('LDAP login, new guest, no channels', () => {
testSettings.user = guest1;
const ldapSetting = {
LdapSettings: {
UserFilter: '(cn=no_users)',
GuestFilter: '(cn=board*)',
},
};
cy.apiAdminLogin().then(() => {
cy.apiUpdateConfig(ldapSetting).then(() => {
cy.doLDAPLogin(testSettings).then(() => {
// # Do logout from sign up
cy.doLogoutFromSignUp(testSettings);
});
});
});
});
});
describe('LDAP Add Member and Guest to teams and test logins', () => {
before(() => {
cy.apiAdminLogin();
cy.apiGetTeamByName(testSettings.teamName).then(({team}) => {
cy.apiGetChannelByName(testSettings.teamName, 'town-square').then(({channel}) => {
cy.apiGetUserByEmail(guest1.email).then(({user}) => {
cy.apiAddUserToTeam(team.id, user.id).then(() => {
cy.apiAddUserToChannel(channel.id, user.id);
});
});
// add member user to team
cy.apiGetUserByEmail(user1.email).then(({user}) => {
cy.apiAddUserToTeam(team.id, user.id);
});
});
});
});
it('LDAP Member login with team invite', () => {
testSettings.user = user1;
const ldapSetting = {
LdapSettings: {
UserFilter: '(cn=test*)',
},
};
cy.apiAdminLogin().then(() => {
cy.apiUpdateConfig(ldapSetting).then(() => {
cy.doLDAPLogin(testSettings).then(() => {
// # Do LDAP logout
cy.doLDAPLogout(testSettings);
});
});
});
});
it('LDAP Guest login with team invite', () => {
testSettings.user = guest1;
const ldapSetting = {
LdapSettings: {
GuestFilter: '(cn=board*)',
},
};
cy.apiAdminLogin().then(() => {
cy.apiUpdateConfig(ldapSetting).then(() => {
cy.doLDAPLogin(testSettings).then(() => {
// # Do LDAP logout
cy.doLDAPLogout(testSettings);
});
});
});
});
});
});
function setLDAPTestSettings(config) {
return {
siteName: config.TeamSettings.SiteName,
siteUrl: config.ServiceSettings.SiteURL,
teamName: '',
user: null,
};
}
function disableOnboardingTaskList(ldapLogin) {
cy.apiLogin(ldapLogin).then(({user}) => {
cy.apiSaveOnboardingTaskListPreference(user.id, 'onboarding_task_list_open', 'false');
cy.apiSaveOnboardingTaskListPreference(user.id, 'onboarding_task_list_show', 'false');
cy.apiSaveSkipStepsPreference(user.id, 'true');
});
}
function removeUserFromAllTeams(testUser) {
cy.apiGetUsersByUsernames([testUser.username]).then(({users}) => {
users.forEach((user) => {
cy.apiGetTeamsForUser(user.id).then(({teams}) => {
teams.forEach((team) => {
cy.apiDeleteUserFromTeam(team.id, user.id);
});
});
});
});
}

Просмотреть файл

@@ -0,0 +1,82 @@
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
// ***************************************************************
// - [#] indicates a test step (e.g. #. Go to a page)
// - [*] indicates an assertion (e.g. * Check the title)
// - Use element ID when selecting an element. Create one if none.
// ***************************************************************
// Stage: @prod
// Group: @channels @enterprise @ldap
// assumes the CYPRESS_* variables are set
// 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
describe('LDAP settings', () => {
beforeEach(() => {
// # Login as sysadmin
cy.apiAdminLogin();
// * Check if server has license for LDAP
cy.apiRequireLicenseForFeature('LDAP');
});
it('MM-T2699 Connection test button - Successful', () => {
// # Load AD/LDAP page in system console
cy.visitLDAPSettings();
// # Click "AD/LDAP Test"
cy.findByRole('button', {name: /ad\/ldap test/i}).click();
// * Confirmation message saying the connection is successful.
cy.findByText(/ad\/ldap test successful/i).should('be.visible');
cy.findByTitle(/success icon/i).should('be.visible');
});
it('MM-T2700 LDAP username required', () => {
cy.visitLDAPSettings();
// # Remove text from Username Attribute
cy.findByLabelText(/username attribute:/i).click().clear();
// # Click Save
cy.findByRole('button', {name: /save/i}).click();
// * Verifying message "AD/LDAP field "Username Attribute" is required."
cy.findByText('AD/LDAP field "Username Attribute" is required.').should('be.visible');
// # Set back to what it was
cy.findByLabelText(/username attribute:/i).click().type('uid');
cy.findByRole('button', {name: /save/i}).click();
cy.findByRole('button', {name: /save/i}).should('be.disabled');
});
it('MM-T2701 LDAP LoginidAttribute required', () => {
cy.visitLDAPSettings();
// # Try to save LDAP settings with blank Loginid
cy.findByTestId('LdapSettings.LoginIdAttributeinput').click().clear();
cy.findByRole('button', {name: /save/i}).click();
// * Verifying Error Message
cy.findByText(/ad\/ldap field "login id attribute" is required./i).should('be.visible');
});
it('MM-T2704 Create new LDAP account from login page', () => {
const testSettings = {
user: {
username: 'test.two',
password: 'Password1',
},
siteName: 'Mattermost',
};
// # Login as a new LDAP user
cy.doLDAPLogin(testSettings);
// * Verify user is logged in Successfully
cy.findByText(/logout/i).should('be.visible');
});
});