diff options
author | Simon Warta <[email protected]> | 2015-08-08 17:20:35 +0200 |
---|---|---|
committer | Simon Warta <[email protected]> | 2015-08-11 10:50:14 +0200 |
commit | 3a85d9aa4da36e7ca46e370f4fe65dddc43f4172 (patch) | |
tree | 875edf108dc38536daa6dca1098493608ef78084 /src/tests/catchy | |
parent | 6dfe8a6e37aa19c59829d98ef47f4d497491be80 (diff) |
Remove string constructor of X509_Time()
* Break down string representations to to_string() and readable_string()
* Add m_ prefix to member variable names
* Fix order of methods
* Move comments Doxygen friendly to header
* Make set_to() private (future subjejt of refectoring); People should
use constructor
Closes #185
Diffstat (limited to 'src/tests/catchy')
-rw-r--r-- | src/tests/catchy/test_x509.cpp | 46 |
1 files changed, 23 insertions, 23 deletions
diff --git a/src/tests/catchy/test_x509.cpp b/src/tests/catchy/test_x509.cpp index 01c01dbdc..ad4aa1b1b 100644 --- a/src/tests/catchy/test_x509.cpp +++ b/src/tests/catchy/test_x509.cpp @@ -3,45 +3,45 @@ #include "catchy_tests.h" -// deacticate due to -// https://github.com/randombit/botan/issues/185 - -#if 0 - #if defined(BOTAN_HAS_ASN1) #include <botan/asn1_time.h> +using namespace Botan; + TEST_CASE("human readable time", "[X509]") { - auto time1 = Botan::X509_Time("2008-02-01"); - auto time2 = Botan::X509_Time("2008-02-01 17:24:33"); - auto time3 = Botan::X509_Time("2004-06-14T23:34:30"); + auto time1 = X509_Time("0802010000Z", ASN1_Tag::UTC_TIME); + auto time2 = X509_Time("0802011724Z", ASN1_Tag::UTC_TIME); + auto time3 = X509_Time("040614233430Z", ASN1_Tag::UTC_TIME); - CHECK(( time1.time_is_set() == true )); - CHECK(( time2.time_is_set() == true )); - CHECK(( time3.time_is_set() == true )); + CHECK_THAT(time1.time_is_set(), Equals(true)); + CHECK_THAT(time2.time_is_set(), Equals(true)); + CHECK_THAT(time3.time_is_set(), Equals(true)); - CHECK(( time1.readable_string() == "2008/02/01 00:00:00 UTC" )); - CHECK(( time2.readable_string() == "2008/02/01 17:24:33 UTC" )); - CHECK(( time3.readable_string() == "2004/06/14 23:34:30 UTC" )); + CHECK_THAT(time1.readable_string(), Equals("2008/02/01 00:00:00 UTC")); + CHECK_THAT(time2.readable_string(), Equals("2008/02/01 17:24:00 UTC")); + CHECK_THAT(time3.readable_string(), Equals("2004/06/14 23:34:30 UTC")); } TEST_CASE("no time", "[X509]") { - auto time = Botan::X509_Time(""); - CHECK(( time.time_is_set() == false )); + auto time = X509_Time(); + CHECK_THAT(time.time_is_set(), Equals(false)); } TEST_CASE("invalid time", "[X509]") { - CHECK_THROWS( Botan::X509_Time(" ") ); - CHECK_THROWS( Botan::X509_Time("2008`02-01") ); - CHECK_THROWS( Botan::X509_Time("9999-02-01") ); - CHECK_THROWS( Botan::X509_Time("2000-02-01 17") ); - CHECK_THROWS( Botan::X509_Time("999921") ); + CHECK_THROWS(X509_Time("", ASN1_Tag::UTC_TIME)); + CHECK_THROWS(X509_Time(" ", ASN1_Tag::UTC_TIME)); + CHECK_THROWS(X509_Time("2008`02-01", ASN1_Tag::UTC_TIME)); + CHECK_THROWS(X509_Time("9999-02-01", ASN1_Tag::UTC_TIME)); + CHECK_THROWS(X509_Time("2000-02-01 17", ASN1_Tag::UTC_TIME)); + CHECK_THROWS(X509_Time("999921", ASN1_Tag::UTC_TIME)); + + // wrong time zone + CHECK_THROWS(X509_Time("0802010000", ASN1_Tag::UTC_TIME)); + CHECK_THROWS(X509_Time("0802010000z", ASN1_Tag::UTC_TIME)); } #endif // BOTAN_HAS_ASN1 - -#endif |