diff options
author | Julien Boeuf <jboeuf@google.com> | 2015-07-08 16:24:31 -0700 |
---|---|---|
committer | Julien Boeuf <jboeuf@google.com> | 2015-07-08 16:24:31 -0700 |
commit | ea94e46b0df7f1774eefea6654f1e26cc4484b00 (patch) | |
tree | b6fdb9a22ac751a78305ffb2665e886f6b6d0063 /test/core/security/base64_test.c | |
parent | feca1bf06cf6ffd8d45b86c1c51f798bad9c52f4 (diff) | |
parent | 977565c2c0d67de0ab0c147fc6cd348a1e9ea419 (diff) |
Merge branch 'master' of github.com:grpc/grpc into jwt_verifier
Diffstat (limited to 'test/core/security/base64_test.c')
-rw-r--r-- | test/core/security/base64_test.c | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/test/core/security/base64_test.c b/test/core/security/base64_test.c index a922896bc3..f8b7ebf554 100644 --- a/test/core/security/base64_test.c +++ b/test/core/security/base64_test.c @@ -169,6 +169,43 @@ static void test_rfc4648_test_vectors(void) { gpr_free(b64); } +static void test_unpadded_decode(void) { + gpr_slice decoded; + + decoded = grpc_base64_decode("Zm9vYmFy", 0); + GPR_ASSERT(!GPR_SLICE_IS_EMPTY(decoded)); + GPR_ASSERT(gpr_slice_str_cmp(decoded, "foobar") == 0); + gpr_slice_unref(decoded); + + decoded = grpc_base64_decode("Zm9vYmE", 0); + GPR_ASSERT(!GPR_SLICE_IS_EMPTY(decoded)); + GPR_ASSERT(gpr_slice_str_cmp(decoded, "fooba") == 0); + gpr_slice_unref(decoded); + + decoded = grpc_base64_decode("Zm9vYg", 0); + GPR_ASSERT(!GPR_SLICE_IS_EMPTY(decoded)); + GPR_ASSERT(gpr_slice_str_cmp(decoded, "foob") == 0); + gpr_slice_unref(decoded); + + decoded = grpc_base64_decode("Zm9v", 0); + GPR_ASSERT(!GPR_SLICE_IS_EMPTY(decoded)); + GPR_ASSERT(gpr_slice_str_cmp(decoded, "foo") == 0); + gpr_slice_unref(decoded); + + decoded = grpc_base64_decode("Zm8", 0); + GPR_ASSERT(!GPR_SLICE_IS_EMPTY(decoded)); + GPR_ASSERT(gpr_slice_str_cmp(decoded, "fo") == 0); + gpr_slice_unref(decoded); + + decoded = grpc_base64_decode("Zg", 0); + GPR_ASSERT(!GPR_SLICE_IS_EMPTY(decoded)); + GPR_ASSERT(gpr_slice_str_cmp(decoded, "f") == 0); + gpr_slice_unref(decoded); + + decoded = grpc_base64_decode("", 0); + GPR_ASSERT(GPR_SLICE_IS_EMPTY(decoded)); +} + int main(int argc, char **argv) { grpc_test_init(argc, argv); test_simple_encode_decode_b64_no_multiline(); @@ -181,5 +218,6 @@ int main(int argc, char **argv) { test_full_range_encode_decode_b64_urlsafe_multiline(); test_url_safe_unsafe_mismtach_failure(); test_rfc4648_test_vectors(); + test_unpadded_decode(); return 0; } |