Skip to content

Commit 274b397

Browse files
philcluffjsanford8
authored andcommitted
Add unit tests
1 parent d100d6d commit 274b397

File tree

2 files changed

+53
-0
lines changed

2 files changed

+53
-0
lines changed

deno_tests/api-resources/jwt.test.ts

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,27 @@ Deno.test(async function signSpaceId() {
152152
);
153153
});
154154

155+
Deno.test(async function signDrmLicense() {
156+
assertObjectMatch(await verify(mux.jwt.signDrmLicense('abcdefgh')), {
157+
kid: jwtSigningKey,
158+
aud: 'l',
159+
sub: 'abcdefgh',
160+
});
161+
assertObjectMatch(
162+
await verify(
163+
muxWithoutKeys.jwt.signDrmLicense('abcdefgh', {
164+
keyId: jwtSigningKey,
165+
keySecret: privatePkcs1,
166+
}),
167+
),
168+
{
169+
kid: jwtSigningKey,
170+
aud: 'l',
171+
sub: 'abcdefgh',
172+
},
173+
);
174+
});
175+
155176
Deno.test(async function signViewerCounts() {
156177
assertObjectMatch(await verify(mux.jwt.signViewerCounts('abcdefgh')), {
157178
kid: jwtSigningKey,

tests/api-resources/jwt.test.ts

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,38 @@ describe('resource jwt', () => {
208208
});
209209
});
210210

211+
test('signDrmLicense', async () => {
212+
expect(decodeJwt(await mux.jwt.signDrmLicense('abcdefgh'))).toMatchObject({
213+
kid: jwtSigningKey,
214+
aud: 'l',
215+
sub: 'abcdefgh',
216+
});
217+
expect(
218+
decodeJwt(
219+
await muxWithoutKeys.jwt.signDrmLicense('abcdefgh', {
220+
keyId: jwtSigningKey,
221+
keySecret: privatePkcs1,
222+
}),
223+
),
224+
).toMatchObject({
225+
kid: jwtSigningKey,
226+
aud: 'l',
227+
sub: 'abcdefgh',
228+
});
229+
expect(
230+
decodeJwt(
231+
await muxWithoutKeys.jwt.signDrmLicense('abcdefgh', {
232+
keyId: jwtSigningKey,
233+
keySecret: Buffer.from(privatePkcs1).toString('base64'),
234+
}),
235+
),
236+
).toMatchObject({
237+
kid: jwtSigningKey,
238+
aud: 'l',
239+
sub: 'abcdefgh',
240+
});
241+
});
242+
211243
test('signViewerCounts', async () => {
212244
expect(decodeJwt(await mux.jwt.signViewerCounts('abcdefgh'))).toMatchObject({
213245
kid: jwtSigningKey,

0 commit comments

Comments
 (0)