fix: fix observable

This commit is contained in:
2025-01-31 03:23:45 +08:00
parent 733b697ee2
commit 316361bd3c
45 changed files with 1084 additions and 1355 deletions

View File

@@ -1,6 +1,5 @@
import { TestBed } from '@/testing';
import { base64url } from 'rfc4648';
import { vi } from 'vitest';
import { CryptoService } from '../utils/crypto/crypto.service';
import { JwkWindowCryptoService } from './jwk-window-crypto.service';
@@ -42,9 +41,6 @@ describe('JwkWindowCryptoService', () => {
imports: [],
providers: [JwkWindowCryptoService, CryptoService],
});
});
beforeEach(async () => {
service = TestBed.inject(JwkWindowCryptoService);
});
@@ -53,22 +49,21 @@ describe('JwkWindowCryptoService', () => {
});
describe('importVerificationKey', () => {
it('returns instance of CryptoKey when valid input is provided', (done) => {
it('returns instance of CryptoKey when valid input is provided', async () => {
const promises = keys.map((key) =>
service.importVerificationKey(key, alg)
);
Promise.all(promises).then((values) => {
values.forEach((value) => {
for (const value of values) {
expect(value).toBeInstanceOf(CryptoKey);
});
done();
}
});
});
});
describe('verifyKey', () => {
it('returns true when valid input is provided', (done) => {
it('returns true when valid input is provided', async () => {
const headerAndPayloadString =
'eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiYWRtaW4iOnRydWUsImlhdCI6MTUxNjIzOTAyMn0';
const signatureString =
@@ -77,17 +72,13 @@ describe('JwkWindowCryptoService', () => {
loose: true,
});
service
const value = await service
.importVerificationKey(key3, alg)
.then((c) =>
service.verifyKey(alg, c, signature, headerAndPayloadString)
)
.then((value) => {
expect(value).toEqual(true);
})
.finally(() => {
done();
});
);
expect(value).toEqual(true);
});
});
});