Skip to content

Commit 9a11b41

Browse files
authored
OWLS-93783: WLSVERSIONEARLIERTHAN METHOD IS MISSING IN 3.3.3 (#2616)
* Add wlsVersionEarlierThan method back for MII * Add additional unit test to verify validity of wlsVersionEarlierThan method
1 parent 2515fb0 commit 9a11b41

File tree

2 files changed

+60
-0
lines changed

2 files changed

+60
-0
lines changed

operator/src/main/resources/scripts/model_wdt_mii_filter.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,13 @@ def toDNS1123Legal(self, address):
139139
def getModel(self):
140140
return self.model
141141

142+
def wlsVersionEarlierThan(self, version):
143+
# unconventional import within function definition for unit testing
144+
from weblogic.management.configuration import LegalHelper
145+
# WLS Domain versions supported by operator are 12.2.1.3 + patches, 12.2.1.4
146+
# and 14.1.1.0 so current version will only be one of these that are listed.
147+
return LegalHelper.versionEarlierThan("14.1.1.0", version)
148+
142149
class SecretManager(object):
143150

144151
def __init__(self, env):

operator/src/test/python/test_wdt_mii_filter.py

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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+
374424
class 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+
391444
if __name__ == '__main__':
392445
unittest.main()

0 commit comments

Comments
 (0)