Skip to content

Commit

Permalink
Update c tests
Browse files Browse the repository at this point in the history
Signed-off-by: Tiago Nascimento <tiago.nascimento@spruceid.com>
  • Loading branch information
theosirian committed Feb 15, 2023
1 parent 9c1919d commit a5070f3
Showing 1 changed file with 14 additions and 11 deletions.
25 changes: 14 additions & 11 deletions lib/c/test.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ int main() {
assert(strlen(version) > 0);

// Trigger error
const char *vp = didkit_vc_issue_presentation("{}", "{}", "{}");
const char *vp = didkit_vc_issue_presentation("{}", "{}", "{}", NULL);
assert(vp == NULL);
const char *error_msg = didkit_error_message();
assert(error_msg != NULL);
Expand Down Expand Up @@ -58,7 +58,8 @@ int main() {
" \"verificationMethod\": \"%s\""
"}",
verification_method);
const char *vc_ldp = didkit_vc_issue_credential(credential, vc_options, key);
const char *vc_ldp =
didkit_vc_issue_credential(credential, vc_options, key, NULL);
if (vc_ldp == NULL)
errx(1, "issue credential (LDP): %s", didkit_error_message());

Expand All @@ -70,13 +71,15 @@ int main() {
" \"verificationMethod\": \"%s\""
"}",
verification_method);
const char *vc_jwt = didkit_vc_issue_credential(credential, vc_options, key);
const char *vc_jwt =
didkit_vc_issue_credential(credential, vc_options, key, NULL);
if (vc_jwt == NULL)
errx(1, "issue credential (JWT): %s", didkit_error_message());

// Verify Credential (LDP)
const char *vc_verify_options = "{\"proofPurpose\": \"assertionMethod\"}";
const char *res = didkit_vc_verify_credential(vc_ldp, vc_verify_options);
const char *res =
didkit_vc_verify_credential(vc_ldp, vc_verify_options, NULL);
if (res == NULL)
errx(1, "verify credential (LDP): %s", didkit_error_message());
if (strstr(res, "\"errors\":[]") == NULL)
Expand All @@ -85,7 +88,7 @@ int main() {

// Verify Credential (JWT)
vc_verify_options = "{\"proofFormat\": \"jwt\"}";
res = didkit_vc_verify_credential(vc_jwt, vc_verify_options);
res = didkit_vc_verify_credential(vc_jwt, vc_verify_options, NULL);
if (res == NULL)
errx(1, "verify credential (JWT): %s", didkit_error_message());
if (strstr(res, "\"errors\":[]") == NULL)
Expand All @@ -110,13 +113,13 @@ int main() {
" \"verificationMethod\": \"%s\""
"}",
verification_method);
vp = didkit_vc_issue_presentation(presentation, vp_options, key);
vp = didkit_vc_issue_presentation(presentation, vp_options, key, NULL);
if (vp == NULL)
errx(1, "issue presentation: %s", didkit_error_message());

// Verify Presentation
const char *vp_verify_options = "{\"proofPurpose\": \"authentication\"}";
res = didkit_vc_verify_presentation(vp, vp_verify_options);
res = didkit_vc_verify_presentation(vp, vp_verify_options, NULL);
if (res == NULL)
errx(1, "verify presentation: %s", didkit_error_message());
if (strstr(res, "\"errors\":[]") == NULL)
Expand Down Expand Up @@ -154,7 +157,7 @@ int main() {
" \"challenge\": \"%d\""
"}",
verification_method, challenge);
vp = didkit_did_auth(did, vp_options, key);
vp = didkit_did_auth(did, vp_options, key, NULL);
if (vp == NULL)
errx(1, "DIDAuth (LDP): %s", didkit_error_message());

Expand All @@ -168,7 +171,7 @@ int main() {
" \"challenge\": \"%d\""
"}",
verification_method, challenge_jwt);
const char *vp_jwt = didkit_did_auth(did, vp_options, key);
const char *vp_jwt = didkit_did_auth(did, vp_options, key, NULL);
if (vp_jwt == NULL)
errx(1, "DIDAuth (JWT): %s", didkit_error_message());

Expand All @@ -180,7 +183,7 @@ int main() {
" \"challenge\": \"%d\""
"}",
challenge);
res = didkit_vc_verify_presentation(vp, vp_options);
res = didkit_vc_verify_presentation(vp, vp_options, NULL);
if (res == NULL)
errx(1, "verify DIDAuth (LDP): %s", didkit_error_message());
if (strstr(res, "\"errors\":[]") == NULL)
Expand All @@ -196,7 +199,7 @@ int main() {
" \"challenge\": \"%d\""
"}",
challenge_jwt);
res = didkit_vc_verify_presentation(vp_jwt, vp_options);
res = didkit_vc_verify_presentation(vp_jwt, vp_options, NULL);
if (res == NULL)
errx(1, "verify DIDAuth (JWT): %s", didkit_error_message());
if (strstr(res, "\"errors\":[]") == NULL)
Expand Down

0 comments on commit a5070f3

Please sign in to comment.