Skip to content

Commit 1ee961e

Browse files
committed
Merge branch 'alias-test-fixes' into 'main'
Include secure_default null values in alias test generated files See merge request weblogic-cloud/weblogic-deploy-tooling!1810
2 parents 5d406f6 + 39507c5 commit 1ee961e

File tree

4 files changed

+70
-14
lines changed

4 files changed

+70
-14
lines changed

integration-tests/alias-test/generate/src/test/python/aliastest/generate/generator_base.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
"""
2-
Copyright (c) 2021, 2023, Oracle and/or its affiliates.
2+
Copyright (c) 2021, 2025, Oracle and/or its affiliates.
33
Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl.
44
"""
55
import types
@@ -105,14 +105,16 @@ def add_computed_defaults(self, dictionary, cmo_helper, attribute_name):
105105
if computed_value is not None: # None means no attribute info was found
106106
dictionary[COMPUTED_DEFAULT] = computed_value
107107

108-
production_default_value = cmo_helper.production_default_value()
109-
if production_default_value is not None:
108+
# we want to include null values
109+
if cmo_helper.has_production_default():
110+
production_default_value = cmo_helper.production_default_value()
110111
dictionary[PRODUCTION_DEFAULT] = self.convert_attribute(attribute_name, production_default_value,
111112
value_type=dictionary[GET_TYPE])
112113

114+
# we want to include null values
113115
if self._model_context.get_local_wls_version() not in SECURE_DEFAULT_DISMISS:
114-
secure_default_value = cmo_helper.secure_default_value()
115-
if secure_default_value is not None:
116+
if cmo_helper.has_secure_default():
117+
secure_default_value = cmo_helper.secure_default_value()
116118
dictionary[SECURE_DEFAULT] = self.convert_attribute(attribute_name, secure_default_value,
117119
value_type=dictionary[GET_TYPE])
118120

integration-tests/alias-test/generate/src/test/python/aliastest/generate/mbean_info_helper.py

Lines changed: 27 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
"""
2-
Copyright (c) 2020, 2022, Oracle Corporation and/or its affiliates.
2+
Copyright (c) 2020, 2025, Oracle and/or its affiliates.
33
Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl.
44
"""
55

@@ -24,14 +24,25 @@
2424

2525
class MBeanInfoHelper(object):
2626
"""
27-
Facade to provide the details for a specific WLST MBean and its attributes / child MBeans.
28-
The information provided in this class is retrieved from the MBeanInfo descriptors for the MBean
29-
encapsulated in an instance.
27+
Wrapper for an MBean proxy object that derives MBean, child MBean, and attribute information
28+
using the MBean's BeanInfo descriptors.
29+
30+
interfaces = self.__mbean_instance.getClass().getInterfaces()
31+
mbean_interface = interfaces[0]
32+
bean_access = ManagementServiceClient.getBeanInfoAccess() // weblogic.management.provider.beaninfo.BeanInfoAccess
33+
getname = getattr(mbean_interface, 'getTypeName')
34+
type_name = getname()
35+
self.__mbean_info = bean_access.getBeanInfoForInterface(type_name, False, '9.0.0.0')
36+
// subclass of java.beans.BeanInfo, weblogic.management.configuration.*MBeanImplBeanInfo
3037
"""
31-
3238
__logger = PlatformLogger('test.aliases.generate.mbean.info')
3339

3440
def __init__(self, mbean_instance, mbean_path, mbean_type=None):
41+
"""
42+
:param mbean_instance: an MBean proxy object, if None it is looked up from mbean_path
43+
:param mbean_path: the MBean path
44+
:param mbean_type: never passed in ?, derived from MBean descriptor name
45+
"""
3546
self.__class_name__ = self.__class__.__name__
3647
self.__mbean_path = mbean_path
3748
self.__mbean_instance = self.__encapsulate_mbean_instance(mbean_instance=mbean_instance, mbean_path=mbean_path)
@@ -366,13 +377,23 @@ def computed_default_value(self):
366377
value = False
367378
return value
368379

