]> git.saurik.com Git - apt.git/commitdiff
add test for apt-key 0xKEY and use parameter expansion
authorDavid Kalnischkies <david@kalnischkies.de>
Sun, 6 Mar 2016 09:16:59 +0000 (10:16 +0100)
committerDavid Kalnischkies <david@kalnischkies.de>
Sun, 6 Mar 2016 09:16:59 +0000 (10:16 +0100)
Fixed in f7bd44bae0d7cb7f9838490b5eece075da83899e already, but the
commit misses the Closes tag and while we are at it we can add a simple
regression test and micro-optimize it a bit.

Thanks: James McCoy for the suggestion.
Closes: 816691
cmdline/apt-key.in
test/integration/test-apt-key

index cfd4be35d3e6062860e6fbcd150877d00c7bce0f..3ed2a70cec9f62a4f35202619bc8ea1febaf0199 100644 (file)
@@ -193,7 +193,7 @@ remove_key_from_keyring() {
        get_fingerprints_of_keyring "$KEYRINGFILE" > "$FINGERPRINTS"
 
         # strip leading 0x, if present:
        get_fingerprints_of_keyring "$KEYRINGFILE" > "$FINGERPRINTS"
 
         # strip leading 0x, if present:
-        KEY="$(printf %s "$KEY" | sed s/^0x//)"
+        KEY="${KEY#0x}"
 
        # check if the key is in this keyring
        if ! grep -iq "^[0-9A-F]*${KEY}$" "$FINGERPRINTS"; then
 
        # check if the key is in this keyring
        if ! grep -iq "^[0-9A-F]*${KEY}$" "$FINGERPRINTS"; then
index 907824db1861f0cb4bdd2abef520aa21db2919f6..82b64963cd7ba5888c48e77eb1320ea90151a33f 100755 (executable)
@@ -85,6 +85,17 @@ gpg:              unchanged: 1' aptkey --fakeroot update
        testfailure test -e rootdir/etc/apt/trusted.gpg.d/joesixpack.gpg
        testsuccess cmp keys/joesixpack.pub rootdir/etc/apt/trusted.gpg.d/joesixpack.gpg~
 
        testfailure test -e rootdir/etc/apt/trusted.gpg.d/joesixpack.gpg
        testsuccess cmp keys/joesixpack.pub rootdir/etc/apt/trusted.gpg.d/joesixpack.gpg~
 
+       msgtest 'Test key removal with' 'different key specs'
+       cleanplate
+       cp -a keys/joesixpack.pub rootdir/etc/apt/trusted.gpg.d/joesixpack.gpg
+       cp -a keys/marvinparanoid.pub rootdir/etc/apt/trusted.gpg.d/marvinparanoid.gpg
+       testsuccess --nomsg aptkey --fakeroot del 0xDBAC8DAE 528144E2
+       testempty aptkey list
+       testfailure test -e rootdir/etc/apt/trusted.gpg.d/joesixpack.gpg
+       testsuccess cmp keys/joesixpack.pub rootdir/etc/apt/trusted.gpg.d/joesixpack.gpg~
+       testfailure test -e rootdir/etc/apt/trusted.gpg.d/marvinparanoid.gpg
+       testsuccess cmp keys/marvinparanoid.pub rootdir/etc/apt/trusted.gpg.d/marvinparanoid.gpg~
+
        msgtest 'Test key removal with' 'long key ID'
        cleanplate
        cp -a keys/joesixpack.pub rootdir/etc/apt/trusted.gpg.d/joesixpack.gpg
        msgtest 'Test key removal with' 'long key ID'
        cleanplate
        cp -a keys/joesixpack.pub rootdir/etc/apt/trusted.gpg.d/joesixpack.gpg