mirror of
https://github.com/zitadel/zitadel.git
synced 2025-12-11 20:12:18 +00:00
chore: enable unit tests
This commit is contained in:
@@ -1,20 +1,24 @@
|
||||
import { Int32Value, Int32ValueSchema, StringValueSchema } from "@bufbuild/protobuf/wkt";
|
||||
import { Int32Value } from "@bufbuild/protobuf/wkt";
|
||||
import { compileService } from "@bufbuild/protocompile";
|
||||
import { createRouterTransport, HandlerContext } from "@connectrpc/connect";
|
||||
import { describe, expect, test, vitest } from "vitest";
|
||||
import { NewAuthorizationBearerInterceptor } from "./interceptors";
|
||||
|
||||
const TestService = {
|
||||
typeName: "handwritten.TestService",
|
||||
methods: {
|
||||
unary: {
|
||||
input: Int32ValueSchema,
|
||||
output: StringValueSchema,
|
||||
methodKind: "unary",
|
||||
},
|
||||
},
|
||||
} as const;
|
||||
const TestService = compileService(`
|
||||
syntax = "proto3";
|
||||
package handwritten;
|
||||
service TestService {
|
||||
rpc Unary(Int32Value) returns (StringValue);
|
||||
}
|
||||
message Int32Value {
|
||||
int32 value = 1;
|
||||
}
|
||||
message StringValue {
|
||||
string value = 1;
|
||||
}
|
||||
`);
|
||||
|
||||
describe.skip("NewAuthorizationBearerInterceptor", () => {
|
||||
describe("NewAuthorizationBearerInterceptor", () => {
|
||||
const transport = {
|
||||
interceptors: [NewAuthorizationBearerInterceptor("mytoken")],
|
||||
};
|
||||
@@ -25,13 +29,13 @@ describe.skip("NewAuthorizationBearerInterceptor", () => {
|
||||
});
|
||||
|
||||
const service = createRouterTransport(
|
||||
({ service }) => {
|
||||
service(TestService, { unary: handler });
|
||||
({ rpc }) => {
|
||||
rpc(TestService.method.unary, handler);
|
||||
},
|
||||
{ transport },
|
||||
);
|
||||
|
||||
await service.unary(TestService, TestService.methods.unary, undefined, undefined, {}, { value: 9001 });
|
||||
await service.unary(TestService.method.unary, undefined, undefined, {}, { value: 9001 });
|
||||
|
||||
expect(handler).toBeCalled();
|
||||
expect(handler.mock.calls[0][1].requestHeader.get("Authorization")).toBe("Bearer mytoken");
|
||||
@@ -43,14 +47,14 @@ describe.skip("NewAuthorizationBearerInterceptor", () => {
|
||||
});
|
||||
|
||||
const service = createRouterTransport(
|
||||
({ service }) => {
|
||||
service(TestService, { unary: handler });
|
||||
({ rpc }) => {
|
||||
rpc(TestService.method.unary, handler);
|
||||
},
|
||||
{ transport },
|
||||
);
|
||||
|
||||
await service.unary(
|
||||
TestService.methods.unary,
|
||||
TestService.method.unary,
|
||||
undefined,
|
||||
undefined,
|
||||
{ Authorization: "Bearer somethingelse" },
|
||||
|
||||
Reference in New Issue
Block a user