/** * @test */ public function sign_someProperties_Success() { $tokenValues = ['issuer' => 'testIssuer', 'key' => 'secretKey', 'issuedAtTime' => 1234567, 'validity' => 3600]; $token = new JwtToken($tokenValues['issuer'], $tokenValues['key'], $tokenValues['issuedAtTime'], $tokenValues['validity']); $token->setQueryString('get', 'some/path'); $this->assertEquals(['iss' => $tokenValues['issuer'], 'iat' => $tokenValues['issuedAtTime'], 'exp' => $tokenValues['issuedAtTime'] + $tokenValues['validity'], 'qsh' => '909144220b8eb4799623bdbb198a01485d4a7ad975d261cdfe14dafe021748c3'], $token->buildPayload()); $this->assertEquals('eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJ0ZXN0SXNzdWVyIiwiaWF0IjoxMjM0NTY3LCJleHAiOjEyMzgxNjcsInF' . 'zaCI6IjkwOTE0NDIyMGI4ZWI0Nzk5NjIzYmRiYjE5OGEwMTQ4NWQ0YTdhZDk3NWQyNjFjZGZlMTRkYWZlMDIxNzQ4YzMifQ.eneZ' . 'Ncg42dCVpB4krbqktMByMPXv1QYbiV-M50Q212A', $token->sign()); $this->assertEquals('eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJ0ZXN0SXNzdWVyIiwiaWF0IjoxMjM0NTY3LCJleHAiOjEyMzgxNjcsInF' . 'zaCI6IjkwOTE0NDIyMGI4ZWI0Nzk5NjIzYmRiYjE5OGEwMTQ4NWQ0YTdhZDk3NWQyNjFjZGZlMTRkYWZlMDIxNzQ4YzMifQ.eneZ' . 'Ncg42dCVpB4krbqktMByMPXv1QYbiV-M50Q212A', (string) $token); }
/** * {@inheritdoc} */ public function setQueryString($method, $url) { $this->token->setQueryString($method, $url); return $this; }