aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--fixtures/test.creds14
-rw-r--r--src/nkeys.zig30
2 files changed, 23 insertions, 21 deletions
diff --git a/fixtures/test.creds b/fixtures/test.creds
deleted file mode 100644
index 4212a39..0000000
--- a/fixtures/test.creds
+++ /dev/null
@@ -1,14 +0,0 @@
1-----BEGIN NATS USER JWT-----
2eyJ0eXAiOiJKV1QiLCJhbGciOiJlZDI1NTE5LW5rZXkifQ.eyJqdGkiOiJUWEg1TUxDNTdPTUJUQURYNUJNU0RLWkhSQUtXUFM0TkdHRFFPVlJXRzUyRFdaUlFFVERBIiwiaWF0IjoxNjIxNTgyOTU1LCJpc3MiOiJBQ1ZUQVZMQlFKTklQRjdNWFZWSlpZUFhaTkdFQUZMWVpTUjJSNVRZNk9ESjNSTTRYV0FDNUVFRiIsIm5hbWUiOiJ0ZXN0Iiwic3ViIjoiVUJHSlhLRkVWUlFEM05LM0lDRVc1Q0lDSzM1NkdESVZORkhaRUU0SzdMMkRYWTdORVNQVlFVNEwiLCJuYXRzIjp7InB1YiI6e30sInN1YiI6e30sInN1YnMiOi0xLCJkYXRhIjotMSwicGF5bG9hZCI6LTEsInR5cGUiOiJ1c2VyIiwidmVyc2lvbiI6Mn19.OhPLDZflyJ_keg2xBRDHZZhG5x_Qf_Yb61k9eHLs9zLRf0_ETwMd0PNZI_isuBhXYevobXHVoYA3oxvMVGlDCQ
3------END NATS USER JWT------
4
5************************* IMPORTANT *************************
6NKEY Seed printed below can be used to sign and prove identity.
7NKEYs are sensitive and should be treated as secrets.
8
9-----BEGIN USER NKEY SEED-----
10SUAGIEYODKBBTUMOB666Z5KA4FCWAZV7HWSGRHOD7MK6UM5IYLWLACH7DQ
11------END USER NKEY SEED------
12
13*************************************************************
14
diff --git a/src/nkeys.zig b/src/nkeys.zig
index e3d9ef9..8493941 100644
--- a/src/nkeys.zig
+++ b/src/nkeys.zig
@@ -439,11 +439,27 @@ test {
439} 439}
440 440
441test { 441test {
442 var creds_bytes = try std.fs.cwd().readFileAlloc(testing.allocator, "fixtures/test.creds", std.math.maxInt(usize)); 442 const creds =
443 defer testing.allocator.free(creds_bytes); 443 \\-----BEGIN NATS USER JWT-----
444 defer wipeBytes(creds_bytes); 444 \\eyJ0eXAiOiJKV1QiLCJhbGciOiJlZDI1NTE5LW5rZXkifQ.eyJqdGkiOiJUWEg1TUxDNTdPTUJUQURYNUJNU0RLWkhSQUtXUFM0TkdHRFFPVlJXRzUyRFdaUlFFVERBIiwiaWF0IjoxNjIxNTgyOTU1LCJpc3MiOiJBQ1ZUQVZMQlFKTklQRjdNWFZWSlpZUFhaTkdFQUZMWVpTUjJSNVRZNk9ESjNSTTRYV0FDNUVFRiIsIm5hbWUiOiJ0ZXN0Iiwic3ViIjoiVUJHSlhLRkVWUlFEM05LM0lDRVc1Q0lDSzM1NkdESVZORkhaRUU0SzdMMkRYWTdORVNQVlFVNEwiLCJuYXRzIjp7InB1YiI6e30sInN1YiI6e30sInN1YnMiOi0xLCJkYXRhIjotMSwicGF5bG9hZCI6LTEsInR5cGUiOiJ1c2VyIiwidmVyc2lvbiI6Mn19.OhPLDZflyJ_keg2xBRDHZZhG5x_Qf_Yb61k9eHLs9zLRf0_ETwMd0PNZI_isuBhXYevobXHVoYA3oxvMVGlDCQ
445 445 \\------END NATS USER JWT------
446 // TODO(rutgerbrf): validate the contents of the results of these functions 446 \\
447 _ = try parseDecoratedUserNkey(creds_bytes); 447 \\************************* IMPORTANT *************************
448 _ = parseDecoratedJwt(creds_bytes); 448 \\NKEY Seed printed below can be used to sign and prove identity.
449 \\NKEYs are sensitive and should be treated as secrets.
450 \\
451 \\-----BEGIN USER NKEY SEED-----
452 \\SUAGIEYODKBBTUMOB666Z5KA4FCWAZV7HWSGRHOD7MK6UM5IYLWLACH7DQ
453 \\------END USER NKEY SEED------
454 \\
455 \\*************************************************************
456 ;
457 const jwt = "eyJ0eXAiOiJKV1QiLCJhbGciOiJlZDI1NTE5LW5rZXkifQ.eyJqdGkiOiJUWEg1TUxDNTdPTUJUQURYNUJNU0RLWkhSQUtXUFM0TkdHRFFPVlJXRzUyRFdaUlFFVERBIiwiaWF0IjoxNjIxNTgyOTU1LCJpc3MiOiJBQ1ZUQVZMQlFKTklQRjdNWFZWSlpZUFhaTkdFQUZMWVpTUjJSNVRZNk9ESjNSTTRYV0FDNUVFRiIsIm5hbWUiOiJ0ZXN0Iiwic3ViIjoiVUJHSlhLRkVWUlFEM05LM0lDRVc1Q0lDSzM1NkdESVZORkhaRUU0SzdMMkRYWTdORVNQVlFVNEwiLCJuYXRzIjp7InB1YiI6e30sInN1YiI6e30sInN1YnMiOi0xLCJkYXRhIjotMSwicGF5bG9hZCI6LTEsInR5cGUiOiJ1c2VyIiwidmVyc2lvbiI6Mn19.OhPLDZflyJ_keg2xBRDHZZhG5x_Qf_Yb61k9eHLs9zLRf0_ETwMd0PNZI_isuBhXYevobXHVoYA3oxvMVGlDCQ";
458 const seed = "SUAGIEYODKBBTUMOB666Z5KA4FCWAZV7HWSGRHOD7MK6UM5IYLWLACH7DQ";
459
460 var got_kp = try parseDecoratedUserNkey(creds);
461 try testing.expectEqualStrings(seed, &got_kp.seed);
462
463 var got_jwt = parseDecoratedJwt(creds);
464 try testing.expectEqualStrings(jwt, got_jwt);
449} 465}