@@ -62,6 +62,18 @@ def getModel(self):
6262
6363 return model
6464
65+ def getModelWithoutMockEnv (self ):
66+ # Load model as dictionary
67+ file = open (r'../resources/model.dynamic_cluster_dict.txt' )
68+ contents = file .read ()
69+ model = ast .literal_eval (contents )
70+ file .close ()
71+
72+ # Setup environment
73+ model_wdt_mii_filter .initOfflineWlstEnv (model )
74+
75+ return model
76+
6577 def getStaticModel (self ):
6678 # Load model as dictionary
6779 file = open (r'../resources/model.static_cluster_dict.txt' )
@@ -371,6 +383,44 @@ def test_customizeIstioReplicationChannel_version_1_10(self):
371383 del os .environ ['ISTIO_ENABLED' ]
372384 del os .environ ['ISTIO_USE_LOCALHOST_BINDINGS' ]
373385
386+ def test_isSecureModeEnabledForDomain_secureModeEnabled (self ):
387+ model = self .getModel ()
388+ topology = model ['topology' ]
389+ if 'SecurityConfiguration' not in topology :
390+ topology ['SecurityConfiguration' ] = {}
391+
392+ if 'SecureMode' not in topology ['SecurityConfiguration' ]:
393+ topology ['SecurityConfiguration' ]['SecureMode' ] = {}
394+
395+ topology ['SecurityConfiguration' ]['SecureMode' ]['SecureModeEnabled' ] = 'true'
396+
397+ isSecureModeEnabled = model_wdt_mii_filter .isSecureModeEnabledForDomain (topology )
398+ self .assertTrue (isSecureModeEnabled , "Expected secure mode enabled for domain" )
399+
400+ def test_isSecureModeEnabledForDomain_productionModeEnabled (self ):
401+ model = self .getModel ()
402+ topology = model ['topology' ]
403+
404+ topology ['ProductionModeEnabled' ] = 'true'
405+
406+ isSecureModeEnabled = model_wdt_mii_filter .isSecureModeEnabledForDomain (topology )
407+ self .assertTrue (isSecureModeEnabled , "Expected secure mode enabled for domain" )
408+
409+ def test_isSecureModeEnabledForDomain_importLegalHelperError (self ):
410+ try :
411+ model = self .getModelWithoutMockEnv ()
412+ topology = model ['topology' ]
413+
414+ topology ['ProductionModeEnabled' ] = 'true'
415+
416+ isSecureModeEnabled = model_wdt_mii_filter .isSecureModeEnabledForDomain (topology )
417+ self .fail ("Expected import error for LegalHelper" )
418+ except ImportError , ie :
419+ self .assertTrue (ie is not None )
420+
421+
422+
423+
374424class MockOfflineWlstEnv (model_wdt_mii_filter .OfflineWlstEnv ):
375425
376426 WLS_CRED_USERNAME = 'weblogic'
@@ -388,5 +438,8 @@ def readFile(self, path):
388438
389439 return self .WLS_CRED_PASSWORD
390440
441+ def wlsVersionEarlierThan (self , version ):
442+ return False
443+
391444if __name__ == '__main__' :
392445 unittest .main ()
0 commit comments