diff options
| author | Michael Albinus | 2018-05-15 14:48:11 +0200 |
|---|---|---|
| committer | Michael Albinus | 2018-05-15 14:48:11 +0200 |
| commit | b3956d85c71c30af732a8bc035ed39421bafe11d (patch) | |
| tree | 4c94dadac1bbfbdb05874b9ba4b2dcf52c96c993 /test | |
| parent | 73a367795f6dfc947a91798c6a62de822e199053 (diff) | |
| download | emacs-b3956d85c71c30af732a8bc035ed39421bafe11d.tar.gz emacs-b3956d85c71c30af732a8bc035ed39421bafe11d.zip | |
Fix Bug#29575
* lisp/net/secrets.el (secrets-create-item): The new item does not
need a unique label.
(secrets-item-path, secrets-get-secret, secrets-get-attributes)
(secrets-get-attribute, secrets-delete-item): ITEM can also be an
object path. (Bug#29575)
* test/lisp/net/secrets-tests.el (secrets-test03-items):
Test also creation of two items with same label. Test
`secrets-get-secret', `secrets-get-attribute' and
`secrets-get-attributes' with object path.
(secrets-test04-search): Harden test.
Diffstat (limited to 'test')
| -rw-r--r-- | test/lisp/net/secrets-tests.el | 70 |
1 files changed, 42 insertions, 28 deletions
diff --git a/test/lisp/net/secrets-tests.el b/test/lisp/net/secrets-tests.el index 23512d48ee5..fcc3a2d3e6e 100644 --- a/test/lisp/net/secrets-tests.el +++ b/test/lisp/net/secrets-tests.el | |||
| @@ -148,37 +148,48 @@ | |||
| 148 | (skip-unless (secrets-empty-path secrets-session-path)) | 148 | (skip-unless (secrets-empty-path secrets-session-path)) |
| 149 | 149 | ||
| 150 | (unwind-protect | 150 | (unwind-protect |
| 151 | (progn | 151 | (let (item-path) |
| 152 | ;; There shall be no items in the "session" collection. | 152 | ;; There shall be no items in the "session" collection. |
| 153 | (should-not (secrets-list-items "session")) | 153 | (should-not (secrets-list-items "session")) |
| 154 | ;; There shall be items in the "Login" collection. | 154 | ;; There shall be items in the "Login" collection. |
| 155 | (should (secrets-list-items "Login")) | 155 | (should (secrets-list-items "Login")) |
| 156 | 156 | ||
| 157 | ;; Create a new item. | 157 | ;; Create a new item. |
| 158 | (secrets-create-item "session" "foo" "secret") | 158 | (should (setq item-path (secrets-create-item "session" "foo" "secret"))) |
| 159 | (should (string-equal (secrets-get-secret "session" "foo") "secret")) | 159 | (dolist (item `("foo" ,item-path)) |
| 160 | (should (string-equal (secrets-get-secret "session" item) "secret"))) | ||
| 161 | |||
| 162 | ;; Create another item with same label. | ||
| 163 | (should (secrets-create-item "session" "foo" "geheim")) | ||
| 164 | (should (equal (secrets-list-items "session") '("foo" "foo"))) | ||
| 160 | 165 | ||
| 161 | ;; Create an item with attributes. | 166 | ;; Create an item with attributes. |
| 162 | (secrets-create-item | ||
| 163 | "session" "bar" "secret" | ||
| 164 | :method "sudo" :user "joe" :host "remote-host") | ||
| 165 | (should | 167 | (should |
| 166 | (string-equal (secrets-get-attribute "session" "bar" :method) "sudo")) | 168 | (setq item-path |
| 167 | ;; The attributes are collected in reverse order. :xdg:schema | 169 | (secrets-create-item |
| 168 | ;; is added silently. | 170 | "session" "bar" "secret" |
| 169 | (should | 171 | :method "sudo" :user "joe" :host "remote-host"))) |
| 170 | (equal | 172 | (dolist (item `("bar" ,item-path)) |
| 171 | (secrets-get-attributes "session" "bar") | 173 | (should |
| 172 | '((:xdg:schema . "org.freedesktop.Secret.Generic") | 174 | (string-equal (secrets-get-attribute "session" item :method) "sudo")) |
| 173 | (:host . "remote-host") (:user . "joe") (:method . "sudo")))) | 175 | ;; The attributes are collected in reverse order. |
| 176 | ;; :xdg:schema is added silently. | ||
| 177 | (should | ||
| 178 | (equal | ||
| 179 | (secrets-get-attributes "session" item) | ||
| 180 | '((:xdg:schema . "org.freedesktop.Secret.Generic") | ||
| 181 | (:host . "remote-host") (:user . "joe") (:method . "sudo"))))) | ||
| 174 | 182 | ||
| 175 | ;; Create an item with another schema. | 183 | ;; Create an item with another schema. |
| 176 | (secrets-create-item | ||
| 177 | "session" "baz" "secret" :xdg:schema "org.gnu.Emacs.foo") | ||
| 178 | (should | 184 | (should |
| 179 | (equal | 185 | (setq item-path |
| 180 | (secrets-get-attributes "session" "baz") | 186 | (secrets-create-item |
| 181 | '((:xdg:schema . "org.gnu.Emacs.foo")))) | 187 | "session" "baz" "secret" :xdg:schema "org.gnu.Emacs.foo"))) |
| 188 | (dolist (item `("baz" ,item-path)) | ||
| 189 | (should | ||
| 190 | (equal | ||
| 191 | (secrets-get-attributes "session" item) | ||
| 192 | '((:xdg:schema . "org.gnu.Emacs.foo"))))) | ||
| 182 | 193 | ||
| 183 | ;; Delete them. | 194 | ;; Delete them. |
| 184 | (dolist (item (secrets-list-items "session")) | 195 | (dolist (item (secrets-list-items "session")) |
| @@ -201,15 +212,18 @@ | |||
| 201 | (should-not (secrets-list-items "session")) | 212 | (should-not (secrets-list-items "session")) |
| 202 | 213 | ||
| 203 | ;; Create some items. | 214 | ;; Create some items. |
| 204 | (secrets-create-item | 215 | (should |
| 205 | "session" "foo" "secret" | 216 | (secrets-create-item |
| 206 | :method "sudo" :user "joe" :host "remote-host") | 217 | "session" "foo" "secret" |
| 207 | (secrets-create-item | 218 | :method "sudo" :user "joe" :host "remote-host")) |
| 208 | "session" "bar" "secret" | 219 | (should |
| 209 | :method "sudo" :user "smith" :host "remote-host") | 220 | (secrets-create-item |
| 210 | (secrets-create-item | 221 | "session" "bar" "secret" |
| 211 | "session" "baz" "secret" | 222 | :method "sudo" :user "smith" :host "remote-host")) |
| 212 | :method "ssh" :user "joe" :host "other-host") | 223 | (should |
| 224 | (secrets-create-item | ||
| 225 | "session" "baz" "secret" | ||
| 226 | :method "ssh" :user "joe" :host "other-host")) | ||
| 213 | 227 | ||
| 214 | ;; Search the items. | 228 | ;; Search the items. |
| 215 | (should-not (secrets-search-items "session" :user "john")) | 229 | (should-not (secrets-search-items "session" :user "john")) |