2020-11-22 15:50:07 -05:00
|
|
|
/*
|
2023-09-24 16:56:31 -04:00
|
|
|
* SPDX-FileCopyrightText: 2023 The HedgeDoc developers (see AUTHORS file)
|
2020-11-22 15:50:07 -05:00
|
|
|
*
|
|
|
|
* SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
*/
|
2022-04-15 17:03:15 -04:00
|
|
|
import { AuthProviderType } from '../../src/api/config/types'
|
2023-05-29 11:32:44 -04:00
|
|
|
import { HttpMethod } from '../../src/handler-utils/respond-to-matching-request'
|
2023-10-24 02:57:42 -04:00
|
|
|
import { IGNORE_MOTD, MOTD_LOCAL_STORAGE_KEY } from '../../src/components/global-dialogs/motd-modal/local-storage-keys'
|
2022-04-15 17:03:15 -04:00
|
|
|
|
2021-03-09 17:00:14 -05:00
|
|
|
declare namespace Cypress {
|
|
|
|
interface Chainable {
|
2023-09-24 16:56:31 -04:00
|
|
|
loadConfig(additionalConfig?: Partial<typeof config>): Chainable<Window>
|
|
|
|
logIn: Chainable<Window>
|
2023-09-10 02:54:03 -04:00
|
|
|
logOut: Chainable<Window>
|
2021-03-09 17:00:14 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-07-18 16:17:36 -04:00
|
|
|
export const branding = {
|
2021-03-09 17:03:54 -05:00
|
|
|
name: 'DEMO Corp',
|
2023-08-12 14:07:38 -04:00
|
|
|
logo: '/public/img/demo.png'
|
2020-07-18 16:17:36 -04:00
|
|
|
}
|
|
|
|
|
2022-04-15 17:03:15 -04:00
|
|
|
export const authProviders = [
|
|
|
|
{
|
|
|
|
type: AuthProviderType.GITHUB
|
|
|
|
},
|
|
|
|
{
|
|
|
|
type: AuthProviderType.GOOGLE
|
|
|
|
},
|
|
|
|
{
|
|
|
|
type: AuthProviderType.LOCAL
|
|
|
|
},
|
|
|
|
{
|
|
|
|
type: AuthProviderType.LDAP,
|
|
|
|
identifier: 'test-ldap',
|
|
|
|
providerName: 'Test LDAP'
|
|
|
|
},
|
|
|
|
{
|
|
|
|
type: AuthProviderType.OAUTH2,
|
|
|
|
identifier: 'test-oauth2',
|
|
|
|
providerName: 'Test OAuth2'
|
|
|
|
},
|
|
|
|
{
|
|
|
|
type: AuthProviderType.SAML,
|
|
|
|
identifier: 'test-saml',
|
|
|
|
providerName: 'Test SAML'
|
|
|
|
},
|
|
|
|
{
|
|
|
|
type: AuthProviderType.GITLAB,
|
|
|
|
identifier: 'test-gitlab',
|
|
|
|
providerName: 'Test GitLab'
|
|
|
|
}
|
|
|
|
]
|
2021-03-09 17:00:14 -05:00
|
|
|
|
|
|
|
export const config = {
|
2022-04-15 17:03:15 -04:00
|
|
|
allowRegister: true,
|
2023-09-24 16:56:31 -04:00
|
|
|
guestAccess: 'write',
|
2021-03-09 17:00:14 -05:00
|
|
|
authProviders: authProviders,
|
|
|
|
branding: branding,
|
2022-04-15 17:03:15 -04:00
|
|
|
useImageProxy: false,
|
2021-05-01 17:01:42 -04:00
|
|
|
specialUrls: {
|
2021-03-09 17:00:14 -05:00
|
|
|
privacy: 'https://example.com/privacy',
|
|
|
|
termsOfUse: 'https://example.com/termsOfUse',
|
|
|
|
imprint: 'https://example.com/imprint'
|
|
|
|
},
|
|
|
|
version: {
|
2022-04-15 17:03:15 -04:00
|
|
|
major: 0,
|
|
|
|
minor: 0,
|
|
|
|
patch: 0,
|
|
|
|
preRelease: '',
|
|
|
|
commit: 'MOCK'
|
2021-03-09 17:00:14 -05:00
|
|
|
},
|
2022-04-15 17:03:15 -04:00
|
|
|
plantumlServer: 'http://mock-plantuml.local',
|
2022-09-16 05:03:29 -04:00
|
|
|
maxDocumentLength: 200
|
2021-03-09 17:00:14 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
Cypress.Commands.add('loadConfig', (additionalConfig?: Partial<typeof config>) => {
|
2023-05-29 11:32:44 -04:00
|
|
|
return cy.request(HttpMethod.POST, '/api/private/config', { ...config, ...additionalConfig })
|
2020-07-16 05:22:53 -04:00
|
|
|
})
|
2021-04-14 16:28:50 -04:00
|
|
|
|
2023-09-10 02:54:03 -04:00
|
|
|
Cypress.Commands.add('logIn', () => {
|
|
|
|
return cy.setCookie('mock-session', '1', { path: '/' })
|
|
|
|
})
|
|
|
|
|
|
|
|
Cypress.Commands.add('logOut', () => {
|
|
|
|
return cy.clearCookie('mock-session')
|
|
|
|
})
|
|
|
|
|
2021-04-14 16:28:50 -04:00
|
|
|
beforeEach(() => {
|
|
|
|
cy.loadConfig()
|
2023-10-24 02:57:42 -04:00
|
|
|
window.localStorage.setItem(MOTD_LOCAL_STORAGE_KEY, IGNORE_MOTD)
|
2023-09-10 02:54:03 -04:00
|
|
|
cy.logIn()
|
2021-10-09 13:09:29 -04:00
|
|
|
|
2023-08-12 14:07:38 -04:00
|
|
|
cy.intercept('GET', '/public/motd.md', {
|
2021-10-09 13:09:29 -04:00
|
|
|
body: '404 Not Found!',
|
|
|
|
statusCode: 404
|
|
|
|
})
|
2023-08-12 14:07:38 -04:00
|
|
|
cy.intercept('HEAD', '/public/motd.md', {
|
2021-10-09 13:09:29 -04:00
|
|
|
statusCode: 404
|
|
|
|
})
|
2021-04-14 16:28:50 -04:00
|
|
|
})
|