mirror of
https://github.com/lowdefy/lowdefy.git
synced 2025-02-17 14:30:34 +08:00
fix(build): Page auth config fixes.
This commit is contained in:
parent
cea898252d
commit
601c942e4f
@ -41,6 +41,12 @@ async function buildConfig({ components }) {
|
|||||||
'Protected and public pages are mutually exclusive. When protected pages are listed, all unlisted pages are public by default and visa versa.'
|
'Protected and public pages are mutually exclusive. When protected pages are listed, all unlisted pages are public by default and visa versa.'
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
if (components.config.auth.pages.protected === false) {
|
||||||
|
throw new Error('Protected pages can not be set to false.');
|
||||||
|
}
|
||||||
|
if (components.config.auth.pages.public === false) {
|
||||||
|
throw new Error('Public pages can not be set to false.');
|
||||||
|
}
|
||||||
components.auth = {};
|
components.auth = {};
|
||||||
if (
|
if (
|
||||||
type.isArray(components.config.auth.pages.public) ||
|
type.isArray(components.config.auth.pages.public) ||
|
||||||
|
@ -58,6 +58,33 @@ test('buildConfig config error when both protected and public pages are true', a
|
|||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('buildConfig config error when both protected or public are false.', async () => {
|
||||||
|
let components = {
|
||||||
|
config: {
|
||||||
|
auth: {
|
||||||
|
pages: {
|
||||||
|
protected: false,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
};
|
||||||
|
await expect(buildConfig({ components, context })).rejects.toThrow(
|
||||||
|
'Protected pages can not be set to false.'
|
||||||
|
);
|
||||||
|
components = {
|
||||||
|
config: {
|
||||||
|
auth: {
|
||||||
|
pages: {
|
||||||
|
public: false,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
};
|
||||||
|
await expect(buildConfig({ components, context })).rejects.toThrow(
|
||||||
|
'Public pages can not be set to false.'
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
test('buildConfig default', async () => {
|
test('buildConfig default', async () => {
|
||||||
const components = {};
|
const components = {};
|
||||||
const res = await buildConfig({ components, context });
|
const res = await buildConfig({ components, context });
|
||||||
|
@ -37,6 +37,22 @@ test('empty components', async () => {
|
|||||||
expect().toBe();
|
expect().toBe();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('page auth config', async () => {
|
||||||
|
const components = {
|
||||||
|
version: '1.0.0',
|
||||||
|
config: {
|
||||||
|
auth: {
|
||||||
|
pages: {
|
||||||
|
protected: true,
|
||||||
|
public: ['page1'],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
};
|
||||||
|
await testSchema({ components, context });
|
||||||
|
expect().toBe();
|
||||||
|
});
|
||||||
|
|
||||||
test('app schema', async () => {
|
test('app schema', async () => {
|
||||||
const components = {
|
const components = {
|
||||||
version: '1.0.0',
|
version: '1.0.0',
|
||||||
|
@ -446,7 +446,7 @@
|
|||||||
},
|
},
|
||||||
"properties": {
|
"properties": {
|
||||||
"protected": {
|
"protected": {
|
||||||
"type": "array",
|
"type": ["array", "boolean"],
|
||||||
"errorMessage": {
|
"errorMessage": {
|
||||||
"type": "App \"config.auth.pages.protected.$\" should be an array of strings."
|
"type": "App \"config.auth.pages.protected.$\" should be an array of strings."
|
||||||
},
|
},
|
||||||
@ -459,7 +459,7 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"public": {
|
"public": {
|
||||||
"type": "array",
|
"type": ["array", "boolean"],
|
||||||
"errorMessage": {
|
"errorMessage": {
|
||||||
"type": "App \"config.auth.pages.public.$\" should be an array of strings."
|
"type": "App \"config.auth.pages.public.$\" should be an array of strings."
|
||||||
},
|
},
|
||||||
|
Loading…
Reference in New Issue
Block a user