Merge branch 'main' into qa

This commit is contained in:
Max Peintner
2024-10-25 10:26:33 +02:00
committed by GitHub
5 changed files with 179 additions and 138 deletions

View File

@@ -9,24 +9,24 @@
"type": "module",
"exports": {
".": {
"types": "./dist/index.d.ts",
"import": "./dist/index.js",
"require": "./dist/index.cjs",
"types": "./dist/index.d.ts"
"require": "./dist/index.cjs"
},
"./v1": {
"types": "./dist/v1.d.ts",
"import": "./dist/v1.js",
"require": "./dist/v1.cjs",
"types": "./dist/v1.d.ts"
"require": "./dist/v1.cjs"
},
"./v2": {
"types": "./dist/v2.d.ts",
"import": "./dist/v2.js",
"require": "./dist/v2.cjs",
"types": "./dist/v2.d.ts"
"require": "./dist/v2.cjs"
},
"./v3alpha": {
"types": "./dist/v3alpha.d.ts",
"import": "./dist/v3alpha.js",
"require": "./dist/v3alpha.cjs",
"types": "./dist/v3alpha.d.ts"
"require": "./dist/v3alpha.cjs"
}
},
"files": [
@@ -44,11 +44,12 @@
"clean": "rm -rf .turbo && rm -rf node_modules && rm -rf dist"
},
"dependencies": {
"@zitadel/proto": "workspace:*",
"@bufbuild/protobuf": "^2.0.0",
"@connectrpc/connect": "2.0.0-alpha.1"
"@connectrpc/connect": "2.0.0-alpha.1",
"@zitadel/proto": "workspace:*"
},
"devDependencies": {
"@bufbuild/protocompile": "^0.0.1",
"@zitadel/tsconfig": "workspace:*",
"eslint-config-zitadel": "workspace:*"
}

View File

@@ -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" },