コード例 #1
0
 /** @test */
 public function shouldParseSecuritySchemes()
 {
     $def = $this->parser->parse(__DIR__ . '/fixture/securitySchemes.raml');
     $resource = $def->getResourceByUri('/users');
     $method = $resource->getMethod('get');
     $securitySchemes = $method->getSecuritySchemes();
     $this->assertEquals(2, count($securitySchemes));
     $this->assertInstanceOf('\\Raml\\SecurityScheme', $securitySchemes['oauth_1_0']);
     $this->assertInstanceOf('\\Raml\\SecurityScheme', $securitySchemes['oauth_2_0']);
     $this->assertEquals('OAuth 1.0 continues to be supported for all API requests, but OAuth 2.0 is now preferred.', trim($securitySchemes['oauth_1_0']->getDescription()));
     $this->assertEquals('OAuth 1.0', $securitySchemes['oauth_1_0']->getType());
     $settings = new \Raml\SecurityScheme\SecuritySettings\OAuth1SecuritySettings();
     $settings->setRequestTokenUri('https://api.dropbox.com/1/oauth/request_token');
     $settings->setAuthorizationUri('https://www.dropbox.com/1/oauth/authorize');
     $settings->setTokenCredentialsUri('https://api.dropbox.com/1/oauth/access_token');
     $this->assertEquals($settings, $securitySchemes['oauth_1_0']->getSettings());
 }
コード例 #2
0
 /** @test */
 public function shouldParseSecuritySchemes()
 {
     $def = $this->parser->parse(__DIR__ . '/fixture/securitySchemes.raml');
     $resource = $def->getResourceByUri('/users');
     $method = $resource->getMethod('get');
     $securitySchemes = $method->getSecuritySchemes();
     $this->assertEquals(2, count($securitySchemes));
     $this->assertInstanceOf('\\Raml\\SecurityScheme', $securitySchemes['oauth_1_0']);
     $this->assertInstanceOf('\\Raml\\SecurityScheme', $securitySchemes['oauth_2_0']);
     $this->assertEquals('OAuth 1.0 continues to be supported for all API requests, but OAuth 2.0 is now preferred.', trim($securitySchemes['oauth_1_0']->getDescription()));
     $this->assertEquals('OAuth 1.0', $securitySchemes['oauth_1_0']->getType());
     $settings = new \Raml\SecurityScheme\SecuritySettings\OAuth1SecuritySettings();
     $settings->setRequestTokenUri('https://api.dropbox.com/1/oauth/request_token');
     $settings->setAuthorizationUri('https://www.dropbox.com/1/oauth/authorize');
     $settings->setTokenCredentialsUri('https://api.dropbox.com/1/oauth/access_token');
     // Get the settings array and remove the key used for internal processing.
     $oauthSettings = $securitySchemes['oauth_1_0']->getSettings()->getSettings();
     unset($oauthSettings['_PRP_ORIGINAL_SETTINGS_']);
     // Make the settings data an array.
     $settings = (array) $settings;
     reset($settings);
     // Loose the class name key.
     $settings = $settings[key($settings)];
     $this->assertEquals($settings, $oauthSettings);
 }