def test_process_dictionary_against_whitelist_global_keys(self): test_dictionary = {u'_href': u'foo', u'_id': u'bar', u'_ns': u'baz'} test_dictionary_before = copy.deepcopy(test_dictionary) JSONController.process_dictionary_against_whitelist( test_dictionary, []) util.compare_dict(test_dictionary_before, test_dictionary)
def test_process_dictionary_against_whitelisty_global_and_local_keys(self): test_dictionary = { u'_href': u'foo', u'_id': u'bar', u'_ns': u'baz', u'qux': u'quux' } test_dictionary_before = copy.deepcopy(test_dictionary) JSONController.process_dictionary_against_whitelist(test_dictionary, [u'qux']) util.compare_dict(test_dictionary_before, test_dictionary)
def test_process_dictionary_against_whitelist_filter_key(self): test_dictionary = { u'_href': u'foo', u'_id': u'bar', u'_ns': u'baz', u'qux': u'quux' } target_result = copy.deepcopy(test_dictionary) target_result.pop(u'qux', None) JSONController.process_dictionary_against_whitelist(test_dictionary, []) util.compare_dict(target_result, test_dictionary)
def test_process_dictionary_against_whitelist_filter_key(self): test_dictionary = { u'_href': u'foo', u'_id': u'bar', u'_ns': u'baz', u'qux': u'quux' } target_result = copy.deepcopy(test_dictionary) target_result.pop(u'qux', None) JSONController.process_dictionary_against_whitelist( test_dictionary, []) util.compare_dict(target_result, test_dictionary)
def _process_users(users): """ Apply standard processing to a collection of users being returned to a client. Adds the object link and removes user password. @param users: collection of users @type users: list, tuple @return the same list that was passed in, just for convenience. The list itself is not modified- only its members are modified in-place. @rtype list of User instances """ for user in users: user.update(serialization.link.search_safe_link_obj(user['login'])) JSONController.process_dictionary_against_whitelist(user, USER_WHITELIST) return users
def _process_users(users): """ Apply standard processing to a collection of users being returned to a client. Adds the object link and removes user password. @param users: collection of users @type users: list, tuple @return the same list that was passed in, just for convenience. The list itself is not modified- only its members are modified in-place. @rtype list of User instances """ for user in users: user.update(serialization.link.search_safe_link_obj(user['login'])) JSONController.process_dictionary_against_whitelist( user, USER_WHITELIST) return users