def test_auth_su_notification_edit(self): """ Test that SUPERADMINS can edit the notification text. """ # Create a SUPERUSER login. self.sessionToken = self.auth_client.performLogin("Username:Password", "root:root") ret = self.auth_client.addPermission(Permission.SUPERUSER, "root", False, "") self.assertTrue(ret) # we got the permission su_auth_client = \ env.setup_auth_client(self._test_workspace, session_token=self.sessionToken) su_config_client = \ env.setup_config_client(self._test_workspace, session_token=self.sessionToken) user = su_auth_client.getLoggedInUser() self.assertEqual(user, "root") # we are root su_config_client.setNotificationBannerText( base64.b64encode('su notification')) self.assertEqual(base64.b64decode( su_config_client.getNotificationBannerText()), 'su notification')
def setUp(self): """ Setup Configuration for tests. """ # TEST_WORKSPACE is automatically set by test package __init__.py . self._test_workspace = os.environ['TEST_WORKSPACE'] test_class = self.__class__.__name__ print('Running ' + test_class + ' tests in ' + self._test_workspace) # Setup a viewer client to test viewer API calls. self._cc_client = env.setup_viewer_client(self._test_workspace) self.assertIsNotNone(self._cc_client) self.auth_client = env.setup_auth_client(self._test_workspace, session_token='_PROHIBIT') self.config_client = env.setup_config_client(self._test_workspace, session_token='_PROHIBIT')
def test_auth_non_su_notification_edit(self): """ Test that non SUPERADMINS can't edit the notification text. """ self.sessionToken = self.auth_client.performLogin("Username:Password", "cc:test") authd_auth_client = \ env.setup_auth_client(self._test_workspace, session_token=self.sessionToken) authd_config_client = \ env.setup_config_client(self._test_workspace, session_token=self.sessionToken) user = authd_auth_client.getLoggedInUser() self.assertEqual(user, "cc") with self.assertRaises(RequestFailed): authd_config_client.setNotificationBannerText( base64.b64encode('non su notification')) print("You are not authorized to modify notifications!")