1717/** Operator class with all the utility methods for Operator. */
1818public class Operator {
1919
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+
2030 public static final String CREATE_OPERATOR_SCRIPT_MESSAGE =
2131 "The Oracle WebLogic Server Kubernetes Operator is deployed" ;
2232
@@ -36,6 +46,7 @@ public class Operator {
3646
3747 private static int maxIterationsOp = BaseTest .getMaxIterationsPod (); // 50 * 5 = 250 seconds
3848 private static int waitTimeOp = BaseTest .getWaitTimePod ();
49+ private static RESTCertType restCertType = RESTCertType .SELF_SIGNED ;
3950
4051 /**
4152 * Takes operator input properties which needs to be customized and generates a operator input
@@ -44,9 +55,10 @@ public class Operator {
4455 * @param inputYaml
4556 * @throws Exception
4657 */
47- public Operator (String inputYaml , boolean useLegacyRESTIdentity ) throws Exception {
58+ public Operator (String inputYaml , RESTCertType restCertType ) throws Exception {
59+ this .restCertType = restCertType ;
4860 initialize (inputYaml );
49- generateInputYaml (useLegacyRESTIdentity );
61+ generateInputYaml ();
5062 callHelmInstall ();
5163 }
5264
@@ -195,8 +207,7 @@ public void scale(String domainUid, String clusterName, int numOfMS) throws Exce
195207 .append (clusterName )
196208 .append ("/scale" );
197209
198- TestUtils .makeOperatorPostRestCall (
199- operatorNS , myOpRestApiUrl .toString (), myJsonObjStr , userProjectsDir );
210+ TestUtils .makeOperatorPostRestCall (this , myOpRestApiUrl .toString (), myJsonObjStr );
200211 // give sometime to complete
201212 logger .info ("Wait 30 sec for scaling to complete..." );
202213 Thread .sleep (30 * 1000 );
@@ -217,7 +228,23 @@ public void verifyDomainExists(String domainUid) throws Exception {
217228 .append (externalRestHttpsPort )
218229 .append ("/operator/latest/domains/" )
219230 .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 ());
221248 }
222249
223250 public Map <String , Object > getOperatorMap () {
@@ -258,23 +285,28 @@ private String getExecFailure(String cmd, ExecResult result) throws Exception {
258285 }
259286
260287 private void generateInputYaml () throws Exception {
261- generateInputYaml (false );
262- }
263-
264- private void generateInputYaml (boolean useLegacyRESTIdentity ) throws Exception {
265288 Path parentDir =
266289 Files .createDirectories (Paths .get (userProjectsDir + "/weblogic-operators/" + operatorNS ));
267290 generatedInputYamlFile = parentDir + "/weblogic-operator-values.yaml" ;
268291 TestUtils .createInputFile (operatorMap , generatedInputYamlFile );
269292 StringBuilder sb = new StringBuilder (200 );
270293 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 ;
278310 }
279311 sb .append (" DNS:" );
280312 sb .append (TestUtils .getHostName ());
@@ -395,4 +427,16 @@ private void initialize(String yamlFile) throws Exception {
395427 operatorNS );
396428 }
397429 }
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+ }
398442}
0 commit comments