2023-11-01 13:20:00 +01:00
|
|
|
import { createNextDescribe } from 'e2e-utils'
|
|
|
|
import { check } from 'next-test-utils'
|
2023-11-08 11:20:32 +01:00
|
|
|
import { join } from 'path'
|
2023-11-01 13:20:00 +01:00
|
|
|
|
|
|
|
createNextDescribe(
|
2023-11-08 11:20:32 +01:00
|
|
|
'app-dir action disallowed origins',
|
2023-11-01 13:20:00 +01:00
|
|
|
{
|
2023-11-08 11:20:32 +01:00
|
|
|
files: join(__dirname, 'unsafe-origins'),
|
2023-11-01 13:20:00 +01:00
|
|
|
skipDeployment: true,
|
|
|
|
dependencies: {
|
|
|
|
react: 'latest',
|
|
|
|
'react-dom': 'latest',
|
|
|
|
'server-only': 'latest',
|
|
|
|
},
|
|
|
|
},
|
|
|
|
({ next }) => {
|
2023-11-08 11:20:32 +01:00
|
|
|
// Origin should be localhost
|
|
|
|
it('should error if x-forwarded-host does not match the origin', async function () {
|
|
|
|
const browser = await next.browser('/')
|
2023-11-01 13:20:00 +01:00
|
|
|
|
|
|
|
await browser.elementByCss('button').click()
|
|
|
|
|
|
|
|
await check(async () => {
|
|
|
|
const t = await browser.elementByCss('#res').text()
|
|
|
|
return t.includes('Invalid Server Actions request.') ||
|
|
|
|
// In prod the message is hidden
|
|
|
|
t.includes('An error occurred in the Server Components render.')
|
|
|
|
? 'yes'
|
|
|
|
: 'no'
|
|
|
|
}, 'yes')
|
|
|
|
})
|
|
|
|
}
|
|
|
|
)
|