diff options
author | nulltoken <emeric.fermas@gmail.com> | 2011-07-01 19:59:10 +0400 |
---|---|---|
committer | Vicent Marti <tanoku@gmail.com> | 2011-07-05 04:21:26 +0400 |
commit | 42a1b5e1ad94c41cc7acb6d9ea940572501dd1cb (patch) | |
tree | 2319645df45dea52501667dbbac1a81196e91414 /tests | |
parent | 60caf0246538f26ea867302021747a0f7eae0cda (diff) |
signature: enhance relaxed parsing of bogus signatures
Final fix for issue #278
Diffstat (limited to 'tests')
-rw-r--r-- | tests/t04-commit.c | 119 |
1 files changed, 105 insertions, 14 deletions
diff --git a/tests/t04-commit.c b/tests/t04-commit.c index 63d409ca3..52770720e 100644 --- a/tests/t04-commit.c +++ b/tests/t04-commit.c @@ -263,7 +263,7 @@ BEGIN_TEST(parse1, "parse the signature line in a commit") TEST_SIGNATURE_PASS( "committer <tanoku@gmail.com> 123456 -0100 \n", "committer ", - " ", + "", "tanoku@gmail.com", 123456, -60); @@ -282,7 +282,7 @@ BEGIN_TEST(parse1, "parse the signature line in a commit") "committer Vicent Marti < > 123456 -0100 \n", "committer ", "Vicent Marti", - " ", + "", 123456, -60); @@ -297,10 +297,19 @@ BEGIN_TEST(parse1, "parse the signature line in a commit") /* Parse a signature with empty name and email */ TEST_SIGNATURE_PASS( + "committer <> 123456 -0100 \n", + "committer ", + "", + "", + 123456, + -60); + + /* Parse a signature with empty name and email */ + TEST_SIGNATURE_PASS( "committer < > 123456 -0100 \n", "committer ", "", - " ", + "", 123456, -60); @@ -308,17 +317,104 @@ BEGIN_TEST(parse1, "parse the signature line in a commit") TEST_SIGNATURE_PASS( "committer foo<@bar> 123456 -0100 \n", "committer ", - "fo", + "foo", "@bar", 123456, -60); - TEST_SIGNATURE_FAIL( + /* Parse an obviously invalid signature */ + TEST_SIGNATURE_PASS( + "committer foo<@bar>123456 -0100 \n", + "committer ", + "foo", + "@bar", + 123456, + -60); + + + /* Parse an obviously invalid signature */ + TEST_SIGNATURE_PASS( + "committer <>\n", + "committer ", + "", + "", + 0, + 0); + + TEST_SIGNATURE_PASS( "committer Vicent Marti <tanoku@gmail.com> 123456 -1500 \n", - "committer "); + "committer ", + "Vicent Marti", + "tanoku@gmail.com", + 0, + 0); - TEST_SIGNATURE_FAIL( + TEST_SIGNATURE_PASS( "committer Vicent Marti <tanoku@gmail.com> 123456 +0163 \n", + "committer ", + "Vicent Marti", + "tanoku@gmail.com", + 0, + 0); + + TEST_SIGNATURE_PASS( + "author Vicent Marti <tanoku@gmail.com> notime \n", + "author ", + "Vicent Marti", + "tanoku@gmail.com", + 0, + 0); + + TEST_SIGNATURE_PASS( + "author Vicent Marti <tanoku@gmail.com> 123456 notimezone \n", + "author ", + "Vicent Marti", + "tanoku@gmail.com", + 0, + 0); + + TEST_SIGNATURE_PASS( + "author Vicent Marti <tanoku@gmail.com> notime +0100\n", + "author ", + "Vicent Marti", + "tanoku@gmail.com", + 0, + 0); + + TEST_SIGNATURE_PASS( + "author Vicent Marti <tanoku@gmail.com>\n", + "author ", + "Vicent Marti", + "tanoku@gmail.com", + 0, + 0); + + TEST_SIGNATURE_PASS( + "author A U Thor <author@example.com>, C O. Miter <comiter@example.com> 1234567890 -0700\n", + "author ", + "A U Thor", + "author@example.com", + 1234567890, + -420); + + TEST_SIGNATURE_PASS( + "author A U Thor <author@example.com> and others 1234567890 -0700\n", + "author ", + "A U Thor", + "author@example.com", + 1234567890, + -420); + + TEST_SIGNATURE_PASS( + "author A U Thor <author@example.com> and others 1234567890\n", + "author ", + "A U Thor", + "author@example.com", + 1234567890, + 0); + + TEST_SIGNATURE_FAIL( + "committer Vicent Marti tanoku@gmail.com> 123456 -0100 \n", "committer "); TEST_SIGNATURE_FAIL( @@ -338,12 +434,8 @@ BEGIN_TEST(parse1, "parse the signature line in a commit") "author "); TEST_SIGNATURE_FAIL( - "author Vicent Marti <tanoku@gmail.com> notime \n", - "author "); - - TEST_SIGNATURE_FAIL( - "author Vicent Marti <tanoku@gmail.com>\n", - "author "); + "committer Vicent Marti ><\n", + "committer "); TEST_SIGNATURE_FAIL( "author ", @@ -628,7 +720,6 @@ BEGIN_SUITE(commit) ADD_TEST(details0); ADD_TEST(write0); - //ADD_TEST(write1); ADD_TEST(root0); END_SUITE |