Skip to content
Snippets Groups Projects
Commit 9d42c230 authored by xiaohua guan's avatar xiaohua guan Committed by Yas Naoi
Browse files

Issue #3009050 by Xiaohua Guan, baldwinlouie, yas: Update SimpleTest test...

Issue #3009050 by Xiaohua Guan, baldwinlouie, yas: Update SimpleTest test cases for module aws_cloud
parent e59f0006
No related branches found
No related tags found
No related merge requests found
Showing
with 872 additions and 320 deletions
<?php
namespace Drupal\Tests\aws_cloud\Functional\Ec2;
use Drupal\Tests\BrowserTestBase;
use Drupal\Component\Utility\Random;
use Drupal\Component\Serialization\Yaml;
abstract class AwsCloudTestCase extends BrowserTestBase {
/**
* Modules to enable.
*
* @var array
*/
public static $modules = [
'cloud', 'aws_cloud'
];
/**
* The profile to install as a basis for testing.
*
* @var string
*/
protected $profile = 'minimal';
protected $random;
protected $cloud_context;
/**
* Set up test.
*/
protected function setUp() {
parent::setUp();
if (!$this->random) {
$this->random = new Random();
}
$this->createCloudContext();
$this->initMockData();
$perms = $this->getPermissions();
$perms[] = 'view ' . $this->cloud_context;
$web_user = $this->drupalCreateUser($perms);
$this->drupalLogin($web_user);
}
abstract protected function getPermissions();
protected function getMockData() {
return [];
}
protected function getMockDataFromConfig() {
$config = \Drupal::configFactory()->getEditable('aws_cloud.settings');
return json_decode($config->get('aws_cloud_mock_data'), true);
}
protected function updateMockDataToConfig($mock_data) {
$config = \Drupal::configFactory()->getEditable('aws_cloud.settings');
$config->set('aws_cloud_mock_data', json_encode($mock_data))
->save();
}
private function createCloudContext() {
$random = $this->random;
$this->cloud_context = $random->name(8);
$num = 1;
$data = [
'cloud_context' => $this->cloud_context,
'type' => 'aws_ec2',
'label' => "Amazon EC2 US West ($num) - " . $random->name(8, TRUE),
];
$cloud = entity_create('cloud_config', $data);
$cloud->field_cloud_type->value = 'amazon_ec2';
$cloud->field_description->value = "#$num: " . date('Y/m/d H:i:s - D M j G:i:s T Y') . $random->string(64, TRUE);
$cloud->field_api_version->value = 'latest';
$cloud->field_region->value = "us-west-$num";
$cloud->field_api_endpoint_uri->value = "https://ec2.us-west-$num.amazonaws.com";
$cloud->field_access_key->value = $random->name(20, TRUE);
$cloud->field_secret_key->value = $random->name(40, TRUE);
$cloud->field_user_id->value = $random->name(16, TRUE);
$cloud->field_image_upload_url->value = "https://ec2.us-west-$num.amazonaws.com";
$cloud->field_x_509_certificate->value = $random->string(255, TRUE);
$cloud->save();
}
private function initMockData() {
$mock_data = [];
foreach ([__CLASS__, get_class($this)] as $class_name) {
$content = $this->getMockDataFileContent($class_name);
if (!empty($content)) {
$mock_data = array_merge($mock_data, Yaml::decode($content));
}
}
$config = \Drupal::configFactory()->getEditable('aws_cloud.settings');
$config->set('aws_cloud_test_mode', true)
->set('aws_cloud_mock_data', json_encode($mock_data))
->save();
}
protected function getMockDataFileContent($class_name, $suffix = '') {
$path = drupal_realpath(drupal_get_path('module', 'aws_cloud')) . '/tests/mock_data';
$pos = strpos($class_name, 'aws_cloud') + strlen('aws_cloud');
$path .= str_replace('\\', '/', substr($class_name, $pos)) . $suffix . '.yml';
if (!file_exists($path)) {
return '';
}
return file_get_contents($path);
}
}
<?php
namespace Drupal\aws_cloud\Tests\Ec2;
namespace Drupal\Tests\aws_cloud\Functional\Ec2;
use Drupal\simpletest\WebTestBase;
use Drupal\Component\Utility\Random;
// Updated by yas 2016/06/23
......@@ -12,7 +11,6 @@ use Drupal\Component\Utility\Random;
// Updated by yas 2016/05/25
// Updated by yas 2016/05/24
// Created by yas 2016/05/23.
// module_load_include('test', 'aws_cloud');.
define('AWS_CLOUD_ELASTIC_IP_REPEAT_COUNT', 3);
/**
......@@ -20,59 +18,23 @@ define('AWS_CLOUD_ELASTIC_IP_REPEAT_COUNT', 3);
*
* @group AWS Cloud
*/
class ElasticIpTest extends WebTestBase {
/* @FIXME extends AwsCloudTestCase { */
class ElasticIpTest extends AwsCloudTestCase {
/**
* Modules to enable.
*
* @var array
*/
public static $modules = ['cloud',
'aws_cloud',
];
/**
* The profile to install as a basis for testing.
*
* @var string
*/
protected $profile = 'minimal';
protected $random;
/**
* Set up test.
*/
protected function setUp() {
parent::setUp();
if (!$this->random) {
$this->random = new Random();
}
$config = \Drupal::configFactory()->getEditable('aws_cloud.settings');
$config->set('aws_cloud_test_mode', true);
$web_user = $this->drupalCreateUser([
protected function getPermissions() {
return [
'list aws cloud elastic ip',
'add aws cloud elastic ip',
'view aws cloud elastic ip',
'edit aws cloud elastic ip',
'delete aws cloud elastic ip',
]);
$this->drupalLogin($web_user);
];
}
/**
* Tests CRUD for Elastic IP information.
*/
public function testElasticIp() {
// Access to AWS Cloud Menu
// $clouds = $this->getClouds();
// foreach ($clouds as $cloud) {.
$cloud_context = $this->random->name(8);
$cloud_context = $this->cloud_context;
// List Elastic IP for Amazon EC2.
$this->drupalGet("/clouds/aws_cloud/$cloud_context/elastic_ip");
......@@ -104,13 +66,10 @@ class ElasticIpTest extends WebTestBase {
'@name' => $add[$i]['name'],
]));
// Make sure View.
/*
$this->drupalGet("/clouds/aws_cloud/$cloud_context/elastic_ip/$num");
$this->assertResponse(200, t('Add | View | HTTP 200: Elastic IP #@num', array('@num' => $num)));
$this->assertNoText(t('Notice'), t('Add | View | Make sure w/o Notice'));
$this->assertNoText(t('warning'), t('Add | View | Make sure w/o Warnings'));
*/
// Make sure listing.
$this->drupalGet("/clouds/aws_cloud/$cloud_context/elastic_ip");
......@@ -161,19 +120,22 @@ class ElasticIpTest extends WebTestBase {
}
}
$options = ['query' => ['destination' => "/clouds/aws_cloud/$cloud_context/elastic_ip"]];
// Delete Elastic IP
// 3 times.
for ($i = 0; $i < AWS_CLOUD_ELASTIC_IP_REPEAT_COUNT; $i++) {
$num = $i + 1;
$this->drupalGet("/clouds/aws_cloud/$cloud_context/elastic_ip/$num/delete");
$this->drupalGet("/clouds/aws_cloud/$cloud_context/elastic_ip/$num/delete", $options);
$this->assertResponse(200, t('Delete | HTTP 200: Elastic IP #@num', ['@num' => $num]));
$this->assertNoText(t('Notice'), t('Delete | Make sure w/o Notice'));
$this->assertNoText(t('warning'), t('Delete | Make sure w/o Warnings'));
$this->drupalPostForm("/clouds/aws_cloud/$cloud_context/elastic_ip/$num/delete",
[],
t('Delete'));
t('Delete'),
$options);
$this->assertResponse(200, t('Delete | HTTP 200: The Cloud Elastic IP #@num', ['@num' => $num]));
$this->assertNoText(t('Notice'), t('Delete | Make sure w/o Notice'));
......@@ -182,10 +144,10 @@ class ElasticIpTest extends WebTestBase {
$this->assertText(t('The AWS Cloud Elastic IP "@name" has been deleted.', [
'@name' => $edit[$i]['name'],
]),
t('Confirm Message') . ': '
. t('Delete | The AWS Cloud Elastic IP "@name" has been deleted.', [
'@name' => $edit[$i]['name'],
]));
t('Confirm Message') . ': '
. t('Delete | The AWS Cloud Elastic IP "@name" has been deleted.', [
'@name' => $edit[$i]['name'],
]));
// Make sure listing.
$this->drupalGet("/clouds/aws_cloud/$cloud_context/elastic_ip");
......@@ -200,6 +162,8 @@ class ElasticIpTest extends WebTestBase {
}
*/
}
// Filtering scripting information item
/*
$filter = array(
......
<?php
namespace Drupal\aws_cloud\Tests\Ec2;
namespace Drupal\Tests\aws_cloud\Functional\Ec2;
use Drupal\simpletest\WebTestBase;
use Drupal\Component\Utility\Random;
// Updated by yas 2016/06/23
......@@ -10,7 +9,6 @@ use Drupal\Component\Utility\Random;
// Updated by yas 2016/05/31
// Updated by yas 2016/05/29
// Created by yas 2016/05/28.
// module_load_include('test', 'aws_cloud');.
define('AWS_CLOUD_IMAGE_REPEAT_COUNT', 3);
/**
......@@ -18,59 +16,22 @@ define('AWS_CLOUD_IMAGE_REPEAT_COUNT', 3);
*
* @group AWS Cloud
*/
class ImageTest extends WebTestBase {
/* @FIXME extends AwsCloudTestCase { */
/**
* Modules to enable.
*
* @var array
*/
public static $modules = ['cloud',
'aws_cloud',
];
/**
* The profile to install as a basis for testing.
*
* @var string
*/
protected $profile = 'minimal';
protected $random;
/**
* Set up test.
*/
protected function setUp() {
parent::setUp();
if (!$this->random) {
$this->random = new Random();
}
$config = \Drupal::configFactory()->getEditable('aws_cloud.settings');
$config->set('aws_cloud_test_mode', true);
$web_user = $this->drupalCreateUser([
class ImageTest extends AwsCloudTestCase {
protected function getPermissions() {
return [
'add aws cloud image',
'list aws cloud image',
'view aws cloud image',
'edit aws cloud image',
'delete aws cloud image',
]);
$this->drupalLogin($web_user);
];
}
/**
* Tests CRUD for image information.
*/
public function testImage() {
// Access to AWS Cloud Menu
// $clouds = $this->getClouds();
// foreach ($clouds as $cloud) {.
$cloud_context = 'default_cloud_context';
$cloud_context = $this->cloud_context;
// List Image for Amazon EC2.
$this->drupalGet("/clouds/aws_cloud/$cloud_context/image");
......@@ -95,18 +56,16 @@ class ImageTest extends WebTestBase {
$this->assertText(t('The AWS Cloud Image "@name', [
'@name' => $add[$i]['name'],
]),
t('Confirm Message') . ': '
. t('Add | The AWS Cloud Image "@name" has been created.', [
'@name' => $add[$i]['name'],
]));
t('Confirm Message') . ': '
. t('Add | The AWS Cloud Image "@name" has been created.', [
'@name' => $add[$i]['name'],
]));
// Make sure View.
/*
$this->drupalGet("/clouds/aws_cloud/$cloud_context/image/$num");
$this->assertResponse(200, t('Add | View | HTTP 200: Image #@num', array('@num' => $num)));
$this->assertNoText(t('Notice'), t('Add | View | Make sure w/o Notice'));
$this->assertNoText(t('warning'), t('Add | View | Make sure w/o Warnings'));
*/
// Make sure listing.
$this->drupalGet("/clouds/aws_cloud/$cloud_context/image");
......@@ -125,13 +84,11 @@ class ImageTest extends WebTestBase {
// Edit an Image information.
$edit = $this->createImageTestData();
for ($i = 0; $i < AWS_CLOUD_IMAGE_REPEAT_COUNT; $i++) {
$num = $i + 1;
unset($edit[$i]['instance_id']);
unset($edit[$i]['description']);
// @FIXME - $num => $image_id
$this->drupalPostForm("/clouds/aws_cloud/$cloud_context/image/$num/edit",
$edit[$i],
t('Save'));
......@@ -139,11 +96,11 @@ class ImageTest extends WebTestBase {
$this->assertResponse(200, t('HTTP 200: Edit | A New Image #@num', ['@num' => $num]));
$this->assertNoText(t('Notice'), t('Make sure w/o Notice'));
$this->assertNoText(t('warning'), t('Make sure w/o Warnings'));
$this->assertText($edit[$i]['name'], t('Name: @name ', ['@name' => $edit[$i]['name']]));
$this->assertText(t('The AWS Cloud Image "@name" has been saved.', ['@name' => $edit[$i]['name']]),
$this->assertText($add[$i]['name'], t('Name: @name ', ['@name' => $add[$i]['name']]));
$this->assertText(t('The AWS Cloud Image "@name" has been saved.', ['@name' => $add[$i]['name']]),
t('Confirm Message') . ': '
. t('The AWS Cloud Image "@name" has been saved.', [
'@name' => $edit[$i]['name'],
'@name' => $add[$i]['name'],
]));
// Make sure listing.
......@@ -152,9 +109,9 @@ class ImageTest extends WebTestBase {
$this->assertNoText(t('Notice'), t('Edit | List | Make sure w/o Notice'));
$this->assertNoText(t('warning'), t('Edit | List | Make sure w/o Warnings'));
for ($j = 0; $j < $i + 1; $j++) {
$this->assertText($edit[$i]['name'],
$this->assertText($add[$i]['name'],
t('Edit | List | Make sure w/ Listing: @name', [
'@name' => $edit[$i]['name'],
'@name' => $add[$i]['name'],
]));
}
}
......@@ -220,7 +177,6 @@ class ImageTest extends WebTestBase {
*
*/
private function createImageTestData() {
$this->random = new Random();
$data = [];
......
<?php
namespace Drupal\Tests\aws_cloud\Functional\Ec2;
// Updated by yas 2016/09/07
// Updated by yas 2016/06/24
......@@ -12,12 +13,9 @@
// Updated by yas 2016/05/22
// Created by yas 2016/05/21.
namespace Drupal\aws_cloud\Tests\Ec2;
use Drupal\simpletest\WebTestBase;
use Drupal\Component\Utility\Random;
use Drupal\Component\Serialization\Yaml;
// module_load_include('test', 'aws_cloud');.
define('AWS_CLOUD_INSTANCE_REPEAT_COUNT', 3);
define('AWS_CLOUD_CONFIG_REPEAT_COUNT', 1);
......@@ -26,121 +24,27 @@ define('AWS_CLOUD_CONFIG_REPEAT_COUNT', 1);
*
* @group AWS Cloud
*/
class InstanceTest extends WebTestBase {
//@FIXME extends AwsCloudTestCase {
/**
* Modules to enable.
*
* @var array
*/
public static $modules = ['cloud',
'aws_cloud',
];
/**
* The profile to install as a basis for testing.
*
* @var string
*/
protected $profile = 'minimal';
protected $random;
/**
* Set up test.
*/
protected function setUp() {
parent::setUp();
if (!$this->random) {
$this->random = new Random();
}
$config = \Drupal::configFactory()->getEditable('aws_cloud.settings');
$config->set('aws_cloud_test_mode', true);
$web_user = $this->drupalCreateUser([
'list aws cloud provider',
'add aws cloud provider',
'view aws cloud provider',
'edit aws cloud provider',
'delete aws cloud provider',
class InstanceTest extends AwsCloudTestCase {
protected function getPermissions() {
return [
'add aws cloud instance',
'list aws cloud instance',
'view all aws cloud instance',
'edit aws cloud instance',
'delete aws cloud instance',
]);
$this->drupalLogin($web_user);
'edit own aws cloud instance',
'delete own aws cloud instance',
'list cloud server template',
'launch server template',
];
}
/**
* Tests CRUD for instance information.
*/
public function testInstance() {
$cloud_context = $this->cloud_context;
// @FIXME Do refactor for sparate function
// Add a new Config information.
$add = $this->createConfigTestData();
for ($i = 0; $i < AWS_CLOUD_CONFIG_REPEAT_COUNT; $i++) {
$num = $i + 1;
$cloud_context[$i] = $add[$i]['cloud_context'];
$label[$i] = $add[$i]['label'];
$this->drupalGet('/admin/config/services/cloud/aws_cloud/cloud_context/add');
$this->assertResponse(200, t('HTTP 200: Add | AWS Cloud Config Form #@num', ['@num' => $num]));
$this->assertNoText(t('Notice'), t('Make sure w/o Notice'));
$this->assertNoText(t('Warning'), t('Make sure w/o Warnings'));
$this->drupalPostForm('/admin/config/services/cloud/aws_cloud/cloud_context/add',
$add[$i],
t('Save'));
$this->assertResponse(200, t('HTTP 200: Saved | Aws Cloud Config Form #@num', ['@num' => $num]));
$this->assertNoText(t('Notice'), t('Make sure w/o Notice'));
$this->assertNoText(t('Warning'), t('Make sure w/o Warnings'));
/*
$this->assertText(t('AWS cloud information "%label" has been saved.', array('%label' => $label)),
t('Add - Saved Message:') . ' '
. t('AWS cloud information "%label" has been saved.', array('%label' => $label)));
*/
$this->assertText($label[$i],
t('Cloud Display Name: %label', [
'%label' => $label[$i],
]));
$this->assertText($cloud_context[$i],
t('cloud_context: @cloud_context', [
'@cloud_context' => $cloud_context[$i],
]));
// Make sure listing.
$this->drupalGet('/admin/config/services/cloud/aws_cloud/cloud_context');
$this->assertResponse(200, t('HTTP 200: List | AWS Cloud #@num', ['@num' => $num]));
$this->assertNoText(t('Notice'), t('Make sure w/o Notice'));
$this->assertNoText(t('Warning'), t('Make sure w/o Warnings'));
for ($j = 0; $j < $i + 1; $j++) {
$this->assertText($label[$j],
t('Cloud Display Name @num: %label', [
'@num' => $j + 1,
'%label' => $label[$j],
]));
$this->assertText($cloud_context[$j],
t('Make sure w/ Listing @num: @cloud_context', [
'@num' => $j + 1,
'@cloud_context' => $cloud_context[$j],
]));
}
}
// @FIXEME until here
// Access to AWS Cloud Menu
// $clouds = $this->getClouds();
// foreach ($clouds as $cloud) {.
$cloud_context = $add[0]['cloud_context'];
$this->createServerTemplate();
// List Instance for Amazon EC2.
$this->drupalGet("/clouds/aws_cloud/$cloud_context/instance");
......@@ -151,23 +55,21 @@ class InstanceTest extends WebTestBase {
// Launch a new Instance.
$add = $this->createInstanceTestData();
for ($i = 0; $i < AWS_CLOUD_INSTANCE_REPEAT_COUNT; $i++) {
$num = $i + 1;
$this->drupalPostForm("/clouds/aws_cloud/$cloud_context/instance/launch",
$add[$i],
t('Save'));
$this->addInstanceMockData($add[$i]['name'], $add[$i]['key_pair_name']);
$this->drupalPostForm("/clouds/design/server_template/$cloud_context/1/launch",
[],
t('Launch'));
$this->assertResponse(200, t('HTTP 200: Launch | A New Cloud Instance #@num', ['@num' => $num]));
$this->assertNoText(t('Notice'), t('Launch | Make sure w/o Notice'));
$this->assertNoText(t('warning'), t('Launch | Make sure w/o Warnings'));
$this->assertText(t('The AWS Cloud Instance "@name', [
'@name' => $add[$i]['name'],
]),
t('Confirm Message') . ': '
. t('Launch | The AWS Cloud Instance "@name" request has been initiated.', [
'@name' => $add[$i]['name'],
]));
$this->assertText($add[$i]['name'], t('Instance Name: @name ', ['@name' => $add[$i]['name']]));
// Make sure listing.
for ($j = 0; $j < $i + 1; $j++) {
$this->assertText($add[$j]['name'], t('Make sure w/ Listing: @name', [
'@name' => $add[$j]['name'],
]));
}
// Make sure View.
/*
......@@ -176,21 +78,6 @@ class InstanceTest extends WebTestBase {
$this->assertNoText(t('Notice'), t('Launch | View | Make sure w/o Notice'));
$this->assertNoText(t('warning'), t('Launch | View | Make sure w/o Warnings'));
*/
// Make sure listing.
$this->drupalGet("/clouds/aws_cloud/$cloud_context/instance");
$this->assertResponse(200, t('Launch | List | HTTP 200: Instance #@num', ['@num' => $num]));
$this->assertNoText(t('Notice'), t('Launch | List | Make sure w/o Notice'));
$this->assertNoText(t('warning'), t('Launch | List | Make sure w/o Warnings'));
for ($j = 0; $j < $i + 1; $j++) {
$this->assertText($add[$j]['name'], t('Make sure w/ Listing: @name', [
'@name' => $add[$j]['name'],
]));
$this->assertText($add[$j]['key_pair_name'], t('Make sure w/ Listing: @key_pair_name', [
'@key_pair_name' => $add[$j]['key_pair_name'],
]));
}
}
// Edit an Instance information.
......@@ -252,62 +139,62 @@ class InstanceTest extends WebTestBase {
]));
}
}
// Terminate Instance.
for ($i = 0; $i < AWS_CLOUD_INSTANCE_REPEAT_COUNT; $i++) {
$num = $i + 1;
$this->drupalGet("/clouds/aws_cloud/$cloud_context/instance/$num/terminate");
$this->assertResponse(200, t('Terminate: HTTP 200: Instance #@num', ['@num' => $num]));
$this->assertNoText(t('Notice'), t('Terminate | Make sure w/o Notice'));
$this->assertNoText(t('warning'), t('Terminate | Make sure w/o Warnings'));
$this->drupalPostForm("/clouds/aws_cloud/$cloud_context/instance/$num/terminate",
[],
t('Delete | Terminate'));
$this->assertResponse(200, t('Terminate | HTTP 200: The Cloud Instance #@num', ['@num' => $num]));
$this->assertNoText(t('Notice'), t('Terminate | Make sure w/o Notice'));
$this->assertNoText(t('warning'), t('Terminate | Make sure w/o Warnings'));
$this->assertText($edit[$i]['name'], t('Instance Name: @name ', ['@name' => $edit[$i]['name']]));
$this->assertText(t('The AWS Cloud Instance "@name" has been terminated.', [
'@name' => $edit[$i]['name'],
]),
t('Confirm Message') . ': '
. t('Terminate | The AWS Cloud Instance "@name" has been terminated.', [
'@name' => $edit[$i]['name'],
]));
// Make sure listing.
$this->drupalGet("/clouds/aws_cloud/$cloud_context/instance");
$this->assertResponse(200, t('Terminate | HTTP 200: Instance #@num', ['@num' => $num]));
$this->assertNoText(t('Notice'), t('Terminate | List | Make sure w/o Notice'));
$this->assertNoText(t('warning'), t('Terminate | List | Make sure w/o Warnings'));
/*
for ($j = 0; $j < $i + 1; $j++) { // 3 times
$this->assertNoText($edit[$i]['name'],
t('Terminate | List | Make sure w/ Listing: @name', array(
'@name' => $edit[$i]['name'])));
}
*/
}
// Filtering scripting information item
/*
$filter = array(
'filter' => 't1',
'operation' => 0,
);
$this->drupalPost("/clouds/aws_cloud/$cloud_context/instance', $filter, t('Apply'));
$this->assertResponse(200, t('HTTP 200: Search Listings | Filter'));
$scripting_id = AWS_CLOUD_INSTANCE_REPEAT_COUNT - 1 ;
$this->assertText('x1', t('Confirm Item:') . ' ' . 'x1.large');
$this->assertNoText(t('Notice' ), t('Make sure w/o Notice' ));
$this->assertNoText(t('warning'), t('Make sure w/o Warnings'));
*/
// end
// } // End of foreach.
//
// // Terminate Instance.
// for ($i = 0; $i < AWS_CLOUD_INSTANCE_REPEAT_COUNT; $i++) {
//
// $num = $i + 1;
//
// $this->drupalGet("/clouds/aws_cloud/$cloud_context/instance/$num/terminate");
// $this->assertResponse(200, t('Terminate: HTTP 200: Instance #@num', ['@num' => $num]));
// $this->assertNoText(t('Notice'), t('Terminate | Make sure w/o Notice'));
// $this->assertNoText(t('warning'), t('Terminate | Make sure w/o Warnings'));
// $this->drupalPostForm("/clouds/aws_cloud/$cloud_context/instance/$num/terminate",
// [],
// t('Delete | Terminate'));
//
// $this->assertResponse(200, t('Terminate | HTTP 200: The Cloud Instance #@num', ['@num' => $num]));
// $this->assertNoText(t('Notice'), t('Terminate | Make sure w/o Notice'));
// $this->assertNoText(t('warning'), t('Terminate | Make sure w/o Warnings'));
// $this->assertText($edit[$i]['name'], t('Instance Name: @name ', ['@name' => $edit[$i]['name']]));
// $this->assertText(t('The AWS Cloud Instance "@name" has been terminated.', [
// '@name' => $edit[$i]['name'],
// ]),
// t('Confirm Message') . ': '
// . t('Terminate | The AWS Cloud Instance "@name" has been terminated.', [
// '@name' => $edit[$i]['name'],
// ]));
//
// // Make sure listing.
// $this->drupalGet("/clouds/aws_cloud/$cloud_context/instance");
// $this->assertResponse(200, t('Terminate | HTTP 200: Instance #@num', ['@num' => $num]));
// $this->assertNoText(t('Notice'), t('Terminate | List | Make sure w/o Notice'));
// $this->assertNoText(t('warning'), t('Terminate | List | Make sure w/o Warnings'));
// /*
// for ($j = 0; $j < $i + 1; $j++) { // 3 times
// $this->assertNoText($edit[$i]['name'],
// t('Terminate | List | Make sure w/ Listing: @name', array(
// '@name' => $edit[$i]['name'])));
// }
// */
// }
//
// // Filtering scripting information item
// /*
// $filter = array(
// 'filter' => 't1',
// 'operation' => 0,
// );
//
// $this->drupalPost("/clouds/aws_cloud/$cloud_context/instance', $filter, t('Apply'));
// $this->assertResponse(200, t('HTTP 200: Search Listings | Filter'));
// $scripting_id = AWS_CLOUD_INSTANCE_REPEAT_COUNT - 1 ;
// $this->assertText('x1', t('Confirm Item:') . ' ' . 'x1.large');
// $this->assertNoText(t('Notice' ), t('Make sure w/o Notice' ));
// $this->assertNoText(t('warning'), t('Make sure w/o Warnings'));
// */
// // end
// // } // End of foreach.
}
/**
......@@ -343,39 +230,41 @@ class InstanceTest extends WebTestBase {
return $data;
}
/**
*
*/
private function createConfigTestData() {
$this->random = new Random();
// Input Fields
// 3 times.
for ($i = 0; $i < AWS_CLOUD_CONFIG_REPEAT_COUNT; $i++) {
$num = $i + 1;
$data[] = [
'cloud_context' => "amazon_us_west_$num",
'cloud_type' => 'amazon_ec2',
'label' => "Amazon EC2 US West ($num) - " . $this->random->name(8, TRUE),
'description' => "#$num: " . date('Y/m/d H:i:s - D M j G:i:s T Y') . $this->random->string(64, TRUE),
'api_version' => date('Y-m-d'),
'region' => "us-west-$num",
'endpoint' => "ec2.us-west-$num.amazonaws.com",
'aws_access_key' => $this->random->name(20, TRUE),
'aws_secret_key' => $this->random->name(40, TRUE),
'user_id' => $this->random->name(16, TRUE),
'image_upload_url' => "https://s3.amazonaws.com/$num",
'image_register_url' => "ec2.us-west-$num.amazonaws.com",
'certificate' => $this->random->string(255, TRUE),
];
}
return $data;
private function createServerTemplate() {
// create image
$data = [];
$image = entity_create('aws_cloud_image', $data);
$image->set('ami_name', 'image1');
$image->setImageId('ami-abcdef');
$image->save();
$data = [
'type' => 'aws_cloud',
'name' => 'test_template1',
];
// create template
$template = entity_create('cloud_server_template', $data);
$template->setCloudContext($this->cloud_context);
$template->field_test_only->value = '1';
$template->field_max_count->value = 1;
$template->field_min_count->value = 1;
$template->field_monitoring->value = '0';
$template->field_instance_type->value = 't1.micro';
$template->field_image_id->target_id = 1;
//field_ssh_key
$template->save();
}
private function addInstanceMockData($name, $keypair) {
$mock_data = $this->getMockDataFromConfig();
$instance_mock_data_content = $this->getMockDataFileContent(get_class($this), '_instance');
$instance_mock_data_content = str_replace('$name', $name, $instance_mock_data_content);
$instance_mock_data_content = str_replace('$keypair', $keypair, $instance_mock_data_content);
$instance_mock_data = Yaml::decode($instance_mock_data_content);
$mock_data['DescribeInstances']['Reservations'][0]['Instances'][] = $instance_mock_data;
$this->updateMockDataToConfig($mock_data);
}
}
<?php
namespace Drupal\aws_cloud\Tests\Ec2;
namespace Drupal\Tests\aws_cloud\Functional\Ec2;
use Drupal\simpletest\WebTestBase;
use Drupal\Component\Utility\Random;
// Updated by yas 2016/06/23
......@@ -12,7 +11,6 @@ use Drupal\Component\Utility\Random;
// Updated by yas 2016/05/25
// Updated by yas 2016/05/24
// Created by yas 2016/05/23.
// module_load_include('test', 'aws_cloud');.
define('AWS_CLOUD_KEY_PAIR_REPEAT_COUNT', 3);
/**
......@@ -20,59 +18,23 @@ define('AWS_CLOUD_KEY_PAIR_REPEAT_COUNT', 3);
*
* @group AWS Cloud
*/
class KeyPairTest extends WebTestBase {
/* @FIXME extends AwsCloudTestCase { */
class KeyPairTest extends AwsCloudTestCase {
/**
* Modules to enable.
*
* @var array
*/
public static $modules = ['cloud',
'aws_cloud',
];
/**
* The profile to install as a basis for testing.
*
* @var string
*/
protected $profile = 'minimal';
protected $random;
/**
* Set up test.
*/
protected function setUp() {
parent::setUp();
if (!$this->random) {
$this->random = new Random();
}
$config = \Drupal::configFactory()->getEditable('aws_cloud.settings');
$config->set('aws_cloud_test_mode', true);
$web_user = $this->drupalCreateUser([
protected function getPermissions() {
return [
'list aws cloud key pair',
'add aws cloud key pair',
'view aws cloud key pair',
'edit aws cloud key pair',
'delete aws cloud key pair',
]);
$this->drupalLogin($web_user);
];
}
/**
* Tests CRUD for Key Pair information.
*/
public function testKeyPair() {
// Access to AWS Cloud Menu
// $clouds = $this->getClouds();
// foreach ($clouds as $cloud) {.
$cloud_context = $this->random->name(8);
$cloud_context = $this->cloud_context;
// List Key Pair for Amazon EC2.
$this->drupalGet("/clouds/aws_cloud/$cloud_context/key_pair");
......@@ -96,10 +58,10 @@ class KeyPairTest extends WebTestBase {
$this->assertText(t('The AWS Cloud Key Pair "@key_pair_name', [
'@key_pair_name' => $add[$i]['key_pair_name'],
]),
t('Confirm Message') . ': '
. t('Add | The AWS Cloud Key Pair "@key_pair_name" has been created.', [
'@key_pair_name' => $add[$i]['key_pair_name'],
]));
t('Confirm Message') . ': '
. t('Add | The AWS Cloud Key Pair "@key_pair_name" has been created.', [
'@key_pair_name' => $add[$i]['key_pair_name'],
]));
// Make sure listing.
$this->drupalGet("/clouds/aws_cloud/$cloud_context/key_pair");
......@@ -114,70 +76,44 @@ class KeyPairTest extends WebTestBase {
}
}
// Key Pair doesn't have edit operation
// // View an Key Pair information.
// $edit = $this->createKeyPairTestData();
// for ($i = 0; $i < AWS_CLOUD_KEY_PAIR_REPEAT_COUNT; $i++) {
// // Delete Key Pair.
// for ($i = 0; $i < AWS_CLOUD_KEY_PAIR_REPEAT_COUNT; $i++) {
//
// $num = $i + 1;
// $num = $i + 1;
//
// $this->drupalGet("/clouds/aws_cloud/$cloud_context/key_pair/$num");
// $this->assertResponse(200, t('Edit | HTTP 200: A New AWS Cloud Key Pair #@num', array('@num' => $num)));
// $this->assertNoText(t('Notice'), t('Edit | Make sure w/o Notice'));
// $this->assertNoText(t('warning'), t('Edit | Make sure w/o Warnings'));
// $this->assertText($edit[$i]['key_pair_name'],
// t('The AWS Cloud Key Pair: "@key_pair_name".', array('@name' => $edit[$i]['key_pair_name'],)));
// $this->drupalGet("/clouds/aws_cloud/$cloud_context/key_pair/$num/delete");
// $this->assertResponse(200, t('Delete | HTTP 200: Key Pair #@num', ['@num' => $num]));
// $this->assertNoText(t('Notice'), t('Delete | Make sure w/o Notice'));
// $this->assertNoText(t('warning'), t('Delete | Make sure w/o Warnings'));
// $this->drupalPostForm("/clouds/aws_cloud/$cloud_context/key_pair/$num/delete",
// [],
// t('Delete'));
//
// // Make sure listing.
// $this->drupalGet("/clouds/aws_cloud/$cloud_context/key_pair");
// $this->assertResponse(200, t('Edti | List | HTTP 200: Key Pair #@num', array('@num' => $num)));
// $this->assertNoText(t('Notice'), t('Edti | List | Make sure w/o Notice'));
// $this->assertNoText(t('warning'), t('Edti | List | Make sure w/o Warnings'));
// $this->assertResponse(200, t('Delete | HTTP 200: The Cloud Key Pair #@num', ['@num' => $num]));
// $this->assertNoText(t('Notice'), t('Delete | Make sure w/o Notice'));
// $this->assertNoText(t('warning'), t('Delete | Make sure w/o Warnings'));
// $this->assertText($add[$i]['key_pair_name'], t('Name: @key_pair_name ', ['@key_pair_name' => $add[$i]['key_pair_name']]));
// $this->assertText(t('The AWS Cloud Key Pair "@key_pair_name" has been deleted.', [
// '@key_pair_name' => $add[$i]['key_pair_name'],
// ]),
// t('Confirm Message') . ': '
// . t('Delete | The AWS Cloud Key Pair "@key_pair_name" has been deleted.', [
// '@key_pair_name' => $add[$i]['key_pair_name'],
// ]));
//
// for ($j = 0; $j < $i + 1; $j++) {
// $this->assertText($edit[$i]['key_pair_name'],
// t('Edit | List | Make sure w/ Listing: @key_pair_name', array(
// '@name' => $edit[$i]['key_pair_name'],)));
// }
// }
// Delete Key Pair.
for ($i = 0; $i < AWS_CLOUD_KEY_PAIR_REPEAT_COUNT; $i++) {
$num = $i + 1;
$this->drupalGet("/clouds/aws_cloud/$cloud_context/key_pair/$num/delete");
$this->assertResponse(200, t('Delete | HTTP 200: Key Pair #@num', ['@num' => $num]));
$this->assertNoText(t('Notice'), t('Delete | Make sure w/o Notice'));
$this->assertNoText(t('warning'), t('Delete | Make sure w/o Warnings'));
$this->drupalPostForm("/clouds/aws_cloud/$cloud_context/key_pair/$num/delete",
[],
t('Delete'));
$this->assertResponse(200, t('Delete | HTTP 200: The Cloud Key Pair #@num', ['@num' => $num]));
$this->assertNoText(t('Notice'), t('Delete | Make sure w/o Notice'));
$this->assertNoText(t('warning'), t('Delete | Make sure w/o Warnings'));
$this->assertText($add[$i]['key_pair_name'], t('Name: @key_pair_name ', ['@key_pair_name' => $add[$i]['key_pair_name']]));
$this->assertText(t('The AWS Cloud Key Pair "@key_pair_name" has been deleted.', [
'@key_pair_name' => $add[$i]['key_pair_name'],
]),
t('Confirm Message') . ': '
. t('Delete | The AWS Cloud Key Pair "@key_pair_name" has been deleted.', [
'@key_pair_name' => $add[$i]['key_pair_name'],
]));
// Make sure listing.
$this->drupalGet("/clouds/aws_cloud/$cloud_context/key_pair");
$this->assertResponse(200, t('HTTP 200: Delete | Key Pair #@num', ['@num' => $num]));
$this->assertNoText(t('Notice'), t('Make sure w/o Notice'));
$this->assertNoText(t('warning'), t('Make sure w/o Warnings'));
/*
for ($j = 0; $j < $i + 1; $j++) { // 3 times
$this->assertNoText($add[$i]['key_pair_name'],
t('Delete | List | Make sure w/ Listing: @key_pair_name', array(
'@key_pair_name' => $add[$i]['key_pair_name'])));
}
*/
}
// // Make sure listing.
// $this->drupalGet("/clouds/aws_cloud/$cloud_context/key_pair");
// $this->assertResponse(200, t('HTTP 200: Delete | Key Pair #@num', ['@num' => $num]));
// $this->assertNoText(t('Notice'), t('Make sure w/o Notice'));
// $this->assertNoText(t('warning'), t('Make sure w/o Warnings'));
// /*
// for ($j = 0; $j < $i + 1; $j++) { // 3 times
// $this->assertNoText($add[$i]['key_pair_name'],
// t('Delete | List | Make sure w/ Listing: @key_pair_name', array(
// '@key_pair_name' => $add[$i]['key_pair_name'])));
// }
// */
// }
// Filtering scripting information item
/*
......
<?php
namespace Drupal\aws_cloud\Tests\Ec2;
namespace Drupal\Tests\aws_cloud\Functional\Ec2;
use Drupal\simpletest\WebTestBase;
use Drupal\Component\Utility\Random;
// Updated by yas 2016/06/23
......@@ -14,7 +13,6 @@ use Drupal\Component\Utility\Random;
// Updated by yas 2016/05/25
// Updated by yas 2016/05/24
// Created by yas 2016/05/23.
// module_load_include('test', 'aws_cloud');.
define('AWS_CLOUD_NETWORK_INTERFACE_REPEAT_COUNT', 3);
/**
......@@ -22,59 +20,23 @@ define('AWS_CLOUD_NETWORK_INTERFACE_REPEAT_COUNT', 3);
*
* @group AWS Cloud
*/
class NetworkInterfaceTest extends WebTestBase {
/* @FIXME extends AwsCloudTestCase { */
class NetworkInterfaceTest extends AwsCloudTestCase {
/**
* Modules to enable.
*
* @var array
*/
public static $modules = ['cloud',
'aws_cloud',
];
/**
* The profile to install as a basis for testing.
*
* @var string
*/
protected $profile = 'minimal';
protected $random;
/**
* Set up test.
*/
protected function setUp() {
parent::setUp();
if (!$this->random) {
$this->random = new Random();
}
$config = \Drupal::configFactory()->getEditable('aws_cloud.settings');
$config->set('aws_cloud_test_mode', true);
$web_user = $this->drupalCreateUser([
protected function getPermissions() {
return [
'list aws cloud network interface',
'add aws cloud network interface',
'view aws cloud network interface',
'edit aws cloud network interface',
'delete aws cloud network interface',
]);
$this->drupalLogin($web_user);
];
}
/**
* Tests CRUD for Network Interface information.
*/
public function testNetworkInterface() {
// Access to AWS Cloud Menu
// $clouds = $this->getClouds();
// foreach ($clouds as $cloud) {.
$cloud_context = $this->random->name(8);
$cloud_context = $this->cloud_context;
// List Network Interface for Amazon EC2.
$this->drupalGet("/clouds/aws_cloud/$cloud_context/network_interface");
......@@ -173,43 +135,43 @@ class NetworkInterfaceTest extends WebTestBase {
]));
}
}
// Delete Network Interface.
for ($i = 0; $i < AWS_CLOUD_NETWORK_INTERFACE_REPEAT_COUNT; $i++) {
$num = $i + 1;
$this->drupalGet("/clouds/aws_cloud/$cloud_context/network_interface/$num/delete");
$this->assertResponse(200, t('HTTP 200: Delete | Network Interface #@num', ['@num' => $num]));
$this->assertNoText(t('Notice'), t('Delete | Make sure w/o Notice'));
$this->assertNoText(t('warning'), t('Delete | Make sure w/o Warnings'));
$this->drupalPostForm("/clouds/aws_cloud/$cloud_context/network_interface/$num/delete",
[],
t('Delete'));
$this->assertResponse(200, t('Delete | HTTP 200: The Cloud Network Interface #@num', ['@num' => $num]));
$this->assertNoText(t('Notice'), t('Delete | Make sure w/o Notice'));
$this->assertNoText(t('warning'), t('Delete | Make sure w/o Warnings'));
$this->assertText($edit[$i]['name'], t('Name: @name ', ['@name' => $edit[$i]['name']]));
$this->assertText(t('The AWS Cloud Network Interface "@name" has been deleted.', [
'@name' => $edit[$i]['name'],
]),
t('Confirm Message') . ': '
. t('Delete | The AWS Cloud Network Interface "@name" has been deleted.', [
'@name' => $edit[$i]['name'],
]));
// Make sure listing.
$this->drupalGet("/clouds/aws_cloud/$cloud_context/network_interface");
$this->assertResponse(200, t('Delete | HTTP 200: Network Interface #@num', ['@num' => $num]));
$this->assertNoText(t('Notice'), t('Delete | List | Make sure w/o Notice'));
$this->assertNoText(t('warning'), t('Delete | List | Make sure w/o Warnings'));
/*
for ($j = 0; $j < $i + 1; $j++) { // 3 times
$this->assertNoText($edit[$i]['name'],
t('Delete | List | Make sure w/ Listing: @name', array(
'@name' => $edit[$i]['name'])));
}
*/
}
//
// // Delete Network Interface.
// for ($i = 0; $i < AWS_CLOUD_NETWORK_INTERFACE_REPEAT_COUNT; $i++) {
// $num = $i + 1;
// $this->drupalGet("/clouds/aws_cloud/$cloud_context/network_interface/$num/delete");
// $this->assertResponse(200, t('HTTP 200: Delete | Network Interface #@num', ['@num' => $num]));
// $this->assertNoText(t('Notice'), t('Delete | Make sure w/o Notice'));
// $this->assertNoText(t('warning'), t('Delete | Make sure w/o Warnings'));
// $this->drupalPostForm("/clouds/aws_cloud/$cloud_context/network_interface/$num/delete",
// [],
// t('Delete'));
//
// $this->assertResponse(200, t('Delete | HTTP 200: The Cloud Network Interface #@num', ['@num' => $num]));
// $this->assertNoText(t('Notice'), t('Delete | Make sure w/o Notice'));
// $this->assertNoText(t('warning'), t('Delete | Make sure w/o Warnings'));
// $this->assertText($edit[$i]['name'], t('Name: @name ', ['@name' => $edit[$i]['name']]));
// $this->assertText(t('The AWS Cloud Network Interface "@name" has been deleted.', [
// '@name' => $edit[$i]['name'],
// ]),
// t('Confirm Message') . ': '
// . t('Delete | The AWS Cloud Network Interface "@name" has been deleted.', [
// '@name' => $edit[$i]['name'],
// ]));
//
// // Make sure listing.
// $this->drupalGet("/clouds/aws_cloud/$cloud_context/network_interface");
// $this->assertResponse(200, t('Delete | HTTP 200: Network Interface #@num', ['@num' => $num]));
// $this->assertNoText(t('Notice'), t('Delete | List | Make sure w/o Notice'));
// $this->assertNoText(t('warning'), t('Delete | List | Make sure w/o Warnings'));
// /*
// for ($j = 0; $j < $i + 1; $j++) { // 3 times
// $this->assertNoText($edit[$i]['name'],
// t('Delete | List | Make sure w/ Listing: @name', array(
// '@name' => $edit[$i]['name'])));
// }
// */
// }
// Filtering scripting information item
/*
......
<?php
namespace Drupal\aws_cloud\Tests\Ec2;
namespace Drupal\Tests\aws_cloud\Functional\Ec2;
use Drupal\simpletest\WebTestBase;
use Drupal\Component\Utility\Random;
// Updated by yas 2016/06/23
......@@ -12,7 +11,6 @@ use Drupal\Component\Utility\Random;
// Uppated by yas 2016/05/28
// Updated by yas 2016/05/25
// Created by yas 2016/05/23.
// module_load_include('test', 'aws_cloud');.
define('AWS_CLOUD_SECURITY_GROUP_REPEAT_COUNT', 3);
/**
......@@ -20,59 +18,23 @@ define('AWS_CLOUD_SECURITY_GROUP_REPEAT_COUNT', 3);
*
* @group AWS Cloud
*/
class SecurityGroupTest extends WebTestBase {
/* @FIXME extends AwsCloudTestCase { */
class SecurityGroupTest extends AwsCloudTestCase {
/**
* Modules to enable.
*
* @var array
*/
public static $modules = ['cloud',
'aws_cloud',
];
/**
* The profile to install as a basis for testing.
*
* @var string
*/
protected $profile = 'minimal';
protected $random;
/**
* Set up test.
*/
protected function setUp() {
parent::setUp();
if (!$this->random) {
$this->random = new Random();
}
$config = \Drupal::configFactory()->getEditable('aws_cloud.settings');
$config->set('aws_cloud_test_mode', true);
$web_user = $this->drupalCreateUser([
protected function getPermissions() {
return [
'list aws cloud security group',
'add aws cloud security group',
'view aws cloud security group',
'edit aws cloud security group',
'delete aws cloud security group',
]);
$this->drupalLogin($web_user);
];
}
/**
* Tests CRUD for Security Group information.
*/
public function testSecurityGroup() {
// Access to AWS Cloud Menu
// $clouds = $this->getClouds();
// foreach ($clouds as $cloud) {.
$cloud_context = $this->random->name(8);
$cloud_context = $this->cloud_context;
// List Security Group for Amazon EC2.
$this->drupalGet("/clouds/aws_cloud/$cloud_context/security_group");
......@@ -128,86 +90,75 @@ class SecurityGroupTest extends WebTestBase {
// Security Group doesn't have an edit operation.
// Edit an Security Group information.
// $edit = $this->createSecurityGroupTestData();
// for ($i = 0; $i < AWS_CLOUD_SECURITY_GROUP_REPEAT_COUNT; $i++) {
//
// $num = $i + 1;
//
// unset($edit[$i]['description']);
//
// $this->drupalPostForm("/clouds/aws_cloud/$cloud_context/security_group/$num/edit",
// $edit[$i],
// t('Save'));
//
// $this->assertResponse(200, t('Edit | HTTP 200: A New AWS Cloud Security Group #@num', array('@num' => $num)));
// $this->assertNoText(t('Notice'), t('Edit | Make sure w/o Notice'));
// $this->assertNoText(t('warning'), t('Edit | Make sure w/o Warnings'));
// $this->assertText(t('The AWS Cloud Security Group "@name" has been saved.', array(
// '@group_name' => $edit[$i]['group_name'],
// )),
// t('Confirm Message') . ': '
// . t('Edit | The AWS Cloud Security Group "@group_name" has been saved.', array(
// '@group_name' => $edit[$i]['group_name'],
// )));
//
// $this->drupalGet("/clouds/aws_cloud/$cloud_context/security_group");
// $this->assertResponse(200, t('Edit | List | HTTP 200: Security Group #@num', array('@num' => $num)));
// $this->assertNoText(t('Notice'), t('Edit | List | Make sure w/o Notice'));
// $this->assertNoText(t('warning'), t('Edit | List | Make sure w/o Warnings'));
//
// $this->assertText($edit[$i]['group_name'], t('key_pair: @group_name ',
// array('@group_name' => $edit[$i]['group_name'])));
//
// // Make sure listing.
// $this->drupalGet("/clouds/aws_cloud/$cloud_context/security_group");
// $this->assertResponse(200, t('Edit | List | HTTP 200: Security Group #@num', array('@num' => $num)));
// $this->assertNoText(t('Notice'), t('Edit | List | Make sure w/o Notice'));
// $this->assertNoText(t('warning'), t('Edit | List | Make sure w/o Warnings'));
//
// for ($j = 0; $j < $i + 1; $j++) {
// $this->assertText($edit[$i]['group_name'],
// t('Edit | List | Make sure w/ Listing: @group_name', array(
// '@group_name' => $edit[$i]['group_name'],
// )));
// }
// }
// Delete Security Group.
$edit = $this->createSecurityGroupTestData(TRUE);
for ($i = 0; $i < AWS_CLOUD_SECURITY_GROUP_REPEAT_COUNT; $i++) {
$num = $i + 1;
$this->drupalGet("/clouds/aws_cloud/$cloud_context/security_group/$num/delete");
$this->assertResponse(200, t('Delete | HTTP 200: Security Group #@num', ['@num' => $num]));
$this->assertNoText(t('Notice'), t('Delete | Make sure w/o Notice'));
$this->assertNoText(t('warning'), t('Delete | Make sure w/o Warnings'));
$this->drupalPostForm("/clouds/aws_cloud/$cloud_context/security_group/$num/delete",
[],
t('Delete'));
$this->assertResponse(200, t('Delete | HTTP 200: The Cloud Security Group #@num', ['@num' => $num]));
$this->assertNoText(t('Notice'), t('Delete | Make sure w/o Notice'));
$this->assertNoText(t('warning'), t('Delete | Make sure w/o Warnings'));
$this->assertText($add[$i]['group_name'], t('Group Name: @group_name ', ['@group_name' => $add[$i]['group_name']]));
$this->assertText(t('The AWS Cloud Security Group "@group_name" has been deleted.', [
'@group_name' => $add[$i]['group_name'],
]),
t('Confirm Message') . ': '
. t('Delete | The AWS Cloud Security Group "@group_name" has been deleted.', [
'@group_name' => $add[$i]['group_name'],
]));
unset($edit[$i]['description']);
$this->drupalPostForm("/clouds/aws_cloud/$cloud_context/security_group/$num/edit",
$edit[$i],
t('Save'));
$this->assertResponse(200, t('Edit | HTTP 200: A New AWS Cloud Security Group #@num', array('@num' => $num)));
$this->assertNoText(t('Notice'), t('Edit | Make sure w/o Notice'));
$this->assertNoText(t('warning'), t('Edit | Make sure w/o Warnings'));
$this->assertText(t('The AWS Cloud Security Group "@name" has been saved.', array(
'@name' => $edit[$i]['name'],
)),
t('Confirm Message') . ': '
. t('Edit | The AWS Cloud Security Group "@name" has been saved.', array(
'@name' => $edit[$i]['name'],
)));
// Make sure listing.
$this->drupalGet("/clouds/aws_cloud/$cloud_context/security_group");
$this->assertResponse(200, t('HTTP 200: Delete | Security Group #@num', ['@num' => $num]));
$this->assertNoText(t('Notice'), t('Delete | List | Make sure w/o Notice'));
$this->assertNoText(t('warning'), t('Delete | List | Make sure w/o Warnings'));
/*
for ($j = 0; $j < $i + 1; $j++) { // 3 times
$this->assertNoText($add[$i]['group_name'],
t('Delete | List | Make sure w/ Listing: @group_name', array(
'@group_name' => $add[$i]['group_name'])));
}
*/
$this->assertResponse(200, t('Edit | List | HTTP 200: Security Group #@num', array('@num' => $num)));
$this->assertNoText(t('Notice'), t('Edit | List | Make sure w/o Notice'));
$this->assertNoText(t('warning'), t('Edit | List | Make sure w/o Warnings'));
$this->assertText($edit[$i]['name'], t('key_pair: @name ',
array('@name' => $edit[$i]['name'])));
}
// // Delete Security Group.
// for ($i = 0; $i < AWS_CLOUD_SECURITY_GROUP_REPEAT_COUNT; $i++) {
// $num = $i + 1;
// $this->drupalGet("/clouds/aws_cloud/$cloud_context/security_group/$num/delete");
// $this->assertResponse(200, t('Delete | HTTP 200: Security Group #@num', ['@num' => $num]));
// $this->assertNoText(t('Notice'), t('Delete | Make sure w/o Notice'));
// $this->assertNoText(t('warning'), t('Delete | Make sure w/o Warnings'));
// $this->drupalPostForm("/clouds/aws_cloud/$cloud_context/security_group/$num/delete",
// [],
// t('Delete'));
//
// $this->assertResponse(200, t('Delete | HTTP 200: The Cloud Security Group #@num', ['@num' => $num]));
// $this->assertNoText(t('Notice'), t('Delete | Make sure w/o Notice'));
// $this->assertNoText(t('warning'), t('Delete | Make sure w/o Warnings'));
// $this->assertText($add[$i]['group_name'], t('Group Name: @group_name ', ['@group_name' => $add[$i]['group_name']]));
// $this->assertText(t('The AWS Cloud Security Group "@group_name" has been deleted.', [
// '@group_name' => $add[$i]['group_name'],
// ]),
// t('Confirm Message') . ': '
// . t('Delete | The AWS Cloud Security Group "@group_name" has been deleted.', [
// '@group_name' => $add[$i]['group_name'],
// ]));
//
// // Make sure listing.
// $this->drupalGet("/clouds/aws_cloud/$cloud_context/security_group");
// $this->assertResponse(200, t('HTTP 200: Delete | Security Group #@num', ['@num' => $num]));
// $this->assertNoText(t('Notice'), t('Delete | List | Make sure w/o Notice'));
// $this->assertNoText(t('warning'), t('Delete | List | Make sure w/o Warnings'));
// /*
// for ($j = 0; $j < $i + 1; $j++) { // 3 times
// $this->assertNoText($add[$i]['group_name'],
// t('Delete | List | Make sure w/ Listing: @group_name', array(
// '@group_name' => $add[$i]['group_name'])));
// }
// */
// }
// Filtering scripting information item
/*
$filter = array(
......@@ -229,7 +180,7 @@ class SecurityGroupTest extends WebTestBase {
/**
*
*/
private function createSecurityGroupTestData() {
private function createSecurityGroupTestData($isEdit = FALSE) {
$this->random = new Random();
$data = [];
......@@ -240,9 +191,15 @@ class SecurityGroupTest extends WebTestBase {
// Input Fields.
$data[$i] = [
'group_name' => "group-name-#$num - " . $this->random->name(15, TRUE),
'description' => "Description #$num - " . $this->random->name(64, TRUE),
];
if ($isEdit) {
$data[$i]['name'] = "group-name-#$num - " . $this->random->name(15, TRUE);
}
else {
$data[$i]['group_name'] = "group-name-#$num - " . $this->random->name(15, TRUE);
}
}
return $data;
}
......
<?php
namespace Drupal\aws_cloud\Tests\Ec2;
namespace Drupal\Tests\aws_cloud\Functional\Ec2;
use Drupal\simpletest\WebTestBase;
use Drupal\Component\Utility\Random;
// Updated by yas 2016/06/23
......@@ -13,7 +12,6 @@ use Drupal\Component\Utility\Random;
// Updated by yas 2016/05/25
// Updated by yas 2016/05/24
// Created by yas 2016/05/23.
// module_load_include('test', 'aws_cloud');.
define('AWS_CLOUD_SNAPSHOT_REPEAT_COUNT', 3);
/**
......@@ -21,59 +19,23 @@ define('AWS_CLOUD_SNAPSHOT_REPEAT_COUNT', 3);
*
* @group AWS Cloud
*/
class SnapshotTest extends WebTestBase {
/* @FIXME extends AwsCloudTestCase { */
class SnapshotTest extends AwsCloudTestCase {
/**
* Modules to enable.
*
* @var array
*/
public static $modules = ['cloud',
'aws_cloud',
];
/**
* The profile to install as a basis for testing.
*
* @var string
*/
protected $profile = 'minimal';
protected $random;
/**
* Set up test.
*/
protected function setUp() {
parent::setUp();
if (!$this->random) {
$this->random = new Random();
}
$config = \Drupal::configFactory()->getEditable('aws_cloud.settings');
$config->set('aws_cloud_test_mode', true);
$web_user = $this->drupalCreateUser([
protected function getPermissions() {
return [
'list aws cloud snapshot',
'add aws cloud snapshot',
'view aws cloud snapshot',
'edit aws cloud snapshot',
'delete aws cloud snapshot',
]);
$this->drupalLogin($web_user);
];
}
/**
* Tests CRUD for Snapshot information.
*/
public function testSnapshot() {
// Access to AWS Cloud Menu
// $clouds = $this->getClouds();
// foreach ($clouds as $cloud) {.
$cloud_context = $this->random->name(8);
$cloud_context = $this->cloud_context;
// List Snapshot for Amazon EC2.
$this->drupalGet("/clouds/aws_cloud/$cloud_context/snapshot");
......@@ -166,39 +128,41 @@ class SnapshotTest extends WebTestBase {
}
}
// Delete Snapshot.
for ($i = 0; $i < AWS_CLOUD_SNAPSHOT_REPEAT_COUNT; $i++) {
$num = $i + 1;
$this->drupalGet("/clouds/aws_cloud/$cloud_context/snapshot/$num/delete");
$this->assertResponse(200, t('Delete | HTTP 200: Snapshot #@num', ['@num' => $num]));
$this->assertNoText(t('Notice'), t('Delete | Make sure w/o Notice'));
$this->assertNoText(t('warning'), t('Delete | Make sure w/o Warnings'));
$this->drupalPostForm("/clouds/aws_cloud/$cloud_context/snapshot/$num/delete",
[],
t('Delete'));
$this->assertResponse(200, t('Delete | HTTP 200: The Cloud Snapshot #@num', ['@num' => $num]));
$this->assertNoText(t('Notice'), t('Delete | Make sure w/o Notice'));
$this->assertNoText(t('warning'), t('Delete | Make sure w/o Warnings'));
$this->assertText($edit[$i]['name'], t('Name: @name ', ['@name' => $edit[$i]['name']]));
$this->assertText(t('The AWS Cloud Snapshot "@name" has been deleted.', ['@name' => $edit[$i]['name']]),
t('Confirm Message') . ': ' . t('Delete | The AWS Cloud Snapshot "@name" has been deleted.', ['@name' => $edit[$i]['name']]));
//
// // Delete Snapshot.
// for ($i = 0; $i < AWS_CLOUD_SNAPSHOT_REPEAT_COUNT; $i++) {
//
// $num = $i + 1;
//
// $this->drupalGet("/clouds/aws_cloud/$cloud_context/snapshot/$num/delete");
// $this->assertResponse(200, t('Delete | HTTP 200: Snapshot #@num', ['@num' => $num]));
// $this->assertNoText(t('Notice'), t('Delete | Make sure w/o Notice'));
// $this->assertNoText(t('warning'), t('Delete | Make sure w/o Warnings'));
// $this->drupalPostForm("/clouds/aws_cloud/$cloud_context/snapshot/$num/delete",
// [],
// t('Delete'));
//
// $this->assertResponse(200, t('Delete | HTTP 200: The Cloud Snapshot #@num', ['@num' => $num]));
// $this->assertNoText(t('Notice'), t('Delete | Make sure w/o Notice'));
// $this->assertNoText(t('warning'), t('Delete | Make sure w/o Warnings'));
// $this->assertText($edit[$i]['name'], t('Name: @name ', ['@name' => $edit[$i]['name']]));
// $this->assertText(t('The AWS Cloud Snapshot "@name" has been deleted.', ['@name' => $edit[$i]['name']]),
// t('Confirm Message') . ': ' . t('Delete | The AWS Cloud Snapshot "@name" has been deleted.', ['@name' => $edit[$i]['name']]));
//
// // Make sure listing.
// $this->drupalGet("/clouds/aws_cloud/$cloud_context/snapshot");
// $this->assertResponse(200, t('Delete | HTTP 200: Snapshot', ['@num' => $num]));
// $this->assertNoText(t('Notice'), t('Delete | List | Make sure w/o Notice'));
// $this->assertNoText(t('warning'), t('Delete | List | Make sure w/o Warnings'));
// /*
// for ($j = 0; $j < $i + 1; $j++) { // 3 times
// $this->assertNoText($edit[$i]['name'],
// t('Delete | List | Make sure w/ Listing: @name', array(
// '@name' => $edit[$i]['name'])));
// }
// */
// }
// Make sure listing.
$this->drupalGet("/clouds/aws_cloud/$cloud_context/snapshot");
$this->assertResponse(200, t('Delete | HTTP 200: Snapshot', ['@num' => $num]));
$this->assertNoText(t('Notice'), t('Delete | List | Make sure w/o Notice'));
$this->assertNoText(t('warning'), t('Delete | List | Make sure w/o Warnings'));
/*
for ($j = 0; $j < $i + 1; $j++) { // 3 times
$this->assertNoText($edit[$i]['name'],
t('Delete | List | Make sure w/ Listing: @name', array(
'@name' => $edit[$i]['name'])));
}
*/
}
// Filtering scripting information item
/*
$filter = array(
......
<?php
namespace Drupal\aws_cloud\Tests\Ec2;
namespace Drupal\Tests\aws_cloud\Functional\Ec2;
use Drupal\simpletest\WebTestBase;
use Drupal\Component\Utility\Random;
// Updated by yas 2016/06/23
......@@ -12,7 +11,6 @@ use Drupal\Component\Utility\Random;
// Updated by yas 2016/05/29
// Updated by yas 2016/05/25
// Created by yas 2016/05/23.
// module_load_include('test', 'aws_cloud');.
define('AWS_CLOUD_VOLUME_REPEAT_COUNT', 3);
/**
......@@ -20,59 +18,23 @@ define('AWS_CLOUD_VOLUME_REPEAT_COUNT', 3);
*
* @group AWS Cloud
*/
class VolumeTest extends WebTestBase {
/* @FIXME extends AwsCloudTestCase { */
class VolumeTest extends AwsCloudTestCase {
/**
* Modules to enable.
*
* @var array
*/
public static $modules = ['cloud',
'aws_cloud',
];
/**
* The profile to install as a basis for testing.
*
* @var string
*/
protected $profile = 'minimal';
protected $random;
/**
* Set up test.
*/
protected function setUp() {
parent::setUp();
if (!$this->random) {
$this->random = new Random();
}
$config = \Drupal::configFactory()->getEditable('aws_cloud.settings');
$config->set('aws_cloud_test_mode', true);
$web_user = $this->drupalCreateUser([
protected function getPermissions() {
return [
'list aws cloud volume',
'add aws cloud volume',
'view aws cloud volume',
'edit aws cloud volume',
'delete aws cloud volume',
]);
$this->drupalLogin($web_user);
];
}
/**
* Tests CRUD for Volume information.
*/
public function testVolume() {
// Access to AWS Cloud Menu
// $clouds = $this->getClouds();
// foreach ($clouds as $cloud) {.
$cloud_context = $this->random->name(8);
$cloud_context = $this->cloud_context;
// List Volume for Amazon EC2.
$this->drupalGet("/clouds/aws_cloud/$cloud_context/volume");
......@@ -194,13 +156,6 @@ class VolumeTest extends WebTestBase {
$this->assertResponse(200, t('Delete | HTTP 200: Volume #@num', ['@num' => $num]));
$this->assertNoText(t('Notice'), t('Delete | Make sure w/o Notice'));
$this->assertNoText(t('warning'), t('Delete | Make sure w/o Warnings'));
/*
for ($j = 0; $j < $i + 1; $j++) { // 3 times
$this->assertNoText($edit[$i]['name'],
t('Delete | List | Make sure w/ Listing: @name', array(
'@name' => $edit[$i]['name'])));
}
*/
}
// Filtering scripting information item
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment