Ejemplo n.º 1
0
    it('should reject the promise if the controller element is empty', () => {
      const role = new Role();
      role.controllers = {
        '*': {}
      };

      return should(role.validateDefinition(context)).be.rejectedWith(BadRequestError, {message: 'Invalid definition for [*]: cannot be empty'});
    });
Ejemplo n.º 2
0
    it('should reject the promise if the actions attribute is empty', () => {
      const role = new Role();
      role.controllers = {
        controller: {
          actions: {}
        }
      };

      return should(role.validateDefinition(context)).be.rejectedWith(BadRequestError, {message: 'Invalid definition for [controller]: "actions" attribute cannot be empty'});
    });
Ejemplo n.º 3
0
    it('should reject the promise is the actions attribute is not an object', () => {
      const role = new Role();
      role.controllers = {
        controller: {
          actions: true
        }
      };

      return should(role.validateDefinition(context)).be.rejectedWith(BadRequestError, {message: 'Invalid definition for [controller]: "actions" attribute must be an object'});
    });
Ejemplo n.º 4
0
    it('should reject the promise if the action right is neither a boolean or an object', () => {
      const role = new Role();
      role.controllers = {
        controller: {
          actions: {
            action: null
          }
        }
      };

      return should(role.validateDefinition(context)).be.rejectedWith(BadRequestError, {message: 'Invalid definition for [controller, action]: must be a boolean or an object'});
    });
Ejemplo n.º 5
0
    it('should validate if only boolean rights are given', () => {
      const role = new Role();
      role.controllers = {
        controller1: {
          actions: {
            action1: false,
            action2: true
          }
        },
        controller2: {
          actions: {
            action3: true
          }
        }
      };

      return should(role.validateDefinition(context)).be.fulfilledWith(true);
    });
Ejemplo n.º 6
0
    it('should reject the promise if the closure does not contain a "test" attribute', () => {
      const role = new Role();
      role.indexes = {
        '*': {
          collections: {
            '*': {
              controllers: {
                '*': {
                  actions: {
                    '*': {an: 'object'}
                  }
                }
              }
            }
          }
        }
      };

      return should(role.validateDefinition(context)).be.rejected();
    });
Ejemplo n.º 7
0
    it('should reject the promise if the controllers definition is empty', () => {
      const role = new Role();
      role.controllers = {};

      return should(role.validateDefinition(context)).be.rejectedWith(BadRequestError, {message: 'The "controllers" definition cannot be empty'});
    });
Ejemplo n.º 8
0
    it('should reject the promise if the controllers definition is not an object', () => {
      const role = new Role();
      role.controllers = true;

      return should(role.validateDefinition(context)).be.rejectedWith(BadRequestError, {message: 'The "controllers" definition must be an object'});
    });