-
Notifications
You must be signed in to change notification settings - Fork 0
/
UnitTest1.cs
40 lines (34 loc) · 1.06 KB
/
UnitTest1.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
namespace c_sharp_unit_tests_github_actions;
using System;
using System.Collections.Generic;
using System.IO;
using System.Security.Cryptography;
using Jose;
[TestClass]
public class UnitTest1
{
[TestMethod]
public void TestMethod1()
{
var serviceAccountId = "ajel4hfk79lh6j0ci6aq";
var keyId = "ajeoqmhhondlfj6alhn8";
var now = DateTimeOffset.UtcNow.ToUnixTimeSeconds();
var headers = new Dictionary<string, object>()
{
{ "kid", keyId }
};
var payload = new Dictionary<string, object>()
{
{ "aud", "https://iam.api.cloud.yandex.net/iam/v1/tokens" },
{ "iss", serviceAccountId },
{ "iat", now },
{ "exp", now + 3600 }
};
using (var rsa = RSA.Create())
{
rsa.ImportFromPem(File.ReadAllText("sa.key").ToCharArray());
string encodedToken = Jose.JWT.Encode(payload, rsa, JwsAlgorithm.PS256, headers);
Assert.IsNotNull(encodedToken);
}
}
}