380+
# allow for null secure default values
381+
def has_secure_default(self):
382+
return (self.__exists and
383+
('secureValue' in self.__get_descriptor_values_keys()
384+
or 'secureValueNull' in self.__get_descriptor_values_keys())
385+
and 'secureValueDocOnly' not in self.__get_descriptor_values_keys())
386+
369387
def secure_default_value(self):
370388
value = None
371389
doc_only = self.__get_descriptor_value('secureValueDocOnly')
372-
if not doc_only:
390+
if not doc_only and self.__get_descriptor_value('secureValueNull') is not True:
373391
value = self.__get_descriptor_value('secureValue')
374392
return value
375393

394+
def has_production_default(self):
395+
return self.__exists and 'restProductionModeDefault' in self.__get_descriptor_values_keys()
396+
376397
def production_default_value(self):
377398
return self.__get_descriptor_value('restProductionModeDefault')
378399

integration-tests/alias-test/generate/src/test/python/aliastest/generate/mbean_method_helper.py

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
"""
2-
Copyright (c) 2020, 2022, Oracle Corporation and/or its affiliates.
2+
Copyright (c) 2020, 2025, Oracle and/or its affiliates.
33
Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl.
44
"""
55

@@ -21,10 +21,21 @@
2121

2222

2323
class MBeanMethodHelper(object):
24+
"""
25+
Wrapper for an MBean proxy object that derives MBean, child MBean, and attribute information
26+
using Java reflection.
27+
Attributes and child MBeans are derived from methods of the proxy object.
2428
29+
self.__mbean_info is a map of attribute_names to getter methods
30+
"""
2531
__logger = PlatformLogger('test.aliases.generate.mbean.method')
2632

2733
def __init__(self, mbean_instance, mbean_path, mbean_type=None):
34+
"""
35+
:param mbean_instance: an MBean proxy object, if None it is looked up from mbean_path
36+
:param mbean_path: the MBean path
37+
:param mbean_type: never passed in ?, derived from interface name
38+
"""
2839
self.__class_name__ = self.__class__.__name__
2940
self.__mbean_path = mbean_path
3041
self.__mbean_instance = self.__encapsulate_mbean_instance(mbean_instance=mbean_instance, mbean_path=mbean_path)
@@ -299,9 +310,15 @@ def derived_default_value(self):
299310
def computed_default_value(self):
300311
return None
301312

313+
def has_secure_default(self):
314+
return False
315+
302316
def secure_default_value(self):
303317
return None
304318

319+
def has_production_default(self):
320+
return False
321+
305322
def production_default_value(self):
306323
return None
307324

integration-tests/alias-test/generate/src/test/python/aliastest/generate/mbi_helper.py

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
"""
2-
Copyright (c) 2020, 2022, Oracle Corporation and/or its affiliates.
2+
Copyright (c) 2020, 2025, Oracle and/or its affiliates.
33
Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl.
44
"""
55

@@ -25,7 +25,13 @@
2525

2626

2727
class MBIHelper(object):
28+
"""
29+
Wrapper for an MBean proxy object that derives MBean, child MBean, and attribute information
30+
using WLST MBI information.
2831
32+
mbi_info = getMBI()
33+
self.__mbean_info = mbi_info.getMBeanDescriptor() // javax.management.modelmbean.ModelMBeanInfoSupport
34+
"""
2935
__logger = PlatformLogger('test.aliases.generate.mbean.mbi')
3036

3137
def __init__(self, mbean_instance, mbean_path, mbean_type=None):
@@ -300,13 +306,23 @@ def derived_default_value(self):
300306
def computed_default_value(self):
301307
return self.__get_descriptor_value('computed')
302308

309+
# allow for null secure default values
310+
def has_secure_default(self):
311+
return (self.__exists and
312+
('secureValue' in self.__get_descriptor_field_keys()
313+
or 'secureValueNull' in self.__get_descriptor_field_keys())
314+
and 'secureValueDocOnly' not in self.__get_descriptor_field_keys())
315+
303316
def secure_default_value(self):
304317
value = None
305318
doc_only = self.__get_descriptor_value('secureValueDocOnly')
306-
if not doc_only:
319+
if not doc_only and self.__get_descriptor_value('secureValueNull') is not True:
307320
value = self.__get_descriptor_value('secureValue')
308321
return value
309322

323+
def has_production_default(self):
324+
return self.__exists and 'restProductionModeDefault' in self.__get_descriptor_field_keys()
325+
310326
def production_default_value(self):
311327
return self.__get_descriptor_value('restProductionModeDefault')
312328

0 commit comments

Comments
 (0)