Skip to content

Commit 582ae35

Browse files
Wdt alias test branch (#927)
* Add alias test foundation * Fix verify issues * run verify without WLST * remove WLST references from verify * Run verify without Weblogic home * further script changes * running under docker * Alias test in jenkinsfile * Jenkinsfile change * aliastest jenkins changes * Change to Jenkinsfile for user * add more versions to jenkinsfile * work on archiving testfiles * add final versions * archive generated files * when on master trigger * add generated files zip * remove archive of generated files * Update pom.xml * Copy jenkinsfile from master to aliast test branch * remove archive from resources * rename systemtest entities * Try different run trigger * reset jenkinfile trigger * intermediate changes for security configuration * offline generate security providers * between verify code changes * working on online generator * online generate security providers * hold code in progress * Add security providers to alias test * Add security providers to alias test * merge jenkinsfiles * update copyright on updated files * update copyright on updated files
1 parent 859da00 commit 582ae35

20 files changed

+933
-52
lines changed

Jenkinsfile

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,6 @@ pipeline {
7878
stage ('Alias Test') {
7979
// only run this stage when triggered by a cron timer and the commit does not have []skip-ci in the message
8080
// for example, only run integration tests during the timer triggered nightly build
81-
8281
when {
8382
allOf {
8483
triggeredBy 'TimerTrigger'

alias-test/src/test/python/aliastest/generate/generator_helper.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
"""
2-
Copyright (c) 2020, Oracle Corporation and/or its affiliates.
2+
Copyright (c) 2021, Oracle Corporation 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

alias-test/src/test/python/aliastest/generate/generator_offline.py

Lines changed: 33 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
"""
2-
Copyright (c) 2020, Oracle Corporation and/or its affiliates.
2+
Copyright (c) 2021, Oracle Corporation 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

@@ -13,6 +13,7 @@
1313

1414
import aliastest.util.all_utils as all_utils
1515
import aliastest.generate.generator_wlst as generator_wlst
16+
import aliastest.generate.generator_security_configuration as generator_security_configuration
1617
from aliastest.generate.generator_helper import GeneratorHelper
1718
from aliastest.generate.mbean_info_helper import MBeanInfoHelper
1819
from aliastest.generate.mbean_method_helper import MBeanMethodHelper
@@ -48,7 +49,9 @@ def generate(self):
4849
_method_name = 'generate'
4950
self.__logger.entering(class_name=self.__class_name__, method_name=_method_name)
5051
offline_dictionary = all_utils.dict_obj()
51-
generator_wlst.read_domain(self._helper.domain_home())
52+
isRead = generator_wlst.read_domain(self._helper.domain_home())
53+
if not isRead:
54+
return
5255
top_mbean_path = '/'
5356
self.__folder_hierarchy(offline_dictionary, self.__online_dictionary, top_mbean_path)
5457
for mbean_type, mbean_type_map in OFFLINE_ONLY_FOLDERS_MAP.items():
@@ -102,8 +105,14 @@ def __folder_hierarchy(self, mbean_dictionary, online_dictionary, mbean_path, pa
102105
class_name=self.__class_name__, method_name=_method_name)
103106

104107
if self._is_valid_folder(mbean_helper):
105-
success, lsc_name, attributes = \
106-
self.__generate_folder(mbean_instance, parent_mbean_type, mbean_type, mbean_helper)
108+
if mbean_type in generator_security_configuration.PROVIDERS:
109+
print 'Found security provider folder ', mbean_type
110+
success, lsc_name, attributes = self.create_security_type(mbean_type)
111+
mbean_dictionary[lsc_name] = attributes
112+
continue
113+
else:
114+
success, lsc_name, attributes = \
115+
self.__generate_folder(mbean_instance, parent_mbean_type, mbean_type, mbean_helper)
107116
mbean_dictionary[lsc_name] = attributes
108117
if success:
109118
next_online_dictionary = dict()
@@ -388,6 +397,26 @@ def __get_attributes_offline_only(self, mbean_instance):
388397
self.__logger.exiting(class_name=self.__class_name__, method_name=_method_name)
389398
return all_utils.sort_dict(attribute_map)
390399

400+
def create_security_type(self, mbean_type):
401+
folder_dict = all_utils.dict_obj()
402+
folder_dict[all_utils.TYPE] = 'Provider'
403+
types = generator_security_configuration.providers_map[mbean_type]
404+
405+
singular = mbean_type
406+
if singular.endswith('s'):
407+
lenm = len(mbean_type)-1
408+
singular = mbean_type[0:lenm]
409+
for item in types:
410+
idx = item.rfind('.')
411+
short = item[idx + 1:]
412+
package = short
413+
mbean_instance = generator_wlst.created_security_provider(singular, short, package)
414+
orig = generator_wlst.current_path()
415+
folder_dict[short] = all_utils.dict_obj()
416+
folder_dict[short][all_utils.ATTRIBUTES] = self.__get_attributes(mbean_instance)
417+
generator_wlst.cd_mbean(orig)
418+
return True, singular, folder_dict
419+
391420
def _slim_maps_for_report(self, mbean_proxy, mbean_type, lsa_map, methods_map, mbean_info_map):
392421
# Unlike the slim_maps method, this report discards additional information to determine how
393422
# different is the usable information in LSA, versus cmo.getClass().getMethods versus

alias-test/src/test/python/aliastest/generate/generator_online.py

Lines changed: 50 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
"""
2-
Copyright (c) 2020, Oracle Corporation and/or its affiliates.
2+
Copyright (c) 2021, Oracle Corporation 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

@@ -8,6 +8,7 @@
88
from wlsdeploy.logging.platform_logger import PlatformLogger
99

1010
import aliastest.util.all_utils as all_utils
11+
import aliastest.generate.generator_security_configuration as generator_security_configuration
1112
import aliastest.generate.generator_wlst as generator_wlst
1213

1314
from aliastest.generate.generator_helper import GeneratorHelper
@@ -74,6 +75,8 @@ def __folder_hierarchy(self, mbean_dictionary, mbean_path):
7475
self.__logger.fine('Child MBean {0} is in the MBI information but not the MBeanInfo information',
7576
mbean_type, class_name=self.__class_name__, method_name=_method_name)
7677

78+
print 'mbean_type = ', mbean_type
79+
7780
if attribute_helper.is_reference_only():
7881
mbean_dictionary[mbean_type] = all_utils.dict_obj()
7982
# This non-attribute might have been added as a folder, which it is not
@@ -83,25 +86,29 @@ def __folder_hierarchy(self, mbean_dictionary, mbean_path):
8386
if self._is_valid_folder(attribute_helper):
8487
self.__logger.fine('WLSDPLYST-01115', mbean_type, generator_wlst.current_path(),
8588
class_name=self.__class_name__, method_name=_method_name)
89+
8690
mbean_dictionary[mbean_type] = all_utils.dict_obj()
87-
attribute_helper.generate_mbean(mbean_dictionary[mbean_type])
88-
if mbean_name is None:
89-
mbean_name = generator_wlst.get_singleton_name(mbean_type)
90-
if mbean_name is not None:
91-
if mbean_type in generator_wlst.child_mbean_types():
92-
mbean_dictionary[mbean_type][all_utils.INSTANCE_TYPE] = all_utils.MULTIPLE
93-
else:
94-
mbean_dictionary[mbean_type][all_utils.INSTANCE_TYPE] = all_utils.SINGLE
95-
bean_dir = mbean_type + '/' + mbean_name
96-
if not generator_wlst.cd_mbean(bean_dir):
97-
self.__logger.fine('WLSDPLYST-01117', mbean_type, generator_wlst.current_path(), '',
98-
class_name=self.__class_name__, method_name=_method_name)
99-
mbean_dictionary[mbean_type][all_utils.RECHECK] = \
100-
'cd to mbean and mbean name returned exception'
101-
continue
102-
103-
self.__folder_hierarchy(mbean_dictionary[mbean_type], generator_wlst.current_path())
104-
generator_wlst.cd_mbean('../..')
91+
if mbean_type in generator_security_configuration.PROVIDERS:
92+
self.generate_security_mbean(mbean_dictionary, mbean_type)
93+
else:
94+
attribute_helper.generate_mbean(mbean_dictionary[mbean_type])
95+
if mbean_name is None:
96+
mbean_name = generator_wlst.get_singleton_name(mbean_type)
97+
if mbean_name is not None:
98+
if mbean_type in generator_wlst.child_mbean_types():
99+
mbean_dictionary[mbean_type][all_utils.INSTANCE_TYPE] = all_utils.MULTIPLE
100+
else:
101+
mbean_dictionary[mbean_type][all_utils.INSTANCE_TYPE] = all_utils.SINGLE
102+
bean_dir = mbean_type + '/' + mbean_name
103+
if not generator_wlst.cd_mbean(bean_dir):
104+
self.__logger.fine('WLSDPLYST-01117', mbean_type, generator_wlst.current_path(), '',
105+
class_name=self.__class_name__, method_name=_method_name)
106+
mbean_dictionary[mbean_type][all_utils.RECHECK] = \
107+
'cd to mbean and mbean name returned exception'
108+
continue
109+
110+
self.__folder_hierarchy(mbean_dictionary[mbean_type], generator_wlst.current_path())
111+
generator_wlst.cd_mbean('../..')
105112
else:
106113
# make this a real message
107114
self.__logger.warning('Ignore invalid MBean folder {0} containment : {1}, deprecated : {2}',
@@ -298,3 +305,27 @@ def __create_any_subfolders(self):
298305
subfolder_list[child_type] = name_list[0]
299306

300307
return subfolder_list
308+
309+
def generate_security_mbean(self, dictionary, mbean_type):
310+
dictionary[mbean_type][all_utils.TYPE] = 'Provider'
311+
types = generator_security_configuration.providers_map[mbean_type]
312+
curr_path = generator_wlst.current_path()
313+
generator_wlst.cd_mbean(curr_path + '/' + mbean_type)
314+
existing = generator_wlst.lsc()
315+
generator_wlst.cd_mbean(curr_path)
316+
for item in types:
317+
idx = item.rfind('.')
318+
short = item[idx + 1:]
319+
orig = generator_wlst.current_path()
320+
if short not in existing:
321+
mbean_instance = generator_wlst.created_security_provider(mbean_type, short, item)
322+
generator_wlst.cd_mbean(curr_path + '/' + mbean_type + '/' + short)
323+
else:
324+
mbean_instance = generator_wlst.get_mbean_proxy(curr_path + '/' + mbean_type + '/' + short)
325+
dictionary[mbean_type][item] = all_utils.dict_obj()
326+
dictionary[mbean_type][item][all_utils.ATTRIBUTES] = self.__get_attributes(mbean_instance)
327+
generator_wlst.cd_mbean(orig)
328+
generator_wlst.cd_mbean(curr_path)
329+
330+
331+
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
"""
2+
Copyright (c) 2021, Oracle Corporation and/or its affiliates.
3+
Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl.
4+
"""
5+
6+
import aliastest.generate.generator_wlst as generator_wlst
7+
8+
import oracle.weblogic.deploy.aliases.TypeUtils as TypeUtils
9+
10+
TYPES = 'Types'
11+
ADJUDICATOR_TYPES = 'AdjudicatorTypes'
12+
ADJUDICATOR_STRING = 'Adjudicator'
13+
AUDITOR_TYPES = 'AuditorTypes'
14+
AUDITOR_STRING = 'Auditors'
15+
AUTHENTICATION_PROVIDER_TYPES = 'AuthenticationProviderTypes'
16+
AUTHENTICATION_PROVIDER_STRING = 'AuthenticationProviders'
17+
AUTHORIZER_TYPES = 'AuthorizerTypes'
18+
AUTHORIZER_STRING = 'Authorizers'
19+
CERTPATH_PROVIDER_TYPES = 'CertPathProviderTypes'
20+
CERTPATH_PROVIDER_STRING = 'CertPathProviders'
21+
CREDENTIAL_MAPPER_TYPES = 'CredentialMapperTypes'
22+
CREDENTIAL_MAPPER_STRING = 'CredentialMappers'
23+
PASSWORD_VALIDATOR_TYPES = 'PasswordValidatorTypes'
24+
PASSWORD_VALIDATOR_STRING = 'PasswordValidators'
25+
ROLE_MAPPER_TYPES = 'RoleMapperTypes'
26+
ROLE_MAPPER_STRING = 'RoleMappers'
27+
28+
PROVIDERS = [ADJUDICATOR_STRING, AUDITOR_STRING, AUTHENTICATION_PROVIDER_STRING, AUTHORIZER_STRING,
29+
CERTPATH_PROVIDER_STRING, CREDENTIAL_MAPPER_STRING, PASSWORD_VALIDATOR_STRING, ROLE_MAPPER_STRING]
30+
31+
providers_map = None
32+
33+
34+
def populate_security_types():
35+
generator_wlst.connect('weblogic', 'welcome1', 't3://localhost:7001')
36+
cd_security_configuration()
37+
provider_map = dict()
38+
provider_map[ADJUDICATOR_STRING] = get_jarray(ADJUDICATOR_TYPES)
39+
provider_map[AUDITOR_STRING] = get_jarray(AUDITOR_TYPES)
40+
provider_map[AUTHENTICATION_PROVIDER_STRING] = get_jarray(AUTHENTICATION_PROVIDER_TYPES)
41+
provider_map[AUTHORIZER_STRING] = get_jarray(AUTHORIZER_TYPES)
42+
provider_map[CERTPATH_PROVIDER_STRING] = get_jarray(CERTPATH_PROVIDER_TYPES)
43+
provider_map[CREDENTIAL_MAPPER_STRING] = get_jarray(CREDENTIAL_MAPPER_TYPES)
44+
provider_map[PASSWORD_VALIDATOR_STRING] = get_jarray(PASSWORD_VALIDATOR_TYPES)
45+
provider_map[ROLE_MAPPER_STRING] = get_jarray(ROLE_MAPPER_TYPES)
46+
return provider_map
47+
48+
49+
def get_jarray(name):
50+
plist = generator_wlst.get(name)
51+
if plist is None or len(plist) == 0:
52+
return []
53+
result = TypeUtils.convertToObjectArray(plist[1], str(plist), ',')
54+
provider = []
55+
for item in result:
56+
provider.append(item)
57+
return provider
58+
59+
60+
def cd_security_configuration():
61+
generator_wlst.cd_mbean('/SecurityConfiguration')
62+
generator_wlst.cd_mbean('system_test_domain')
63+
generator_wlst.cd_mbean('Realms')
64+
generator_wlst.cd_mbean('myrealm')
65+
66+
67+
def get_last_node(package):
68+
result = package
69+
idx = package.rfind('.')
70+
if idx > 0:
71+
result = package[idx+1:]
72+
return result

alias-test/src/test/python/aliastest/generate/generator_wlst.py

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
"""
2-
Copyright (c) 2020, Oracle Corporation and/or its affiliates.
2+
Copyright (c) 2021, Oracle Corporation 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 java.lang.Boolean as Boolean
@@ -149,7 +149,7 @@ def get_mbean_proxy(path=None):
149149
local_cmo = _load_global('cmo')
150150
mbean_proxy = local_cmo
151151
if mbean_proxy is None:
152-
update_cmo = _load_global('upateCmo')
152+
update_cmo = _load_global('updateCmo')
153153
update_cmo()
154154
local_cmo = _load_global('cmo')
155155
mbean_proxy = local_cmo
@@ -242,6 +242,28 @@ def created(mbean_type, name):
242242
return True
243243

244244

245+
def created_security_provider(mbean_type, name, package):
246+
"""
247+
Create the MBean with the provided name at the current wlst location. WLST Exceptions are caught and returned
248+
as False from the method.
249+
:param mbean_type: MBean type to create
250+
:param name: Name of the MBean to create
251+
:param package: package name of the security provider to create
252+
:return: True if successfully created
253+
"""
254+
_method_name = 'created'
255+
online_wlst_exception = _load_global('WLSTException')
256+
result = None
257+
try:
258+
local_create = _load_global('create')
259+
result = local_create(name, package, mbean_type)
260+
except (online_wlst_exception, offlineWLSTException, ClassCastException, NoSuchMethodException), e:
261+
__logger.fine('Unable to create MBean {0} with name {1} and provider name {2} at location {3} : {4}',
262+
mbean_type, name, package, current_path(), str(e),
263+
class_name=__class_name, method_name=_method_name)
264+
return result
265+
266+
245267
def cd_proxy(bean_dir):
246268
_method_name = 'cd_proxy'
247269
__logger.entering(bean_dir, class_name=__class_name, method_name=_method_name)
@@ -261,10 +283,9 @@ def cd_mbean(bean_dir):
261283
_method_name = 'cd_mbean'
262284
__logger.entering(bean_dir, class_name=__class_name, method_name=_method_name)
263285
online_wlst_exception = _load_global('WLSTException')
264-
local_cd = _load_global('cd')
265286
success = True
266287
try:
267-
local_cd(bean_dir)
288+
_load_global('cd')(bean_dir)
268289
except (online_wlst_exception, offlineWLSTException), we:
269290
__logger.warning('WLSDPLYST-01340', bean_dir, current_path(), we.getLocalizedMessage(),
270291
class_name=__class_name, method_name=_method_name)

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ def __get_mbean_info(self):
139139
type_name = all_utils.get_interface_name(mbean_interface)
140140
self.__mbean_info = bean_access.getBeanInfoForInterface(type_name, False, '9.0.0.0')
141141
if _info_is_not_empty(self.__mbean_info) is False:
142-
self.__logger.info('Unable to locate MBeanInfo for MBean interface {0}', type_name,
142+
self.__logger.info('Unable to locate MBeanInfo for MBean interface {0}', mbean_interface,
143143
class_name=self.__class_name__, method_name=_method_name)
144144
self.__logger.exiting(class_name=self.__class_name__, method_name=_method_name,
145145
result=str(self.__mbean_info))

alias-test/src/test/python/aliastest/util/all_utils.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,6 @@ def get_dictionary_from_json_file(json_file_name):
122122
"""
123123
_method_name = 'get_dictionary_from_json_file'
124124
__logger.entering(json_file_name, class_name=CLASS_NAME, method_name=_method_name)
125-
print 'THE FILE NAME IS ', json_file_name
126125
json_input_stream = FileInputStream(File(json_file_name))
127126
json_translator = JsonStreamTranslator(json_file_name, json_input_stream)
128127
dictionary = None
@@ -432,7 +431,6 @@ def set_domain_home_arg(arg_map, domain_home):
432431
__logger.info("domain home arg {0}", arg_map[CommandLineArgUtil.DOMAIN_HOME_SWITCH],
433432
class_name=CLASS_NAME, method_name='set_domain_home_arg')
434433
set_arg(arg_map, CommandLineArgUtil.DOMAIN_HOME_SWITCH, domain_home)
435-
print '********************************** domain home ', domain_home
436434

437435

438436
def set_arg(arg_map, key, value):

alias-test/src/test/python/aliastest/util/helper.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
"""
2-
Copyright (c) 2020, Oracle Corporation and/or its affiliates.
2+
Copyright (c) 2020, 2021, Oracle Corporation 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 java.util.logging.Level as Level
@@ -121,7 +121,6 @@ def get_folder_map(self, model_folder_list, base_location):
121121
location.append_location(name)
122122
self.__logger.finer('Checking the folder {0} for flattened and type', location.get_folder_path())
123123
flattened_info = None
124-
print '******* ', location.get_folder_path()
125124
if not location.get_folder_path().startswith('/NMProperties') and not location.get_folder_path() == '/':
126125
flattened_info = self.__aliases.get_wlst_flattened_folder_info(location)
127126
if flattened_info is not None:

0 commit comments

Comments
 (0)