|
@@ -24,6 +24,18 @@ describe('AclService test', () => {
|
|
|
expect(crowi.aclService.isAclEnabled()).toBe(true);
|
|
expect(crowi.aclService.isAclEnabled()).toBe(true);
|
|
|
});
|
|
});
|
|
|
|
|
|
|
|
|
|
+ test('to be false when FORCE_WIKI_MODE is dummy string', async() => {
|
|
|
|
|
+ process.env.FORCE_WIKI_MODE = 'dummy string';
|
|
|
|
|
+
|
|
|
|
|
+ // reload
|
|
|
|
|
+ await crowi.configManager.loadConfigs();
|
|
|
|
|
+
|
|
|
|
|
+ const wikiMode = crowi.configManager.getConfig('crowi', 'security:wikiMode');
|
|
|
|
|
+
|
|
|
|
|
+ expect(wikiMode).toBe('dummy string');
|
|
|
|
|
+ expect(crowi.aclService.isAclEnabled()).toBe(true);
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
test('to be true when FORCE_WIKI_MODE=private', async() => {
|
|
test('to be true when FORCE_WIKI_MODE=private', async() => {
|
|
|
process.env.FORCE_WIKI_MODE = 'private';
|
|
process.env.FORCE_WIKI_MODE = 'private';
|
|
|
|
|
|
|
@@ -50,6 +62,56 @@ describe('AclService test', () => {
|
|
|
|
|
|
|
|
});
|
|
});
|
|
|
|
|
|
|
|
|
|
+ describe('isWikiModeForced()', () => {
|
|
|
|
|
+
|
|
|
|
|
+ test('to be false when FORCE_WIKI_MODE is undefined', async() => {
|
|
|
|
|
+ delete process.env.FORCE_WIKI_MODE;
|
|
|
|
|
+
|
|
|
|
|
+ // reload
|
|
|
|
|
+ await crowi.configManager.loadConfigs();
|
|
|
|
|
+
|
|
|
|
|
+ expect(process.env.FORCE_WIKI_MODE).not.toBeDefined();
|
|
|
|
|
+ expect(crowi.aclService.isWikiModeForced()).toBe(false);
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
|
|
+ test('to be false when FORCE_WIKI_MODE is dummy string', async() => {
|
|
|
|
|
+ process.env.FORCE_WIKI_MODE = 'dummy string';
|
|
|
|
|
+
|
|
|
|
|
+ // reload
|
|
|
|
|
+ await crowi.configManager.loadConfigs();
|
|
|
|
|
+
|
|
|
|
|
+ const wikiMode = crowi.configManager.getConfig('crowi', 'security:wikiMode');
|
|
|
|
|
+
|
|
|
|
|
+ expect(wikiMode).toBe('dummy string');
|
|
|
|
|
+ expect(crowi.aclService.isWikiModeForced()).toBe(false);
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
|
|
+ test('to be true when FORCE_WIKI_MODE=private', async() => {
|
|
|
|
|
+ process.env.FORCE_WIKI_MODE = 'private';
|
|
|
|
|
+
|
|
|
|
|
+ // reload
|
|
|
|
|
+ await crowi.configManager.loadConfigs();
|
|
|
|
|
+
|
|
|
|
|
+ const wikiMode = crowi.configManager.getConfig('crowi', 'security:wikiMode');
|
|
|
|
|
+
|
|
|
|
|
+ expect(wikiMode).toBe('private');
|
|
|
|
|
+ expect(crowi.aclService.isWikiModeForced()).toBe(true);
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
|
|
+ test('to be false when FORCE_WIKI_MODE=public', async() => {
|
|
|
|
|
+ process.env.FORCE_WIKI_MODE = 'public';
|
|
|
|
|
+
|
|
|
|
|
+ // reload
|
|
|
|
|
+ await crowi.configManager.loadConfigs();
|
|
|
|
|
+
|
|
|
|
|
+ const wikiMode = crowi.configManager.getConfig('crowi', 'security:wikiMode');
|
|
|
|
|
+
|
|
|
|
|
+ expect(wikiMode).toBe('public');
|
|
|
|
|
+ expect(crowi.aclService.isWikiModeForced()).toBe(true);
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
describe('isGuestAllowedToRead()', () => {
|
|
describe('isGuestAllowedToRead()', () => {
|
|
|
let getConfigSpy;
|
|
let getConfigSpy;
|
|
|
|
|
|