Skip to content

Commit

Permalink
Adding EULA acceptance: Accepting boolean values in different formats
Browse files Browse the repository at this point in the history
  • Loading branch information
rane-rajasi committed Sep 14, 2023
1 parent dd4d23b commit 1c07157
Show file tree
Hide file tree
Showing 2 changed files with 121 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/core/src/core_logic/ExecutionConfig.py
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ def __is_eula_accepted_for_all_patches(self):
accept_eula_for_all_patches = self.__fetch_specific_eula_setting(eula_settings, Constants.EulaSettings.ACCEPT_EULA_FOR_ALL_PATCHES)
accepted_by = self.__fetch_specific_eula_setting(eula_settings, Constants.EulaSettings.ACCEPTED_BY)
last_modified = self.__fetch_specific_eula_setting(eula_settings, Constants.EulaSettings.LAST_MODIFIED)
if accept_eula_for_all_patches is not None and accept_eula_for_all_patches is True:
if accept_eula_for_all_patches is not None and accept_eula_for_all_patches in [True, 'True', 'true', '1', 1]:
is_eula_accepted = True
self.composite_logger.log_debug("EULA config values from disk: [AcceptEULAForAllPatches={0}] [AcceptedBy={1}] [LastModified={2}]. Computed value of [IsEULAAccepted={3}]"
.format(str(accept_eula_for_all_patches), str(accepted_by), str(last_modified), str(is_eula_accepted)))
Expand Down
120 changes: 120 additions & 0 deletions src/core/tests/Test_AptitudePackageManager.py
Original file line number Diff line number Diff line change
Expand Up @@ -621,6 +621,126 @@ def test_eula_acceptance_file_read_success(self):
self.assertEqual(execution_config.accept_package_eula, False)
runtime.stop()

# Accept EULA set to true in a string i.e. 'true'
eula_settings = {
"AcceptEULAForAllPatches": 'true',
"AcceptedBy": "TestSetup",
"LastModified": "2023-08-29"
}
f = open(Constants.AzGPSPaths.EULA_SETTINGS, "w+")
f.write(json.dumps(eula_settings))
f.close()
runtime = RuntimeCompositor(self.argument_composer, True, package_manager_name=Constants.APT)
container = runtime.container
execution_config = container.get('execution_config')
self.assertEqual(execution_config.accept_package_eula, True)
runtime.stop()

# Accept EULA set to true in a string i.e. 'True'
eula_settings = {
"AcceptEULAForAllPatches": 'True',
"AcceptedBy": "TestSetup",
"LastModified": "2023-08-29"
}
f = open(Constants.AzGPSPaths.EULA_SETTINGS, "w+")
f.write(json.dumps(eula_settings))
f.close()
runtime = RuntimeCompositor(self.argument_composer, True, package_manager_name=Constants.APT)
container = runtime.container
execution_config = container.get('execution_config')
self.assertEqual(execution_config.accept_package_eula, True)
runtime.stop()

# Accept EULA set to true in a string i.e. 'False'
eula_settings = {
"AcceptEULAForAllPatches": 'False',
"AcceptedBy": "TestSetup",
"LastModified": "2023-08-29"
}
f = open(Constants.AzGPSPaths.EULA_SETTINGS, "w+")
f.write(json.dumps(eula_settings))
f.close()
runtime = RuntimeCompositor(self.argument_composer, True, package_manager_name=Constants.APT)
container = runtime.container
execution_config = container.get('execution_config')
self.assertEqual(execution_config.accept_package_eula, False)
runtime.stop()

# Accept EULA set to true in a string i.e. 'false'
eula_settings = {
"AcceptEULAForAllPatches": 'false',
"AcceptedBy": "TestSetup",
"LastModified": "2023-08-29"
}
f = open(Constants.AzGPSPaths.EULA_SETTINGS, "w+")
f.write(json.dumps(eula_settings))
f.close()
runtime = RuntimeCompositor(self.argument_composer, True, package_manager_name=Constants.APT)
container = runtime.container
execution_config = container.get('execution_config')
self.assertEqual(execution_config.accept_package_eula, False)
runtime.stop()

# Accept EULA set as '0'
eula_settings = {
"AcceptEULAForAllPatches": '0',
"AcceptedBy": "TestSetup",
"LastModified": "2023-08-29"
}
f = open(Constants.AzGPSPaths.EULA_SETTINGS, "w+")
f.write(json.dumps(eula_settings))
f.close()
runtime = RuntimeCompositor(self.argument_composer, True, package_manager_name=Constants.APT)
container = runtime.container
execution_config = container.get('execution_config')
self.assertEqual(execution_config.accept_package_eula, False)
runtime.stop()

# Accept EULA set as 0
eula_settings = {
"AcceptEULAForAllPatches": 0,
"AcceptedBy": "TestSetup",
"LastModified": "2023-08-29"
}
f = open(Constants.AzGPSPaths.EULA_SETTINGS, "w+")
f.write(json.dumps(eula_settings))
f.close()
runtime = RuntimeCompositor(self.argument_composer, True, package_manager_name=Constants.APT)
container = runtime.container
execution_config = container.get('execution_config')
self.assertEqual(execution_config.accept_package_eula, False)
runtime.stop()

# Accept EULA set as 1
eula_settings = {
"AcceptEULAForAllPatches": 1,
"AcceptedBy": "TestSetup",
"LastModified": "2023-08-29"
}
f = open(Constants.AzGPSPaths.EULA_SETTINGS, "w+")
f.write(json.dumps(eula_settings))
f.close()
runtime = RuntimeCompositor(self.argument_composer, True, package_manager_name=Constants.APT)
container = runtime.container
execution_config = container.get('execution_config')
self.assertEqual(execution_config.accept_package_eula, True)
runtime.stop()

# Accept EULA set as '1'
eula_settings = {
"AcceptEULAForAllPatches": '1',
"AcceptedBy": "TestSetup",
"LastModified": "2023-08-29"
}
f = open(Constants.AzGPSPaths.EULA_SETTINGS, "w+")
f.write(json.dumps(eula_settings))
f.close()
runtime = RuntimeCompositor(self.argument_composer, True, package_manager_name=Constants.APT)
container = runtime.container
execution_config = container.get('execution_config')
self.assertEqual(execution_config.accept_package_eula, True)
runtime.stop()

def test_eula_acceptance_file_read_when_no_data_found(self):
self.runtime.stop()

Expand Down

0 comments on commit 1c07157

Please sign in to comment.