diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-08-07 13:28:46 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-08-07 13:28:46 +0000 |
commit | b5f09c671df3a54d284a32e400f8b995de9745f9 (patch) | |
tree | 24a85cdbe383a4c75751eb7130ee651228304b39 /test/libapt/assert_pubkeyalgo_test.cc | |
parent | Releasing progress-linux version 2.9.6-0.0~progress7.99u1. (diff) | |
download | apt-b5f09c671df3a54d284a32e400f8b995de9745f9.tar.xz apt-b5f09c671df3a54d284a32e400f8b995de9745f9.zip |
Merging upstream version 2.9.7.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'test/libapt/assert_pubkeyalgo_test.cc')
-rw-r--r-- | test/libapt/assert_pubkeyalgo_test.cc | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/test/libapt/assert_pubkeyalgo_test.cc b/test/libapt/assert_pubkeyalgo_test.cc new file mode 100644 index 0000000..88a070b --- /dev/null +++ b/test/libapt/assert_pubkeyalgo_test.cc @@ -0,0 +1,56 @@ +#include <config.h> + +#include <apt-pkg/error.h> +#include <apt-pkg/gpgv.h> + +#include "common.h" + +TEST(AssertPubKeyAlgo_Test, test) +{ + EXPECT_TRUE(IsAssertedPubKeyAlgo("rsa2048", ">=rsa2048")); + _error->DumpErrors(); + EXPECT_TRUE(_error->empty()); + + EXPECT_TRUE(IsAssertedPubKeyAlgo("rsa2048", "another,>=rsa2048")); + EXPECT_TRUE(_error->empty()); + + EXPECT_FALSE(IsAssertedPubKeyAlgo("rsa2048", ">=rsa2049")); + EXPECT_TRUE(_error->empty()); + + EXPECT_TRUE(IsAssertedPubKeyAlgo("ed25519", ">=rsa2048,ed25519")); + EXPECT_TRUE(_error->empty()); +} + +TEST(AssertPubKeyAlgo_Test, CanOnlyCompareRSA) +{ + std::string msg; + EXPECT_FALSE(IsAssertedPubKeyAlgo("ed25519", ">=ed25519")); + EXPECT_TRUE(_error->PopMessage(msg)); + EXPECT_EQ("Unrecognized public key specification '>=ed25519' in option >=ed25519", msg); + EXPECT_TRUE(_error->empty()); +} + +TEST(AssertPubKeyAlgo_Test, EmptyOption) +{ + std::string msg; + EXPECT_FALSE(IsAssertedPubKeyAlgo("ed25519", "")); + EXPECT_TRUE(_error->empty()); + + EXPECT_FALSE(IsAssertedPubKeyAlgo("ed25519", ",")); + EXPECT_TRUE(_error->PopMessage(msg)); + EXPECT_EQ("Empty item in public key assertion string option ,", msg); + EXPECT_TRUE(_error->empty()); + + EXPECT_FALSE(IsAssertedPubKeyAlgo("ed25519", "moo,")); + EXPECT_TRUE(_error->empty()); + + EXPECT_FALSE(IsAssertedPubKeyAlgo("ed25519", "moo,,")); + EXPECT_TRUE(_error->PopMessage(msg)); + EXPECT_EQ("Empty item in public key assertion string option moo,,", msg); + EXPECT_TRUE(_error->empty()); + + EXPECT_FALSE(IsAssertedPubKeyAlgo("ed25519", ",moo")); + EXPECT_TRUE(_error->PopMessage(msg)); + EXPECT_EQ("Empty item in public key assertion string option ,moo", msg); + EXPECT_TRUE(_error->empty()); +} |