-
Notifications
You must be signed in to change notification settings - Fork 865
/
Copy pathSmokeTestsV2.partial.cs
204 lines (166 loc) · 6.14 KB
/
SmokeTestsV2.partial.cs
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
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;
using Json.LitJson;
namespace ServiceClientGenerator.Generators.TestFiles
{
public partial class SmokeTestsV2
{
#region Core Configuration Properties
public string GetRegion(JsonData testCase)
{
var config = testCase["config"];
if (config == null)
return null;
var region = config["region"];
if (region == null)
return null;
return region.ToJson();
}
public string GetUri(JsonData testCase)
{
var config = testCase["config"];
if (config == null)
return null;
var uri = config["uri"];
if (uri == null)
return null;
return $"\"{uri.ToString()}\"";
}
#endregion
#region Endpoint Configuration Properties
public bool? GetUseFipsEndpoint(JsonData testCase)
{
var config = testCase["config"];
if (config == null)
return null;
var useFips = config["useFips"];
if (useFips == null)
return null;
return (bool)useFips;
}
public bool? GetUseDualstackEndpoint(JsonData testCase)
{
var config = testCase["config"];
if (config == null)
return null;
var useDualstack = config["useDualstack"];
if (useDualstack == null)
return null;
return (bool)useDualstack;
}
#endregion
#region S3-Specific Configuration Properties
public bool? GetUseAccelerateEndpoint(JsonData testCase)
{
var config = testCase["config"];
if (config == null)
return null;
var useAccelerate = config["useAccelerate"];
if (useAccelerate == null)
return null;
return (bool)useAccelerate;
}
public bool? GetUseGlobalEndpoint(JsonData testCase)
{
var config = testCase["config"];
if (config == null)
return null;
var useGlobalEndpoint = config["useGlobalEndpoint"];
if (useGlobalEndpoint == null)
return null;
return (bool)useGlobalEndpoint;
}
public bool? GetUseArnRegion(JsonData testCase)
{
var config = testCase["config"];
if (config == null)
return null;
var useArnRegion = config["useArnRegion"];
if (useArnRegion == null)
return null;
return (bool)useArnRegion;
}
public bool? GetForcePathStyle(JsonData testCase)
{
var config = testCase["config"];
if (config == null)
return null;
var forcePathStyle = config["forcePathStyle"];
if (forcePathStyle == null)
return null;
return (bool)forcePathStyle;
}
#endregion
#region Authentication Configuration Properties
public bool? GetUseAccountIdRouting(JsonData testCase)
{
var config = testCase["config"];
if (config == null)
return null;
var useAccountIdRouting = config["useAccountIdRouting"];
if (useAccountIdRouting == null)
return null;
return (bool)useAccountIdRouting;
}
public string[] GetSigV4aRegionSet(JsonData testCase)
{
var config = testCase["config"];
if (config == null)
return null;
var sigv4aRegionSet = config["sigv4aRegionSet"];
if (sigv4aRegionSet == null || !sigv4aRegionSet.IsArray)
return null;
var regions = new List<string>();
foreach (JsonData region in sigv4aRegionSet)
{
regions.Add(region.ToString());
}
return regions.ToArray();
}
#endregion
#region Test Case Properties
public JsonData GetInput(JsonData testCase)
{
return testCase["input"];
}
public bool IsSuccessExpected(JsonData testCase)
{
var expectation = testCase["expectation"];
return expectation["success"] != null;
}
public string GetExpectedErrorId(JsonData testCase)
{
var expectation = testCase["expectation"];
var failure = expectation["failure"];
return failure?["errorId"]?.ToString();
}
#endregion
/// <summary>
/// Finds the operation in the ServiceModel based on the operation name in the smoke2 json file. The
/// name in that file does not take any customizations that might have been put in place. So we need to
/// compare to the raw ShapeName instead of Name property which has customizations applied.
/// </summary>
private Operation FindOperation(JsonData testCase)
{
var operationShapeName = testCase["operationName"].ToString();
return this.Config.ServiceModel.Operations.FirstOrDefault(x => string.Equals(x.ShapeName, operationShapeName));
}
/// <summary>
/// Finds the proper .NET property name for a given JSON key in the operation's input shape.
/// </summary>
private string FindPropertyName(Operation operation, string jsonKey)
{
// Get the input shape for the operation
var inputShape = operation.RequestStructure;
if (inputShape == null)
return jsonKey;
// Look for a member in the input shape that matches the json key
var member = inputShape.Members.FirstOrDefault(m =>
string.Equals(m.MarshallLocationName, jsonKey, StringComparison.OrdinalIgnoreCase));
// If found, return the .NET customized name, otherwise return original key
return member?.PropertyName ?? jsonKey;
}
}
}