diff options
author | Mikkel Krautz <mikkel@krautz.dk> | 2017-08-06 23:13:01 +0300 |
---|---|---|
committer | Mikkel Krautz <mikkel@krautz.dk> | 2017-08-06 23:13:01 +0300 |
commit | 7d83448d09fd8090139cc3a398cc39b18ca7bf0b (patch) | |
tree | 2287fbce865d74ba35947a7c11fa19e6834e9b21 /src/tests/TestFFDHE | |
parent | 1178f64509cc66cd2f1c305a3d25168ed938fe12 (diff) |
FFDHE: add NamedGroups method for getting a list of supported named groups.
Also updates TestFFDHE to exercise the new method (and, in doing so,
refactors the tests a bit).
The core check logic from exercise() is moved into a tryFFDHELookupByName
function, which is now used by both the exercise() test, as well as the
namedGroupsMethod() test that is added by this commit.
Diffstat (limited to 'src/tests/TestFFDHE')
-rw-r--r-- | src/tests/TestFFDHE/TestFFDHE.cpp | 20 |
1 files changed, 15 insertions, 5 deletions
diff --git a/src/tests/TestFFDHE/TestFFDHE.cpp b/src/tests/TestFFDHE/TestFFDHE.cpp index d5dcd286d..0a8fa8ef5 100644 --- a/src/tests/TestFFDHE/TestFFDHE.cpp +++ b/src/tests/TestFFDHE/TestFFDHE.cpp @@ -22,6 +22,7 @@ class TestFFDHE : public QObject { #if defined(USE_QSSLDIFFIEHELLMANPARAMETERS) void exercise_data(); void exercise(); + void namedGroupsMethod(); #endif }; @@ -51,10 +52,7 @@ void TestFFDHE::exercise_data() { QTest::newRow("trailingspace") << QString(QLatin1String("ffdhe2048 ")) << false; } -void TestFFDHE::exercise() { - QFETCH(QString, name); - QFETCH(bool, expectedToWork); - +static bool tryFFDHELookupByName(QString name) { bool ok = true; QByteArray pem = FFDHE::PEMForNamedGroup(name); @@ -69,7 +67,19 @@ void TestFFDHE::exercise() { } } - QCOMPARE(ok, expectedToWork); + return ok; +} + +void TestFFDHE::exercise() { + QFETCH(QString, name); + QFETCH(bool, expectedToWork); + QCOMPARE(tryFFDHELookupByName(name), expectedToWork); +} + +void TestFFDHE::namedGroupsMethod() { + foreach (QString name, FFDHE::NamedGroups()) { + QCOMPARE(tryFFDHELookupByName(name), true); + } } #endif |