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