示例#1
0
 before(async () => {
   await esArchiver.load('empty_kibana');
   await sourceConfigurationService.createConfiguration('default', {
     name: 'Test Source',
     logColumns: [
       {
         timestampColumn: {
           id: uuidv4(),
         },
       },
       {
         fieldColumn: {
           id: uuidv4(),
           field: 'host.name',
         },
       },
       {
         fieldColumn: {
           id: uuidv4(),
           field: 'event.dataset',
         },
       },
       {
         messageColumn: {
           id: uuidv4(),
         },
       },
     ],
   });
 });
示例#2
0
    it('should pass list authorization', async () => {
      const route = buildRoute({type: 'destroy', byId: false, byList: true, authorization})
      const body = [uuid(), uuid()]

      const req = {grants, body}
      await utils.runMiddleware(route.middleware, req)
      expect(destroyStub).toHaveBeenCalledTimes(2)
    })
示例#3
0
    it('should pass list authorization', async () => {
      const route = buildRoute({type: 'update', byId: false, byList: true, authorization})
      const body = [{id: uuid(), ...utils.defaultUser}, {id: uuid(), ...utils.defaultUser}]

      const req = {grants, body}
      const {res} = await utils.runMiddleware(route.middleware, req)

      expect(await res.promise).toEqual(req.validated.body)
      expect(updateAllStub).toHaveBeenCalledTimes(1)
    })
示例#4
0
    it('should fail list authorization', async () => {
      const route = buildRoute({type: 'destroy', byId: false, byList: true, authorization})
      const body = [uuid(), uuid()]

      findStub.mockReturnValueOnce({lastName: 'Thompson'})
      findStub.mockReturnValueOnce({lastName: 'Not-Thompson'})

      const req = {grants, body}
      const {err} = await utils.runMiddleware(route.middleware, req)

      expect(err).toBeInstanceOf(Error)
      expect(err.message).toMatch(/permission/)
      expect(destroyStub).toHaveBeenCalledTimes(0)
    })
示例#5
0
    it('should fail list authorization for existing', async () => {
      const route = buildRoute({type: 'update', byId: false, byList: true, authorization})
      const body = [{id: uuid(), ...utils.defaultUser}, {id: uuid(), ...utils.defaultUser}]

      findStub.mockReturnValueOnce({lastName: 'Thompson'})
      findStub.mockReturnValueOnce({lastName: 'Not-Thompson'})

      const req = {grants, body}
      const {res, err} = await utils.runMiddleware(route.middleware, req)

      expect(err).toBeInstanceOf(Error)
      expect(err.message).toMatch(/permission/)
      expect(res.promise).toBe(undefined)
    })
示例#6
0
function _validateAnalyticsSharingUuid(value: string) {
  if (value == '') {
    return uuidV4();
  } else {
    return value;
  }
}
export const addTodo = (text: string) => ({
  type: 'ADD_TODO',
  payload: {
    id: v4(),
    text
  }
});
示例#8
0
  produce(state, draftState => {
    switch (action.type) {
      case 'PUBLISH_NOTIFICATION': {
        const {notification} = action.payload
        const publishedNotification = {
          ...notification,
          id: uuid.v4(),
        }
        const matchIndex = state.findIndex(
          n => n.type && notification.type && n.type === notification.type
        )
        const isUnique = matchIndex === -1
        if (isUnique) {
          draftState.unshift(publishedNotification)
        }
        return
      }

      case 'DISMISS_NOTIFICATION': {
        const {id} = action.payload
        return draftState.filter(n => n.id !== id)
      }

      case 'DISMISS_ALL_NOTIFICATIONS': {
        return []
      }
    }
  })
示例#9
0
文件: push.ts 项目: lovett/notifier
router.get('/', async (req: express.Request, res: express.Response) => {
    const id = uuid.v4();

    const timer = setInterval(() => {
        res.write('event:keepalive\ndata:\n\n');
    }, 30000);

    req.socket.setKeepAlive(true);
    req.socket.setTimeout(0);

    req.connection.on('close', () => {
        clearInterval(timer);
        delete req.app.locals.pushClients[id];
        res.end();
    });

    req.app.locals.pushClients[id] = res;

    // The no-transform value of the Cache-Control header tells the
    // compresssion middleware not to compress this
    // response. Otherwise, the client never sees any of the writes.
    res.writeHead(200, {
        'Cache-Control': 'no-cache, no-transform',
        'Connection': 'keep-alive',
        'Content-Type': 'text/event-stream',
        'X-Accel-Buffering': 'no',
    });

    res.write('event:connection\ndata:\n\n');
});
示例#10
0
				$request(reqOut, function (err: Error, message: any, body: any): void {

					console.log('*************************');
					console.log('' + vertex + ' ' + targetUrl);
					console.log('-------------------------');
					console.dir(headers);
					console.log('=========================');
					console.dir(body);

					if (params && body && !params.id && !_.isArray(body)) {
						body.id = body.id || uuid.v4();
						body = [body];
					}
					else if (_.isArray(body)) {
						_.each(body, function (item: any) {
							item.id = item.id || uuid.v4();
						});
					}

					if (!err) {
						res
							.status(message.statusCode)
							.send(body);
					}
					else {
						res.serverError(err);
					}
				})