* Split Settings::Authentication from SiteConfig * Move specs * Sort fields * Update settings usages * Update recaptcha usages * Add data update script * Update spec * Rename SiteConfigParams concern * Fixes, new route, new controller * Controller and service refactoring * More controller and service updates * Spec updates * More spec fixes * Move file * Fix FeedbackMessagesController * Update admin/configs_spec * Fix remaining specs in admin/configs_spec * Fix configs API * Formatting * Clean up old service object * Various fixes * Update DUS * Add model argument to admin_config_label * Fix key name * Fix specs * Add distinct request caches for settings classes * Fix e2e tests * Fix remaining system spec * Make DUS idempotent * Move routes block * Cleanup * Switch to ActiveSupport::CurrentAttributes * Pinned rails-settings-cached * Update e2e test * Update lib/data_update_scripts/20210316091354_move_authentication_settings.rb Co-authored-by: rhymes <rhymes@hey.com> * Add guard to DUS * Temporarily re-add two SiteConfig fields * Fix config show view Co-authored-by: rhymes <rhymes@hey.com>
136 lines
4.9 KiB
JavaScript
136 lines
4.9 KiB
JavaScript
describe('Authentication Section', () => {
|
|
beforeEach(() => {
|
|
cy.testSetup();
|
|
cy.fixture('users/adminUser.json').as('user');
|
|
|
|
cy.get('@user').then((user) => {
|
|
cy.loginUser(user).then(() => {
|
|
cy.updateAdminAuthConfig(user.username);
|
|
});
|
|
});
|
|
});
|
|
|
|
describe('invite-only mode setting', () => {
|
|
it('should disable email registration and all authorization providers when enabled', () => {
|
|
cy.fixture('users/adminUser.json').as('user');
|
|
|
|
cy.get('@user').then(({ username }) => {
|
|
cy.updateAdminAuthConfig(username, {
|
|
authProvidersToEnable: 'facebook',
|
|
facebookKey: 'somekey',
|
|
facebookSecret: 'somesecret',
|
|
}).then(() => {
|
|
cy.visit('/admin/config');
|
|
cy.findByTestId('authSectionForm').as('authSectionForm');
|
|
|
|
cy.get('@authSectionForm').findByText('Authentication').click();
|
|
cy.get('@authSectionForm')
|
|
.findByLabelText('Invite-only mode')
|
|
.should('not.be.checked')
|
|
.check();
|
|
|
|
cy.get('@authSectionForm')
|
|
.findByPlaceholderText('Confirmation text')
|
|
.type(
|
|
`My username is @${username} and this action is 100% safe and appropriate.`,
|
|
);
|
|
cy.get('@authSectionForm')
|
|
.findByText('Update Site Configuration')
|
|
.click();
|
|
|
|
cy.url().should('contains', '/admin/config');
|
|
|
|
// Page reloaded so need to get a new reference to the form.
|
|
cy.findByTestId('authSectionForm').as('authSectionForm');
|
|
|
|
cy.findByText('Site configuration was successfully updated.').should(
|
|
'be.visible',
|
|
);
|
|
|
|
cy.get('@authSectionForm').findByText('Authentication').click();
|
|
|
|
cy.get('@authSectionForm')
|
|
.findByLabelText('Invite-only mode')
|
|
.should('be.checked');
|
|
|
|
// Ensure that none of the authentication providers are enabled.
|
|
cy.findByLabelText('Email enabled').should('not.be.visible');
|
|
cy.findByLabelText('Facebook enabled').should('not.be.visible');
|
|
cy.findByLabelText('GitHub enabled').should('not.be.visible');
|
|
cy.findByLabelText('Twitter enabled').should('not.be.visible');
|
|
});
|
|
});
|
|
cy.visit('/signout_confirm');
|
|
|
|
cy.findByText('Yes, sign out').click();
|
|
cy.findByText('Create account').click();
|
|
|
|
cy.findByLabelText('Sign up with Email').should('not.exist');
|
|
cy.findByLabelText('Sign up with Facebook').should('not.exist');
|
|
cy.contains('invite only').should('be.visible');
|
|
});
|
|
});
|
|
|
|
describe('authentication providers settings', () => {
|
|
it('should display warning modal if provider keys are missing', () => {
|
|
cy.fixture('users/adminUser.json').as('user');
|
|
cy.get('@user').then(() => {
|
|
cy.visit('/admin/config');
|
|
cy.findByTestId('authSectionForm').as('authSectionForm');
|
|
|
|
cy.get('@authSectionForm').findByText('Authentication').click();
|
|
cy.get('#facebook-auth-btn').click();
|
|
cy.get('@user').then(({ username }) => {
|
|
cy.get('@authSectionForm')
|
|
.findByPlaceholderText('Confirmation text')
|
|
.type(
|
|
`My username is @${username} and this action is 100% safe and appropriate.`,
|
|
);
|
|
});
|
|
cy.get('@authSectionForm')
|
|
.findByText('Update Site Configuration')
|
|
.click();
|
|
|
|
cy.get('.crayons-modal__box__body > ul > li')
|
|
.contains('facebook')
|
|
.should('be.visible');
|
|
});
|
|
});
|
|
|
|
it('should not display warning modal if provider keys present', () => {
|
|
cy.fixture('users/adminUser.json').as('user');
|
|
|
|
cy.get('@user').then(() => {
|
|
cy.visit('/admin/config');
|
|
cy.findByTestId('authSectionForm').as('authSectionForm');
|
|
|
|
cy.get('@authSectionForm').findByText('Authentication').click();
|
|
cy.get('#facebook-auth-btn').click();
|
|
cy.get('#settings_authentication_facebook_key').type('randomkey');
|
|
cy.get('#settings_authentication_facebook_secret').type('randomsecret');
|
|
cy.get('@user').then(({ username }) => {
|
|
cy.get('@authSectionForm')
|
|
.findByPlaceholderText('Confirmation text')
|
|
.type(
|
|
`My username is @${username} and this action is 100% safe and appropriate.`,
|
|
);
|
|
});
|
|
cy.get('@authSectionForm')
|
|
.findByText('Update Site Configuration')
|
|
.click();
|
|
|
|
cy.url().should('contains', '/admin/config');
|
|
|
|
cy.findByText('Site configuration was successfully updated.').should(
|
|
'be.visible',
|
|
);
|
|
|
|
// Page reloaded so need to get a new reference to the form.
|
|
cy.findByTestId('authSectionForm').as('authSectionForm');
|
|
cy.get('@authSectionForm').findByText('Authentication').click();
|
|
|
|
cy.findByLabelText('Facebook enabled').should('be.visible');
|
|
});
|
|
});
|
|
});
|
|
});
|