Ejemplo n.º 1
0
 def test_to_from_json(self, key_template_name, supported_langs):
     key_template = supported_key_types.KEY_TEMPLATE[key_template_name]
     keyset = testing_servers.new_keyset('java', key_template)
     for to_lang in supported_langs:
         json_keyset = testing_servers.keyset_to_json(to_lang, keyset)
         for from_lang in supported_langs:
             keyset2 = testing_servers.keyset_from_json(
                 from_lang, json_keyset)
             self.assertEqualKeyset(keyset, keyset2)
Ejemplo n.º 2
0
 def test_to_from_json(self, key_template_name, supported_langs):
     self.assertNotEmpty(supported_langs)
     key_template = supported_key_types.KEY_TEMPLATE[key_template_name]
     # Take the first supported language to generate the keyset.
     keyset = testing_servers.new_keyset(supported_langs[0], key_template)
     for to_lang in supported_langs:
         json_keyset = testing_servers.keyset_to_json(to_lang, keyset)
         for from_lang in supported_langs:
             keyset2 = testing_servers.keyset_from_json(
                 from_lang, json_keyset)
             self.assertEqualKeyset(keyset, keyset2)
Ejemplo n.º 3
0
 def test_to_from_json(self, keyset_text_proto):
     keyset_proto = text_format.Parse(keyset_text_proto, tink_pb2.Keyset())
     keyset = keyset_proto.SerializeToString()
     for to_lang in testing_servers.LANGUAGES:
         json_keyset = testing_servers.keyset_to_json(to_lang, keyset)
         for from_lang in testing_servers.LANGUAGES:
             keyset_from_json = testing_servers.keyset_from_json(
                 from_lang, json_keyset)
             key_util.assert_tink_proto_equal(
                 self,
                 tink_pb2.Keyset.FromString(keyset),
                 tink_pb2.Keyset.FromString(keyset_from_json),
                 msg=('keysets are not equal when converting to JSON in '
                      '%s and back in %s' % (to_lang, from_lang)))
Ejemplo n.º 4
0
 def test_to_from_json(self, key_template_name):
     supported_langs = supported_key_types.SUPPORTED_LANGUAGES_BY_TEMPLATE_NAME[
         key_template_name]
     self.assertNotEmpty(supported_langs)
     key_template = supported_key_types.KEY_TEMPLATE[key_template_name]
     # Take the first supported language to generate the keyset.
     keyset = testing_servers.new_keyset(supported_langs[0], key_template)
     for to_lang in supported_langs:
         json_keyset = testing_servers.keyset_to_json(to_lang, keyset)
         for from_lang in supported_langs:
             keyset2 = testing_servers.keyset_from_json(
                 from_lang, json_keyset)
             key_util.assert_tink_proto_equal(
                 self,
                 tink_pb2.Keyset.FromString(keyset),
                 tink_pb2.Keyset.FromString(keyset2),
                 msg=('keysets are not equal when converting to JSON in '
                      '%s and back in %s' % (to_lang, from_lang)))