17
17
/** Operator class with all the utility methods for Operator. */
18
18
public class Operator {
19
19
20
+ public static enum RESTCertType {
21
+ /*self-signed certificate and public key stored in a kubernetes tls secret*/
22
+ SELF_SIGNED ,
23
+ /*Certificate signed by an auto-created CA signed by an auto-created root certificate,
24
+ * both and stored in a kubernetes tls secret*/
25
+ CHAIN ,
26
+ /*Certificate and public key, and stored in a kubernetes tls secret*/
27
+ LEGACY
28
+ };
29
+
20
30
public static final String CREATE_OPERATOR_SCRIPT_MESSAGE =
21
31
"The Oracle WebLogic Server Kubernetes Operator is deployed" ;
22
32
@@ -36,6 +46,7 @@ public class Operator {
36
46
37
47
private static int maxIterationsOp = BaseTest .getMaxIterationsPod (); // 50 * 5 = 250 seconds
38
48
private static int waitTimeOp = BaseTest .getWaitTimePod ();
49
+ private static RESTCertType restCertType = RESTCertType .SELF_SIGNED ;
39
50
40
51
/**
41
52
* Takes operator input properties which needs to be customized and generates a operator input
@@ -44,9 +55,10 @@ public class Operator {
44
55
* @param inputYaml
45
56
* @throws Exception
46
57
*/
47
- public Operator (String inputYaml , boolean useLegacyRESTIdentity ) throws Exception {
58
+ public Operator (String inputYaml , RESTCertType restCertType ) throws Exception {
59
+ this .restCertType = restCertType ;
48
60
initialize (inputYaml );
49
- generateInputYaml (useLegacyRESTIdentity );
61
+ generateInputYaml ();
50
62
callHelmInstall ();
51
63
}
52
64
@@ -195,8 +207,7 @@ public void scale(String domainUid, String clusterName, int numOfMS) throws Exce
195
207
.append (clusterName )
196
208
.append ("/scale" );
197
209
198
- TestUtils .makeOperatorPostRestCall (
199
- operatorNS , myOpRestApiUrl .toString (), myJsonObjStr , userProjectsDir );
210
+ TestUtils .makeOperatorPostRestCall (this , myOpRestApiUrl .toString (), myJsonObjStr );
200
211
// give sometime to complete
201
212
logger .info ("Wait 30 sec for scaling to complete..." );
202
213
Thread .sleep (30 * 1000 );
@@ -217,7 +228,23 @@ public void verifyDomainExists(String domainUid) throws Exception {
217
228
.append (externalRestHttpsPort )
218
229
.append ("/operator/latest/domains/" )
219
230
.append (domainUid );
220
- TestUtils .makeOperatorGetRestCall (operatorNS , myOpRestApiUrl .toString (), userProjectsDir );
231
+ TestUtils .makeOperatorGetRestCall (this , myOpRestApiUrl .toString ());
232
+ }
233
+
234
+ /**
235
+ * Verify the Operator's REST Api is working fine over TLS
236
+ *
237
+ * @throws Exception
238
+ */
239
+ public void verifyOperatorExternalRESTEndpoint () throws Exception {
240
+ // Operator REST external API URL to scale
241
+ StringBuffer myOpRestApiUrl =
242
+ new StringBuffer ("https://" )
243
+ .append (TestUtils .getHostName ())
244
+ .append (":" )
245
+ .append (externalRestHttpsPort )
246
+ .append ("/operator/" );
247
+ TestUtils .makeOperatorGetRestCall (this , myOpRestApiUrl .toString ());
221
248
}
222
249
223
250
public Map <String , Object > getOperatorMap () {
@@ -258,23 +285,28 @@ private String getExecFailure(String cmd, ExecResult result) throws Exception {
258
285
}
259
286
260
287
private void generateInputYaml () throws Exception {
261
- generateInputYaml (false );
262
- }
263
-
264
- private void generateInputYaml (boolean useLegacyRESTIdentity ) throws Exception {
265
288
Path parentDir =
266
289
Files .createDirectories (Paths .get (userProjectsDir + "/weblogic-operators/" + operatorNS ));
267
290
generatedInputYamlFile = parentDir + "/weblogic-operator-values.yaml" ;
268
291
TestUtils .createInputFile (operatorMap , generatedInputYamlFile );
269
292
StringBuilder sb = new StringBuilder (200 );
270
293
sb .append (BaseTest .getProjectRoot ());
271
- if (useLegacyRESTIdentity ) {
272
- sb .append (
273
- "/integration-tests/src/test/resources/scripts/legacy-generate-external-rest-identity.sh " );
274
- } else {
275
- sb .append ("/kubernetes/samples/scripts/rest/generate-external-rest-identity.sh " );
276
- sb .append (" -n " );
277
- sb .append (operatorNS );
294
+ switch (restCertType ) {
295
+ case LEGACY :
296
+ sb .append (
297
+ "/integration-tests/src/test/resources/scripts/legacy-generate-external-rest-identity.sh " );
298
+ break ;
299
+ case CHAIN :
300
+ sb .append (
301
+ "/integration-tests/src/test/resources/scripts/generate-external-rest-identity-chain.sh " );
302
+ sb .append (" -n " );
303
+ sb .append (operatorNS );
304
+ break ;
305
+ case SELF_SIGNED :
306
+ sb .append ("/kubernetes/samples/scripts/rest/generate-external-rest-identity.sh " );
307
+ sb .append (" -n " );
308
+ sb .append (operatorNS );
309
+ break ;
278
310
}
279
311
sb .append (" DNS:" );
280
312
sb .append (TestUtils .getHostName ());
@@ -395,4 +427,16 @@ private void initialize(String yamlFile) throws Exception {
395
427
operatorNS );
396
428
}
397
429
}
430
+
431
+ public String getOperatorNamespace () {
432
+ return operatorNS ;
433
+ }
434
+
435
+ public String getUserProjectsDir () {
436
+ return userProjectsDir ;
437
+ }
438
+
439
+ public RESTCertType getRestCertType () {
440
+ return restCertType ;
441
+ }
398
442
}
0 commit comments