public function DeveloperAppUITest::testCallbackUrlValidationServerSide in Apigee Edge 8
Tests callback url validation on the server-side.
File
- tests/
src/ Functional/ DeveloperAppUITest.php, line 520
Class
- DeveloperAppUITest
- Developer app UI tests.
Namespace
Drupal\Tests\apigee_edge\FunctionalCode
public function testCallbackUrlValidationServerSide() {
// Override default configuration.
$description = 'This is a Callback URL field.';
$this
->config('apigee_edge.common_app_settings')
->set('callback_url_pattern', '^https:\\/\\/example.com')
->set('callback_url_description', $description)
->save();
$callback_url = $this
->randomMachineName();
$product = $this
->createProduct();
$this->products[] = $product;
$app = $this
->createDeveloperApp([
'name' => $callback_url,
'displayName' => $this
->randomString(),
'callbackUrl' => $callback_url,
], $this->account, [
$product
->id(),
]);
$app_edit_url = $app
->toUrl('edit-form-for-developer');
$this
->drupalGet($app_edit_url);
// Also test field description.
$this
->assertSession()
->pageTextContains($description);
$this
->drupalPostForm($app_edit_url, [], 'Save');
$this
->assertSession()
->pageTextContains("The URL {$callback_url} is not valid.");
$this
->drupalPostForm($app_edit_url, [
'callbackUrl[0][value]' => 'http://example.com',
], 'Save');
$this
->assertSession()
->pageTextContains("Callback URL field is not in the right format.");
$this
->drupalPostForm($app_edit_url, [
'callbackUrl[0][value]' => 'https://example.com',
], 'Save');
$this
->assertSession()
->pageTextContains('App has been successfully updated.');
$this
->assertSession()
->pageTextContains('https://example.com');
}