コード例 #1
0
 public function it_will_return_false_on_check_fail(AbstractEvent $event, WebHookSignature $signature)
 {
     $event->getSignature()->willReturn($signature);
     $signature->getAlgorithm()->willReturn('sha1');
     $signature->getSignature()->willReturn('abc123');
     $event->getRawPayload()->willReturn('{}');
     $this->check($event)->shouldReturn(false);
 }
コード例 #2
0
 /**
  * @param AbstractEvent $event
  *
  * @return bool
  */
 public function check(AbstractEvent $event)
 {
     $payLoadHash = hash_hmac($event->getSignature()->getAlgorithm(), $event->getRawPayload(), $this->secret);
     if ($payLoadHash === $event->getSignature()->getSignature()) {
         return true;
     } else {
         return false;
     }
 }
コード例 #3
0
ファイル: PayloadFactory.php プロジェクト: brankol/devboard
 /**
  * @param AbstractEvent $event
  *
  * @throws Exception
  *
  * @return PushPayload
  */
 public function create(AbstractEvent $event)
 {
     if ($event instanceof PushEvent) {
         return new PushPayload($event->getPayload());
     } elseif ($event instanceof StatusEvent) {
         return new StatusPayload($event->getPayload());
     } elseif ($event instanceof PullRequestEvent) {
         return new PullRequestPayload($event->getPayload());
     }
     throw new Exception('Unknown WebHook Event:' . get_class($event));
 }