/usr/share/otrs/scripts/test/CloudService.t is in otrs2 6.0.5-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 | # --
# Copyright (C) 2001-2018 OTRS AG, http://otrs.com/
# --
# This software comes with ABSOLUTELY NO WARRANTY. For details, see
# the enclosed file COPYING for license information (AGPL). If you
# did not receive this file, see http://www.gnu.org/licenses/agpl.txt.
# --
use strict;
use warnings;
use utf8;
use vars (qw($Self));
use Kernel::System::VariableCheck qw(:all);
my $Index = 0;
my @Tests = (
{
Name => 'Test ' . $Index . '.- No RequestData',
Success => '0',
},
{
Name => 'Test ' . $Index . '.- RequestData is not an array, HASH',
RequestData => {},
Success => '0',
},
{
Name => 'Test ' . $Index . '.- RequestData is not an array, STRING',
RequestData => 'Array',
Success => '0',
},
{
Name => 'Test ' . $Index . '.- RequestData without web service',
RequestData => {
'' => [
{
InstanceName => 'AnyName', # optional
Operation => "ConfigurationSet",
Data => {
# ... request operation data ...
},
},
],
},
Success => '0',
},
{
Name => 'Test ' . $Index . '.- RequestData without Operation',
RequestData => {
CloudServiceTest => [
{
InstanceName => 'AnyName', # optional
Data => {
# ... request operation data ...
},
},
],
},
Success => '0',
},
{
Name => 'Test ' . $Index . '.- Wrong Data structure - STRING',
RequestData => {
CloudServiceTest => [
{
InstanceName => 'MyInstance', # optional
Operation => "ConfigurationSet",
Data => 'NoCorrectDataStructure',
},
],
},
Success => '0',
},
{
Name => 'Test ' . $Index . '.- Wrong Data structure - ARRAY',
RequestData => {
CloudServiceTest => [
{
InstanceName => 'MyInstance', # optional
Operation => "ConfigurationSet",
Data => [ 'a', 'b', 'c', 'd' ],
},
],
},
Success => '0',
},
{
Name => 'Test ' . $Index . '.- Correct Request data structure - Not a real CloudService',
RequestData => {
CloudServiceTest => [
{
InstanceName => 'AnyName', # optional
Operation => "ConfigurationSet",
Data => {
# ... request operation data ...
},
},
],
},
Success => '1',
},
);
my $CloudServiceObject = $Kernel::OM->Get('Kernel::System::CloudService::Backend::Run');
for my $Test (@Tests) {
my $RequestResult = $CloudServiceObject->Request(
%{$Test},
);
if ( $Test->{Success} ) {
if ( defined $RequestResult ) {
$Self->Is(
ref $RequestResult,
'HASH',
"$Test->{Name} - Operation result Data structure",
);
# check result for each cloud service is available
for my $CloudServiceName ( sort keys %{ $Test->{RequestData} } ) {
$Self->True(
$RequestResult->{$CloudServiceName},
"$Test->{Name} - A result for each Cloud Service should be present - $CloudServiceName.",
);
$Self->Is(
scalar @{ $RequestResult->{$CloudServiceName} },
scalar @{ $Test->{RequestData}->{$CloudServiceName} },
"$Test->{Name} - Each operation should return a result.",
);
}
}
else {
$Self->True(
1,
"$Test->{Name} - A result from Cloud Service is not availble perhaps web response was not successful because Internet connection.",
);
}
}
else {
$Self->Is(
$RequestResult,
undef,
"$Test->{Name} - Operation executed with Fail",
);
}
}
1;
|