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 386 additions and 657 deletions
...@@ -2,10 +2,12 @@ name: Cloud ...@@ -2,10 +2,12 @@ name: Cloud
type: module type: module
description: Allows users to manage Clouds. description: Allows users to manage Clouds.
package: Cloud package: Cloud
dependencies:
- drupal:views
version : 8.x-1.x version : 8.x-1.x
core : 8.x core : 8.x
project : cloud project : cloud
scripts: scripts:
- js/cloud.js - js/cloud.js
\ No newline at end of file
...@@ -8,10 +8,10 @@ views.field.cloud_list_instances: ...@@ -8,10 +8,10 @@ views.field.cloud_list_instances:
type: label type: label
label: 'Text to display' label: 'Text to display'
views.field.cloud_server_template_list: views.field.cloud_list_templates:
type: views_field type: views_field
label: 'Link to cloud server template list' label: 'Link to cloud server template list'
mapping: mapping:
text: text:
type: label type: label
label: 'Text to display' label: 'Text to display'
\ No newline at end of file
...@@ -2,6 +2,9 @@ name: 'AWS Cloud' ...@@ -2,6 +2,9 @@ name: 'AWS Cloud'
description: 'Amazon Web Services Compatible Cloud (incl. Amazon EC2, OpenStack nova, Eucalyptus and Cloud n) Implementation' description: 'Amazon Web Services Compatible Cloud (incl. Amazon EC2, OpenStack nova, Eucalyptus and Cloud n) Implementation'
package: Cloud Service Provider package: Cloud Service Provider
dependencies: dependencies:
- drupal:views
- drupal:options
- drupal:user
- cloud - cloud
- cloud_server_template - cloud_server_template
- cloud_pricing - cloud_pricing
......
aws_cloud.settings:
type: config_object
mapping:
aws_cloud_test_mode:
type: boolean
aws_cloud_instance_types:
type: string
aws_cloud_notification_frequency:
type: integer
aws_cloud_notification:
type: integer
aws_cloud_notification_criteria:
type: integer
aws_cloud_notification_subject:
type: string
aws_cloud_notification_msg:
type: string
aws_cloud_mock_data:
type: string
views.access.ViewsCloudContextAccess:
type: mapping
mapping:
perm:
type: string
...@@ -2,6 +2,10 @@ ...@@ -2,6 +2,10 @@
namespace Drupal\aws_cloud\Service; namespace Drupal\aws_cloud\Service;
use Aws\MockHandler;
use Aws\Result;
use Aws\Api\DateTimeResult;
use Aws\Ec2\Ec2Client; use Aws\Ec2\Ec2Client;
use Aws\Ec2\Exception\Ec2Exception; use Aws\Ec2\Exception\Ec2Exception;
use Drupal\aws_cloud\Entity\Ec2\ElasticIp; use Drupal\aws_cloud\Entity\Ec2\ElasticIp;
...@@ -118,8 +122,10 @@ class AwsEc2Service implements AwsEc2ServiceInterface { ...@@ -118,8 +122,10 @@ class AwsEc2Service implements AwsEc2ServiceInterface {
$this->logger = $logger_factory->get('aws_ec2_service'); $this->logger = $logger_factory->get('aws_ec2_service');
// setup the configuration factory // setup the configuration factory
$this->configFactory = $config_factory; $this->configFactory = $config_factory;
// setup the dryRun flag // setup the dryRun flag
$this->dryRun = (bool) $this->configFactory->get('aws_cloud.settings')->get('aws_cloud_test_mode'); $this->dryRun = (bool) $this->configFactory->get('aws_cloud.settings')->get('aws_cloud_test_mode');
// setup the messenger // setup the messenger
$this->messenger = $messenger; $this->messenger = $messenger;
// setup the $this->t() // setup the $this->t()
...@@ -146,6 +152,7 @@ class AwsEc2Service implements AwsEc2ServiceInterface { ...@@ -146,6 +152,7 @@ class AwsEc2Service implements AwsEc2ServiceInterface {
$credentials = $this->cloudConfigPluginManager->loadCredentials(); $credentials = $this->cloudConfigPluginManager->loadCredentials();
try { try {
$ec2_client = Ec2Client::factory($credentials); $ec2_client = Ec2Client::factory($credentials);
$this->addMockHandler($ec2_client);
} }
catch (\Exception $e) { catch (\Exception $e) {
$ec2_client = NULL; $ec2_client = NULL;
...@@ -155,6 +162,38 @@ class AwsEc2Service implements AwsEc2ServiceInterface { ...@@ -155,6 +162,38 @@ class AwsEc2Service implements AwsEc2ServiceInterface {
return $ec2_client; return $ec2_client;
} }
private function addMockHandler($ec2_client) {
$mock_data = $this->configFactory->get('aws_cloud.settings')->get('aws_cloud_mock_data');
if ($this->dryRun && $mock_data) {
$func = function ($command, $request) {
$mock_data = \Drupal::service('config.factory')
->get('aws_cloud.settings')
->get('aws_cloud_mock_data');
$mock_data = json_decode($mock_data, true);
$command_name = $command->getName();
if (isset($mock_data[$command_name])) {
$result_data = $mock_data[$command_name];
if ($command_name == 'DescribeInstances') {
foreach ($result_data['Reservations'] as &$reservation) {
foreach ($reservation['Instances'] as &$instance) {
if (!empty($instance['LaunchTime'])) {
$instance['LaunchTime'] = new DateTimeResult($instance['LaunchTime']);
}
}
}
}
return new Result($result_data);
}
else {
return new Result();
}
};
$ec2_client->getHandlerList()->setHandler(new MockHandler([$func, $func]));
}
}
/** /**
* @param String $operation * @param String $operation
* The operation to perform * The operation to perform
...@@ -523,7 +562,6 @@ class AwsEc2Service implements AwsEc2ServiceInterface { ...@@ -523,7 +562,6 @@ class AwsEc2Service implements AwsEc2ServiceInterface {
// call the api and get all instances // call the api and get all instances
$result = $this->describeInstances(); $result = $this->describeInstances();
if ($result != NULL) { if ($result != NULL) {
$all_instances = $this->loadAllEntities($entity_type); $all_instances = $this->loadAllEntities($entity_type);
...@@ -538,7 +576,6 @@ class AwsEc2Service implements AwsEc2ServiceInterface { ...@@ -538,7 +576,6 @@ class AwsEc2Service implements AwsEc2ServiceInterface {
foreach ($result['Reservations'] as $reservation) { foreach ($result['Reservations'] as $reservation) {
foreach ($reservation['Instances'] as $instance) { foreach ($reservation['Instances'] as $instance) {
// keep track of instances that do not exist anymore // keep track of instances that do not exist anymore
// delete them after saving the rest of the instances // delete them after saving the rest of the instances
if (isset($stale[$instance['InstanceId']])) { if (isset($stale[$instance['InstanceId']])) {
......
This diff is collapsed.
<?php
/**
* @file
* Configuration for aws_cloud.test
*
*/
/**
* Updated by yas 2011/06/07
* Updated by yas 2010/12/26
* Created by yas 2010/12/02
*/
define('AMAZON_EC2_API_VERSION' , '2012-06-01' );
// us-east-1
define('AMAZON_EC2_HOST_URI' , 'ec2.amazonaws.com' );
// PLEASE CHANGE THE FOLLOWING CREDENTIALS
define('AMAZON_EC2_AWS_ACCESS_KEY' , '12ABCDEFGHIJKVWXYZ89' );
define('AMAZON_EC2_API_SECRET_KEY' , '123ABC/defGHIjkl34+LMNopq567RSTuvwxYz89Z');
define('AMAZON_EC2_USER_ID' , '123456789012' );
define('AMAZON_S3_IMAGE_UPLOAD_URL' , 'https://s3.amazonaws.com' );
define('AMAZON_EC2_IMAGE_REGISTER_URL', 'https://ec2.amazonaws.com' );
define('AMAZON_EC2_X509_CERTIFICATE' , "-----BEGIN CERTIFICATE-----\nXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX\nXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX\nXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX\nXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX\nXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX\nXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX\nXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXX==\n-----END CERTIFICATE-----\n" );
DescribeAvailabilityZones:
AvailabilityZones:
- ZoneName: us-west-1
- ZoneName: us-west-2
- ZoneName: us-west-3
AllocateAddress:
PublicIp: 10.0.0.0
CreateImage:
ImageId: dummy image
DescribeInstances:
Reservations:
- Instances: []
OwnerId: 123456789012
ReservationId: r-1234567890abcdef0
#@FIXME move to Reservations area.
InstanceId: '$name'
InstanceType: t2.micro
Placement:
AvailabilityZone: us-west-1c
Tenancy: default
GroupName: ''
HostId: host1
Affinity: affinity1
LaunchTime: '2018-01-01T00:00:00.000Z'
Tags:
- Key: Name
Value: '$name'
SecurityGroups:
- GroupId: sg-e4076980
GroupName: SecurityGroup1
State:
Code: 16
Name: running
PublicDnsName: ec2-54-250-160-22.ap-northeast-1.compute.amazonaws.com
PublicIpAddress: 54.250.160.22
PrivateDnsName: ip-172-20-61-130.ap-northeast-1.compute.internal
PrivateIpAddress: 172.20.61.130
KeyName: '$keypair'
Monitoring:
State: enabled
VpcId: vpc-e867158c
SubnetId: subnet-0b1b1a7d
SourceDestCheck: false
EbsOptimized: false
RootDeviceType: ebs
RootDeviceName: /dev/xvda
ImageId: ami-f46f5993
VirtualizationType: hvm
AmiLaunchIndex: 0
StateTransitionReason: ''
CreateKeyPair:
KeyName: dummy key
KeyFingerprint: dummy fingerprint
CreateNetworkInterface:
NetworkInterfaceId: dummy network interface
Status: pending
VpcId: dummy vpc id
DescribeVpcs:
Vpcs:
VpcId: vpc-1a2b3c4d
CidrBlock: 192.168.0.0/16
CreateSecurityGroup:
GroupId: dummy group
CreateSnapshot:
SnapshotId: dummy snapshot
Status: pending
StartTime: '2018-01-01T00:00:00.000Z'
Encrypted: TRUE
CreateVolume:
VolumeId: dummy volume
CreateTime: '2018-01-01T00:00:00.000Z'
State: creating
<?php <?php
namespace Drupal\aws_cloud\Tests\Config; namespace Drupal\Tests\aws_cloud\Functional\Config;
use Drupal\simpletest\WebTestBase; use Drupal\Tests\BrowserTestBase;
use Drupal\Component\Utility\Random; use Drupal\Component\Utility\Random;
use Drupal\user\Entity\Role;
// Updated by yas 2016/06/02 // Updated by yas 2016/06/02
// Updated by yas 2016/06/01 // Updated by yas 2016/06/01
...@@ -18,14 +19,14 @@ use Drupal\Component\Utility\Random; ...@@ -18,14 +19,14 @@ use Drupal\Component\Utility\Random;
// updated by yas 2015/06/09 // updated by yas 2015/06/09
// created by yas 2015/06/08. // created by yas 2015/06/08.
// module_load_include('test', 'aws_cloud');. // module_load_include('test', 'aws_cloud');.
define('AWS_CLOUD_CONFIG_REPEAT_COUNT', 3); define('AWS_CLOUD_CONFIG_REPEAT_COUNT', 2);
/** /**
* Tests AWS Cloud Config. * Tests AWS Cloud Config.
* *
* @group AWS Cloud * @group AWS Cloud
*/ */
class ConfigTest extends WebTestBase { class ConfigTest extends BrowserTestBase {
/* @FIXME extends ConfigTestCase { */ /* @FIXME extends ConfigTestCase { */
/** /**
...@@ -60,11 +61,16 @@ class ConfigTest extends WebTestBase { ...@@ -60,11 +61,16 @@ class ConfigTest extends WebTestBase {
$config->set('aws_cloud_test_mode', true); $config->set('aws_cloud_test_mode', true);
$web_user = $this->drupalCreateUser([ $web_user = $this->drupalCreateUser([
'list aws cloud provider', 'administer cloud config entities',
'add aws cloud provider', 'add cloud config entities',
'view aws cloud provider', 'edit cloud config entities',
'edit aws cloud provider', 'edit own cloud config entities',
'delete aws cloud provider', 'delete cloud config entities',
'delete own cloud config entities',
'view unpublished cloud config entities',
'view own unpublished cloud config entities',
'view published cloud config entities',
'view own published cloud config entities',
]); ]);
$this->drupalLogin($web_user); $this->drupalLogin($web_user);
} }
...@@ -74,11 +80,8 @@ class ConfigTest extends WebTestBase { ...@@ -74,11 +80,8 @@ class ConfigTest extends WebTestBase {
*/ */
public function testConfig() { public function testConfig() {
// Access to AWS Cloud Menu
// $clouds = $this->getClouds();
// foreach ($clouds as $cloud) {.
// List AWS Cloud for Amazon EC2. // List AWS Cloud for Amazon EC2.
$this->drupalGet('/admin/config/services/cloud/aws_cloud/cloud_context'); $this->drupalGet('/admin/structure/cloud_config');
$this->assertResponse(200, t('HTTP 200: List | AWS Cloud')); $this->assertResponse(200, t('HTTP 200: List | AWS Cloud'));
$this->assertNoText(t('Notice'), t('Make sure w/o Notice')); $this->assertNoText(t('Notice'), t('Make sure w/o Notice'));
$this->assertNoText(t('Warning'), t('Make sure w/o Warnings')); $this->assertNoText(t('Warning'), t('Make sure w/o Warnings'));
...@@ -89,48 +92,39 @@ class ConfigTest extends WebTestBase { ...@@ -89,48 +92,39 @@ class ConfigTest extends WebTestBase {
$num = $i + 1; $num = $i + 1;
$cloud_context[$i] = $add[$i]['cloud_context']; $cloud_context[$i] = $add[$i]['cloud_context'];
$label[$i] = $add[$i]['label']; $label[$i] = $add[$i]['name[0][value]'];
$this->drupalGet('/admin/config/services/cloud/aws_cloud/cloud_context/add'); $this->drupalGet('/admin/structure/cloud_config/add');
$this->assertResponse(200, t('HTTP 200: Add | AWS Cloud Config Form #@num', ['@num' => $num])); $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('Notice'), t('Make sure w/o Notice'));
$this->assertNoText(t('Warning'), t('Make sure w/o Warnings')); $this->assertNoText(t('Warning'), t('Make sure w/o Warnings'));
$this->drupalPostForm('/admin/config/services/cloud/aws_cloud/cloud_context/add', $this->drupalPostForm('/admin/structure/cloud_config/add',
$add[$i], $add[$i],
t('Save')); t('Save'));
$this->assertResponse(200, t('HTTP 200: Saved | Aws Cloud Config Form #@num', ['@num' => $num])); $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('Notice'), t('Make sure w/o Notice'));
$this->assertNoText(t('Warning'), t('Make sure w/o Warnings')); $this->assertNoText(t('Warning'), t('Make sure w/o Warnings'));
/* $this->assertText(t('Created the @label Cloud config.', array('@label' => $label[$i])),
$this->assertText(t('AWS cloud information "%label" has been saved.', array('%label' => $label)), t('Add - Saved Message:') . ' '
t('Add - Saved Message:') . ' ' . t('Created the @label Cloud config.', array('@label' => $label[$i])));
. t('AWS cloud information "%label" has been saved.', array('%label' => $label)));
*/
$this->assertText($label[$i], $this->assertText($label[$i],
t('Cloud Display Name: %label', [ t('Name: @label', [
'%label' => $label[$i], '@label' => $label[$i],
]));
$this->assertText($cloud_context[$i],
t('cloud_context: @cloud_context', [
'@cloud_context' => $cloud_context[$i],
])); ]));
// Make sure listing. // Make sure listing.
$this->drupalGet('/admin/config/services/cloud/aws_cloud/cloud_context'); $this->drupalGet('/admin/structure/cloud_config');
$this->assertResponse(200, t('HTTP 200: List | AWS Cloud #@num', ['@num' => $num])); $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('Notice'), t('Make sure w/o Notice'));
$this->assertNoText(t('Warning'), t('Make sure w/o Warnings')); $this->assertNoText(t('Warning'), t('Make sure w/o Warnings'));
for ($j = 0; $j < $i + 1; $j++) { for ($j = 0; $j < $i + 1; $j++) {
$this->assertText($label[$j], $this->assertText($label[$j],
t('Cloud Display Name @num: %label', [ t('Cloud config @num: @label', [
'@num' => $j + 1, '@num' => $j + 1,
'%label' => $label[$j], '@label' => $label[$j],
]));
$this->assertText($cloud_context[$j],
t('Make sure w/ Listing @num: @cloud_context', [
'@num' => $j + 1,
'@cloud_context' => $cloud_context[$j],
])); ]));
} }
} }
...@@ -142,12 +136,12 @@ class ConfigTest extends WebTestBase { ...@@ -142,12 +136,12 @@ class ConfigTest extends WebTestBase {
$num = $i + 1; $num = $i + 1;
$cloud_context[$i] = $edit[$i]['cloud_context']; $cloud_context[$i] = $edit[$i]['cloud_context'];
$label[$i] = $edit[$i]['label']; $label[$i] = $edit[$i]['name[0][value]'];
unset($edit[$i]['cloud_context']); unset($edit[$i]['cloud_context']);
unset($edit[$i]['cloud_type']); unset($edit[$i]['field_cloud_type']);
$this->drupalPostForm('/admin/config/services/cloud/aws_cloud/cloud_context/' . $cloud_context[$i] . '/edit', $this->drupalPostForm('/admin/structure/cloud_config/' . $num . '/edit',
$edit[$i], $edit[$i],
t('Save')); t('Save'));
$this->assertResponse(200, t('HTTP 200: Edit | AWS Cloud Form #@num', ['@num' => $num])); $this->assertResponse(200, t('HTTP 200: Edit | AWS Cloud Form #@num', ['@num' => $num]));
...@@ -159,96 +153,56 @@ class ConfigTest extends WebTestBase { ...@@ -159,96 +153,56 @@ class ConfigTest extends WebTestBase {
. t('AWS cloud information "%label" has been saved.', array('%label' => $label))); . t('AWS cloud information "%label" has been saved.', array('%label' => $label)));
*/ */
$this->assertText($label[$i], $this->assertText($label[$i],
t('Cloud Display Name: %label', [ t('Cloud config Name: @label', [
'%label' => $label[$i], '@label' => $label[$i],
]));
$this->assertText($cloud_context[$i],
t('cloud_context: @cloud_context', [
'@cloud_context' => $cloud_context[$i],
])); ]));
// Make sure listing. // Make sure listing.
$this->drupalGet('/admin/config/services/cloud/aws_cloud/cloud_context'); $this->drupalGet('/admin/structure/cloud_config');
$this->assertResponse(200, t('HTTP 200: List | AWS Cloud #@num', ['@num' => $num])); $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('Notice'), t('Make sure w/o Notice'));
$this->assertNoText(t('warning'), t('Make sure w/o Warnings')); $this->assertNoText(t('warning'), t('Make sure w/o Warnings'));
for ($j = 0; $j < $i + 1; $j++) { for ($j = 0; $j < $i + 1; $j++) {
$this->assertText($label[$j], $this->assertText($label[$j],
t('Cloud Display Name @num: %label', [ t('Cloud config @num: @label', [
'@num' => $j + 1,
'%label' => $label[$j],
]));
$this->assertText($cloud_context[$j],
t('Make sure w/ Listing @num: @cloud_context', [
'@num' => $j + 1, '@num' => $j + 1,
'@cloud_context' => $cloud_context[$j], '@label' => $label[$j],
])); ]));
} }
} }
// Delete Config Items. // Delete Config Items.
$delete = $this->createConfigTestData(); $delete = $edit;
for ($i = 0; $i < AWS_CLOUD_CONFIG_REPEAT_COUNT; $i++) { for ($i = 0; $i < AWS_CLOUD_CONFIG_REPEAT_COUNT; $i++) {
$num = $i + 1; $num = $i + 1;
$cloud_context[$i] = $delete[$i]['cloud_context']; $label[$i] = $delete[$i]['name[0][value]'];
$label[$i] = $delete[$i]['label'];
$this->drupalGet('/admin/config/services/cloud/aws_cloud/cloud_context/' . $cloud_context[$i] . '/delete'); $this->drupalGet('/admin/structure/cloud_config/' . $num . '/delete');
$this->drupalPostForm('/admin/config/services/cloud/aws_cloud/cloud_context/' . $cloud_context[$i] . '/delete', $this->drupalPostForm('/admin/structure/cloud_config/' . $num . '/delete',
[], [],
t('Delete')); t('Delete'));
$this->assertResponse(200, t('HTTP 200: Delete | AWS Cloud')); $this->assertResponse(200, t('HTTP 200: Delete | AWS Cloud'));
$this->assertNoText(t('Notice'), t('Make sure w/o Notice')); $this->assertNoText(t('Notice'), t('Make sure w/o Notice'));
$this->assertNoText(t('Warning'), t('Make sure w/o Warnings')); $this->assertNoText(t('Warning'), t('Make sure w/o Warnings'));
/* $this->assertText(t('The cloud config @label has been deleted.', array('@label' => $label[$i])),
$this->assertText(t('content aws_cloud: deleted %label.', array('%label' => $label)),
t('Deleted Message:') . ' ' t('Deleted Message:') . ' '
. t('content aws_cloud: deleted %label.', array('%label' => $label))); . t('The cloud config @label has been deleted.', array('@label' => $label[$i])));
*/
$this->assertNoText($label[$i],
t('Cloud Display Name: %label', [
'%label' => $label[$i],
]));
$this->assertNoText($cloud_context[$i],
t('cloud_context: @cloud_context', [
'@cloud_context' => $cloud_context[$i],
]));
// Because $cloud_context has been deleted. // Because $cloud_context has been deleted.
// Make sure listing. // Make sure listing.
$this->drupalGet('/admin/config/services/cloud/aws_cloud/cloud_context'); $this->drupalGet('/admin/structure/cloud_config');
$this->assertResponse(200, t('HTTP 200: List | AWS Cloud #@num', ['@num' => $num])); $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('Notice'), t('Make sure w/o Notice'));
$this->assertNoText(t('Warning'), t('Make sure w/o Warnings')); $this->assertNoText(t('Warning'), t('Make sure w/o Warnings'));
for ($j = 0; $j < $i + 1; $j++) { for ($j = 0; $j < $i + 1; $j++) {
$this->assertNoText($label[$j], $this->assertNoText($label[$j],
t('Cloud Display Name @num: %label', [ t('Cloud config Name @num: @label', [
'@num' => $j + 1,
'%label' => $label[$j],
]));
$this->assertNoText($cloud_context[$j],
t('Make sure w/ Listing @num: @cloud_context', [
'@num' => $j + 1, '@num' => $j + 1,
'@cloud_context' => $cloud_context[$j], '@label' => $label[$j],
])); ]));
} }
} }
// Filtering pricing information item
/*
$filter = array(
'filter' => 't1',
'operation' => 0,
);
$this->drupalPost("/admin/config/services/cloud/aws_cloud/cloud_context/$cloud_context", $filter, t('Apply'));
$this->assertResponse(200, t('HTTP 200: Search Listings | Filter'));
$xxxxx = AWS_CLOUD_CONFIG_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.
} }
/** /**
...@@ -265,19 +219,18 @@ class ConfigTest extends WebTestBase { ...@@ -265,19 +219,18 @@ class ConfigTest extends WebTestBase {
$num = $i + 1; $num = $i + 1;
$data[] = [ $data[] = [
'cloud_context' => "amazon_us_west_$num", 'cloud_context' => "amazon_us_west_$num",
'cloud_type' => 'amazon_ec2', 'field_cloud_type' => 'amazon_ec2',
'label' => "Amazon EC2 US West ($num) - " . $this->random->name(8, TRUE), 'name[0][value]' => "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), 'field_description[0][value]' => "#$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'), 'field_api_version[0][value]' => date('Y-m-d'),
'region' => "us-west-$num", 'field_region' => "us-west-$num",
'endpoint' => "ec2.us-west-$num.amazonaws.com", 'field_api_endpoint_uri' => "https://ec2.us-west-$num.amazonaws.com",
'aws_access_key' => $this->random->name(20, TRUE), 'field_secret_key[0][value]' => $this->random->name(20, TRUE),
'aws_secret_key' => $this->random->name(40, TRUE), 'field_access_key[0][value]' => $this->random->name(40, TRUE),
'user_id' => $this->random->name(16, TRUE), 'field_user_id[0][value]' => $this->random->name(16, TRUE),
'image_upload_url' => "https://s3.amazonaws.com/$num", 'field_image_upload_url' => "https://ec2.us-west-$num.amazonaws.com",
'image_register_url' => "ec2.us-west-$num.amazonaws.com", 'field_x_509_certificate[0][value]' => $this->random->string(255, TRUE),
'certificate' => $this->random->string(255, TRUE),
]; ];
} }
......
<?php <?php
use Drupal\simpletest\WebTestBase; use Drupal\simpletest\WebTestBase;
namespace Drupal\aws_cloud\Tests\Config; namespace Drupal\Tests\aws_cloud\Functional\Config;
/** /**
* *
*/ */
......
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