Exemplo n.º 1
0
 public function testClientSecretAddedIfSetForPasswordRequests()
 {
     $testConfig = $this->tokenRequestMinimal;
     $testConfig['clientSecret'] = 'a_client_secret';
     $o = new OAuth2($testConfig);
     $o->setUsername('a_username');
     $o->setPassword('a_password');
     $request = $o->generateCredentialsRequest();
     $fields = Psr7\parse_query((string) $request->getBody());
     $this->assertEquals('a_client_secret', $fields['client_secret']);
 }
 public function testGeneratesPasswordRequests()
 {
     $testConfig = $this->tokenRequestMinimal;
     $o = new OAuth2($testConfig);
     $o->setUsername('a_username');
     $o->setPassword('a_password');
     // Generate the request and confirm that it's correct.
     $req = $o->generateCredentialsRequest();
     $this->assertInstanceOf('GuzzleHttp\\Message\\RequestInterface', $req);
     $this->assertEquals('POST', $req->getMethod());
     $fields = $req->getBody()->getFields();
     $this->assertEquals('password', $fields['grant_type']);
     $this->assertEquals('a_password', $fields['password']);
     $this->assertEquals('a_username', $fields['username']);
 }