Message ID | 20181104094710.27859-2-mgorny@gentoo.org (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | [1/2] t/t7510-signed-commit.sh: Add %GP to custom format checks | expand |
On Sun, Nov 04, 2018 at 10:47:10AM +0100, Michał Górny wrote: > diff --git a/t/t7510-signed-commit.sh b/t/t7510-signed-commit.sh > index e8377286d..86d3f93fa 100755 > --- a/t/t7510-signed-commit.sh > +++ b/t/t7510-signed-commit.sh > @@ -197,9 +197,9 @@ test_expect_success GPG 'show bad signature with custom format' ' > test_expect_success GPG 'show untrusted signature with custom format' ' > cat >expect <<-\EOF && > U > - 61092E85B7227189 > + 65A0EEA02E30CAD7 > Eris Discordia <discord@example.net> > - D4BE22311AD3131E5EDA29A461092E85B7227189 > + F8364A59E07FFE9F4D63005A65A0EEA02E30CAD7 > D4BE22311AD3131E5EDA29A461092E85B7227189 > EOF > git log -1 --format="%G?%n%GK%n%GS%n%GF%n%GP" eighth-signed-alt >actual && > @@ -209,7 +209,7 @@ test_expect_success GPG 'show untrusted signature with custom format' ' > test_expect_success GPG 'show unknown signature with custom format' ' > cat >expect <<-\EOF && > E > - 61092E85B7227189 > + 65A0EEA02E30CAD7 It's my understanding that GnuPG will use the most recent subkey suitable for a particular purpose, and I think the test relies on that behavior. However, I'm not sure that's documented. Do we want to rely on that behavior or be more explicit? (This is a question, not an opinion.)
On Sun, 2018-11-04 at 15:10 +0000, brian m. carlson wrote: > On Sun, Nov 04, 2018 at 10:47:10AM +0100, Michał Górny wrote: > > diff --git a/t/t7510-signed-commit.sh b/t/t7510-signed-commit.sh > > index e8377286d..86d3f93fa 100755 > > --- a/t/t7510-signed-commit.sh > > +++ b/t/t7510-signed-commit.sh > > @@ -197,9 +197,9 @@ test_expect_success GPG 'show bad signature with custom format' ' > > test_expect_success GPG 'show untrusted signature with custom format' ' > > cat >expect <<-\EOF && > > U > > - 61092E85B7227189 > > + 65A0EEA02E30CAD7 > > Eris Discordia <discord@example.net> > > - D4BE22311AD3131E5EDA29A461092E85B7227189 > > + F8364A59E07FFE9F4D63005A65A0EEA02E30CAD7 > > D4BE22311AD3131E5EDA29A461092E85B7227189 > > EOF > > git log -1 --format="%G?%n%GK%n%GS%n%GF%n%GP" eighth-signed-alt >actual && > > @@ -209,7 +209,7 @@ test_expect_success GPG 'show untrusted signature with custom format' ' > > test_expect_success GPG 'show unknown signature with custom format' ' > > cat >expect <<-\EOF && > > E > > - 61092E85B7227189 > > + 65A0EEA02E30CAD7 > > It's my understanding that GnuPG will use the most recent subkey > suitable for a particular purpose, and I think the test relies on that > behavior. However, I'm not sure that's documented. Do we want to rely > on that behavior or be more explicit? (This is a question, not an > opinion.) To be honest, I don't recall which suitable subkey is used. However, it definitely will prefer a subkey with signing capabilities over the primary key if one is present, and this is well-known and expected behavior. In fact, if you have a key with two signing subkeys A and B and it considers A better, then even if you explicitly pass keyid of B, it will use A. To force another subkey you have to append '!' to keyid. Therefore, I think this is a behavior we can rely on.
Michał Górny <mgorny@gentoo.org> writes: >> It's my understanding that GnuPG will use the most recent subkey >> suitable for a particular purpose, and I think the test relies on that >> behavior. However, I'm not sure that's documented. Do we want to rely >> on that behavior or be more explicit? (This is a question, not an >> opinion.) > > To be honest, I don't recall which suitable subkey is used. However, it > definitely will prefer a subkey with signing capabilities over > the primary key if one is present, and this is well-known and expected > behavior. > > In fact, if you have a key with two signing subkeys A and B and it > considers A better, then even if you explicitly pass keyid of B, it will > use A. To force another subkey you have to append '!' to keyid. > > Therefore, I think this is a behavior we can rely on. I didn't check how the signing key configuration is done in the test sript (which is outside the patch context), but do you mean that we create these signed objects by specifying which key to use with a keyid with "!" appended? If so I agree that would make sense, because we would then know which subkey should be used for signing and checking with %GF/%GP would be a good way to do so. Thanks.
On Mon, 2018-11-05 at 10:08 +0900, Junio C Hamano wrote: > Michał Górny <mgorny@gentoo.org> writes: > > > > It's my understanding that GnuPG will use the most recent subkey > > > suitable for a particular purpose, and I think the test relies on that > > > behavior. However, I'm not sure that's documented. Do we want to rely > > > on that behavior or be more explicit? (This is a question, not an > > > opinion.) > > > > To be honest, I don't recall which suitable subkey is used. However, it > > definitely will prefer a subkey with signing capabilities over > > the primary key if one is present, and this is well-known and expected > > behavior. > > > > In fact, if you have a key with two signing subkeys A and B and it > > considers A better, then even if you explicitly pass keyid of B, it will > > use A. To force another subkey you have to append '!' to keyid. > > > > Therefore, I think this is a behavior we can rely on. > > I didn't check how the signing key configuration is done in the test > sript (which is outside the patch context), but do you mean that we > create these signed objects by specifying which key to use with a > keyid with "!" appended? If so I agree that would make sense, > because we would then know which subkey should be used for signing > and checking with %GF/%GP would be a good way to do so. > No, we don't have duplicate subkeys to be required to use that. Some of the tests use explicit '-S<keyid>' to force using the other key; other seem to use a default key (I can't find a place where the default would be set, so I suppose it's GnuPG default).
diff --git a/t/lib-gpg/keyring.gpg b/t/lib-gpg/keyring.gpg index d4754a1f1..918dfce33 100644 --- a/t/lib-gpg/keyring.gpg +++ b/t/lib-gpg/keyring.gpg @@ -30,7 +30,6 @@ Cezx4Q2khACcCs+/LtE8Lb9hC+2cvr3uH5p82AI= =aEiU -----END PGP PRIVATE KEY BLOCK----- -----BEGIN PGP PRIVATE KEY BLOCK----- -Version: GnuPG v1 lQOYBFFMlkcBCADJi/xnAF8yI34PHilSCbM7VtOFO17oFMkpu4cgN2QpPuM5MVjy cvrzKSguZFvPCDLzeAFJW1uPxL4SHaHSkisCrFhijH7OJWcOPNPSFCwu+inAoAsv @@ -83,11 +82,43 @@ fn1sY/IG5atoKK+ypmV/TlBlMZqFQzuPIJQT8VLbmxtLlDhJG04LbI6c8axIZxOO ZKLy5nTTSy16ztqEeS7eifHLPZg1UFFyEEIQ1XW0CNDAeuWKh90ERjyl4Cg7PnWS Z9Ei+zj6JD5Pcdi3BJhQo9WOLOVEJ0NHmewTYqk9QVXH/0v1Hdl4LMJtgcbdbDWk 4UTkXbg9pn3umCgkNJ3Vs8fWnIWO9Izdr2/wrFY2JvUT7Yvl+wsNIWatvOEzGy7n -BOW78WUxzhu0YJ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S5VVndZOjag8URW/9nJMf01w/h +el64 +=Iv7W -----END PGP PRIVATE KEY BLOCK----- -----BEGIN PGP PUBLIC KEY BLOCK----- -Version: GnuPG v1 mQGiBEZnyykRBACzCPjIpTYNL7Y2tQqlEGTTDlvZcWNLjF5f7ZzuyOqNOidLUgFD 36qch1LZLSZkShdR3Gae+bsolyjxrlFuFP0eXRPMtqK20aLw7WZvPFpEV1ThMne+ @@ -137,6 +168,25 @@ bGPyBuWraCivsqZlf05QZTGahUM7jyCUE/FS25sbS5Q4SRtOC2yOnPGsSGcTjmSi 8uZ000stes7ahHku3onxyz2YNVBRchBCENV1tAjQwHrliofdBEY8peAoOz51kmfR Ivs4+iQ+T3HYtwSYUKPVjizlRCdDR5nsE2KpPUFVx/9L9R3ZeCzCbYHG3Ww1pOFE 5F24PaZ97pgoJDSd1bPH1pyFjvSM3a9v8KxWNib1E+2L5fsLDSFmrbzhMxsu5wTl -u/FlMc4btGCUyysvoigo4OR0uXcejgvnuGhBIH4TTwjJG7w7CY7U -=iYv/ +u/FlMc4btGCUyysvoigo4OR0uXcejgvnuGhBIH4TTwjJG7w7CY7UuQENBFveu9wB +CACo7Hk9LE0I8jd/Xzp9H88VqfPURDFFCoC4oG9NTCrrjSN3HnQWbM94aRTilXIo +ua5XcPLn98ktzpIbdg3xz0g+DaxsyxhM0k6UNdEvDdqtA1GMMi1OgtFPB5zGZv5/ +pQhgW1KMb567qIQLygI6Rzt65ifA+A3vYZVoP38HQMUENEr3tJDfFcJNqdRrjjlk +CldUlPXPpAYqLu3XsEJm4pT0Wpypj+WUlOHpoaUzjJSRVxfpJmEjg0JNXDL1ljm9 +7bZZdpZV9Brpe0o3/oWqvxXEckZO08OTB8GY6+Wlogp8tP9Pm8r3xekgSH88hKpc +llEUNoB2VKkoht0DzGYmK9OHABEBAAGJAmwEGAEIACAWIQTUviIxGtMTHl7aKaRh +CS6FtyJxiQUCW9673AIbAgFACRBhCS6FtyJxicB0IAQZAQgAHRYhBPg2Slngf/6f +TWMAWmWg7qAuMMrXBQJb3rvcAAoJEGWg7qAuMMrXA/YH/1ooLR5e5RcpfEWhP7qk +ThRHpWcjNNL9YeeX3fyBkRvPBLTdC6+BWqgaj5DGY1PyzfVDAWk3fu+PLx5R2sHm +apY1ybvfQjvSHe2OMO1sxdwt2MkLBmfdhBsbYbDytPq4R1dDG2iDbqSNaDvYAExY +JUsate6PNxSWrRkY2lwmWrvI6+e/wctTBrY5PiKtTZMxpK1++/C3UUBiyg8NkGu5 +bHR2PHd5VDwB/Jm2/exC5iHPbTxtmjOwEyS+5wZhbkx6OoZhHCMN9hIvSitc8TNG +cpRGJIwYxwJZJVpim/TImsjAubh1uyMoY5fjW4GyBK9iU2plv/bS+lKyCMYgxHam +hzXwmgf/Q/ld9VKXKIXPWs8AeABfHYkMLeZ34laZ1Xhf1vPnktQctlukK8CzbYTU +Wm2BZ7kn/VEhwGOmrQ1nvnoCHTCyL+HHtIt8pKHM0rtKDKFAjMXZfZEK7DR2Qqll +/zogwy0m9Obvz/94XvdNMurUgdeTGyDwOouQcP+vd5x4LqsUtQEmwQfy4iLt7wl3 +RRLPUTLyCfqpD98UAPeqCJkIikd1Ojhr+fd3jjSoo1CDTah0auvlMSMifjggIvi9 +kE4nQISS0QqehGQ/ertNnLYWKvCgPI9fq8fQXG3mnFVR3qXhtSbIMbF1/AUye2bk +uVVZ3WTo2oPFEVv/ZyTH9NcP4XpeuA== +=KRyT -----END PGP PUBLIC KEY BLOCK----- diff --git a/t/t7510-signed-commit.sh b/t/t7510-signed-commit.sh index e8377286d..86d3f93fa 100755 --- a/t/t7510-signed-commit.sh +++ b/t/t7510-signed-commit.sh @@ -197,9 +197,9 @@ test_expect_success GPG 'show bad signature with custom format' ' test_expect_success GPG 'show untrusted signature with custom format' ' cat >expect <<-\EOF && U - 61092E85B7227189 + 65A0EEA02E30CAD7 Eris Discordia <discord@example.net> - D4BE22311AD3131E5EDA29A461092E85B7227189 + F8364A59E07FFE9F4D63005A65A0EEA02E30CAD7 D4BE22311AD3131E5EDA29A461092E85B7227189 EOF git log -1 --format="%G?%n%GK%n%GS%n%GF%n%GP" eighth-signed-alt >actual && @@ -209,7 +209,7 @@ test_expect_success GPG 'show untrusted signature with custom format' ' test_expect_success GPG 'show unknown signature with custom format' ' cat >expect <<-\EOF && E - 61092E85B7227189 + 65A0EEA02E30CAD7
Add a dedicated signing subkey to the key identified as 'Eris Discordia', and update tests appropriately. GnuPG will now sign commits using the dedicated signing subkey, changing the value of %GK and %GF, and effectively creating a test case for %GF!=%GP. Signed-off-by: Michał Górny <mgorny@gentoo.org> --- t/lib-gpg/keyring.gpg | 62 ++++++++++++++++++++++++++++++++++++---- t/t7510-signed-commit.sh | 6 ++-- 2 files changed, 59 insertions(+), 9 deletions(-)