mirror of
https://gitlab.gnome.org/GNOME/libsecret.git
synced 2025-03-11 19:46:38 +00:00
Fix introspection for secret_value_get() to return a uint8
This works around a crash in pygobject. https://bugzilla.gnome.org/show_bug.cgi?id=694448
This commit is contained in:
parent
9b3424a229
commit
ddd9bdd2e9
@ -151,13 +151,13 @@ secret_value_new_full (gchar *secret,
|
|||||||
/**
|
/**
|
||||||
* secret_value_get:
|
* secret_value_get:
|
||||||
* @value: the value
|
* @value: the value
|
||||||
* @length: (out): the length of the secret
|
* @length: the length of the secret
|
||||||
*
|
*
|
||||||
* Get the secret data in the #SecretValue. The value is not necessarily
|
* Get the secret data in the #SecretValue. The value is not necessarily
|
||||||
* null-terminated unless it was created with secret_value_new() or a
|
* null-terminated unless it was created with secret_value_new() or a
|
||||||
* null-terminated string was passed to secret_value_new_full().
|
* null-terminated string was passed to secret_value_new_full().
|
||||||
*
|
*
|
||||||
* Returns: (array length=length): the secret data
|
* Returns: (array length=length) (element-type guint8): the secret data
|
||||||
*/
|
*/
|
||||||
const gchar *
|
const gchar *
|
||||||
secret_value_get (SecretValue *value,
|
secret_value_get (SecretValue *value,
|
||||||
|
@ -14,22 +14,50 @@
|
|||||||
import unittest
|
import unittest
|
||||||
|
|
||||||
from gi.repository import MockService as Mock
|
from gi.repository import MockService as Mock
|
||||||
from gi.repository import SecretUnstable as Secret, GLib
|
from gi.repository import SecretUnstable, Secret, GLib
|
||||||
|
|
||||||
|
EXAMPLE_SCHEMA = Secret.Schema.new('org.mock.type.Store',
|
||||||
|
Secret.SchemaFlags.NONE,
|
||||||
|
{
|
||||||
|
'number': Secret.SchemaAttributeType.INTEGER,
|
||||||
|
'string': Secret.SchemaAttributeType.STRING,
|
||||||
|
'even': Secret.SchemaAttributeType.BOOLEAN,
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
attributes = {
|
||||||
|
'number': '8',
|
||||||
|
'string': 'eight',
|
||||||
|
'even': 'true'
|
||||||
|
}
|
||||||
|
|
||||||
class TestStore(unittest.TestCase):
|
class TestStore(unittest.TestCase):
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
Mock.start("mock-service-normal.py")
|
Mock.start("mock-service-normal.py")
|
||||||
|
|
||||||
def tearDown(self):
|
def tearDown(self):
|
||||||
Secret.Service.disconnect()
|
SecretUnstable.Service.disconnect()
|
||||||
Mock.stop()
|
Mock.stop()
|
||||||
|
|
||||||
def testSynchronous(self):
|
def testSynchronous(self):
|
||||||
service = Secret.Service.get_sync(Secret.ServiceFlags.NONE, None);
|
service = SecretUnstable.Service.get_sync(SecretUnstable.ServiceFlags.NONE, None);
|
||||||
path = service.read_alias_dbus_path_sync("default", None);
|
path = service.read_alias_dbus_path_sync("default", None);
|
||||||
|
|
||||||
# Just running this without error is good enough for us to test the unstable gir
|
# Just running this without error is good enough for us to test the unstable gir
|
||||||
self.assertNotEqual(path, None);
|
self.assertNotEqual(path, None);
|
||||||
|
|
||||||
|
def testValueGet(self):
|
||||||
|
Secret.password_store_sync(EXAMPLE_SCHEMA, attributes, Secret.COLLECTION_DEFAULT,
|
||||||
|
'the label', 'the password', None)
|
||||||
|
|
||||||
|
service = SecretUnstable.Service.get_sync(SecretUnstable.ServiceFlags.NONE, None)
|
||||||
|
items = service.search_sync(EXAMPLE_SCHEMA, { 'even': 'true' },
|
||||||
|
SecretUnstable.SearchFlags.ALL | SecretUnstable.SearchFlags.LOAD_SECRETS,
|
||||||
|
None)
|
||||||
|
|
||||||
|
item = items[0]
|
||||||
|
item_secret = item.get_secret()
|
||||||
|
self.assertEqual(item_secret.get(), "the password")
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
unittest.main()
|
unittest.main()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user