Skip to content

OWLS-93783: WLSVERSIONEARLIERTHAN METHOD IS MISSING IN 3.3.3 #2616

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Nov 9, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions operator/src/main/resources/scripts/model_wdt_mii_filter.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,13 @@ def toDNS1123Legal(self, address):
def getModel(self):
return self.model

def wlsVersionEarlierThan(self, version):
# unconventional import within function definition for unit testing
from weblogic.management.configuration import LegalHelper
# WLS Domain versions supported by operator are 12.2.1.3 + patches, 12.2.1.4
# and 14.1.1.0 so current version will only be one of these that are listed.
return LegalHelper.versionEarlierThan("14.1.1.0", version)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The code that was removed by PR #2582 checks against 14.1.2.0. Just want to make sure that changing from 14.1.2.0 to 14.1.1.0 here is intentional.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, it turns out from talking to Quang that secure mode will be enabled by default in 14.1.2.0 so had to change it. This is intentional.


class SecretManager(object):

def __init__(self, env):
Expand Down
53 changes: 53 additions & 0 deletions operator/src/test/python/test_wdt_mii_filter.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,18 @@ def getModel(self):

return model

def getModelWithoutMockEnv(self):
# Load model as dictionary
file = open(r'../resources/model.dynamic_cluster_dict.txt')
contents = file.read()
model = ast.literal_eval(contents)
file.close()

# Setup environment
model_wdt_mii_filter.initOfflineWlstEnv(model)

return model

def getStaticModel(self):
# Load model as dictionary
file = open(r'../resources/model.static_cluster_dict.txt')
Expand Down Expand Up @@ -371,6 +383,44 @@ def test_customizeIstioReplicationChannel_version_1_10(self):
del os.environ['ISTIO_ENABLED']
del os.environ['ISTIO_USE_LOCALHOST_BINDINGS']

def test_isSecureModeEnabledForDomain_secureModeEnabled(self):
model = self.getModel()
topology = model['topology']
if 'SecurityConfiguration' not in topology:
topology['SecurityConfiguration'] = {}

if 'SecureMode' not in topology['SecurityConfiguration']:
topology['SecurityConfiguration']['SecureMode'] = {}

topology['SecurityConfiguration']['SecureMode']['SecureModeEnabled'] = 'true'

isSecureModeEnabled = model_wdt_mii_filter.isSecureModeEnabledForDomain(topology)
self.assertTrue(isSecureModeEnabled, "Expected secure mode enabled for domain")

def test_isSecureModeEnabledForDomain_productionModeEnabled(self):
model = self.getModel()
topology = model['topology']

topology['ProductionModeEnabled'] = 'true'

isSecureModeEnabled = model_wdt_mii_filter.isSecureModeEnabledForDomain(topology)
self.assertTrue(isSecureModeEnabled, "Expected secure mode enabled for domain")

def test_isSecureModeEnabledForDomain_importLegalHelperError(self):
try:
model = self.getModelWithoutMockEnv()
topology = model['topology']

topology['ProductionModeEnabled'] = 'true'

isSecureModeEnabled = model_wdt_mii_filter.isSecureModeEnabledForDomain(topology)
self.fail("Expected import error for LegalHelper")
except ImportError, ie:
self.assertTrue(ie is not None)




class MockOfflineWlstEnv(model_wdt_mii_filter.OfflineWlstEnv):

WLS_CRED_USERNAME = 'weblogic'
Expand All @@ -388,5 +438,8 @@ def readFile(self, path):

return self.WLS_CRED_PASSWORD

def wlsVersionEarlierThan(self, version):
return False

if __name__ == '__main__':
unittest.main()