mirror of
https://github.com/andwati/zitadel.git
synced 2026-12-04 18:08:50 +00:00
chore(login): migrate nextjs login to monorepo (#10134)
# Which Problems Are Solved We move the login code to the zitadel repo. # How the Problems Are Solved The login repo is added to ./login as a git subtree pulled from the dockerize-ci branch. Apart from the login code, this PR contains the changes from #10116 # Additional Context - Closes https://github.com/zitadel/typescript/issues/474 - Also merges #10116 - Merging is blocked by failing check because of: - https://github.com/zitadel/zitadel/pull/10134#issuecomment-3012086106 --------- Co-authored-by: Max Peintner <[email protected]> Co-authored-by: Max Peintner <[email protected]> Co-authored-by: Florian Forster <[email protected]>
This commit is contained in:
co-authored by
Max Peintner
Max Peintner
Florian Forster
parent
fce9e770ac
commit
2928c6ac2b
@@ -0,0 +1,67 @@
|
||||
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.js";
|
||||
|
||||
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("NewAuthorizationBearerInterceptor", () => {
|
||||
const transport = {
|
||||
interceptors: [NewAuthorizationBearerInterceptor("mytoken")],
|
||||
};
|
||||
|
||||
test("injects the authorization token", async () => {
|
||||
const handler = vitest.fn((request: Int32Value, context: HandlerContext) => {
|
||||
return { value: request.value.toString() };
|
||||
});
|
||||
|
||||
const service = createRouterTransport(
|
||||
({ rpc }) => {
|
||||
rpc(TestService.method.unary, handler);
|
||||
},
|
||||
{ transport },
|
||||
);
|
||||
|
||||
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");
|
||||
});
|
||||
|
||||
test("do not overwrite the previous authorization token", async () => {
|
||||
const handler = vitest.fn((request: Int32Value, context: HandlerContext) => {
|
||||
return { value: request.value.toString() };
|
||||
});
|
||||
|
||||
const service = createRouterTransport(
|
||||
({ rpc }) => {
|
||||
rpc(TestService.method.unary, handler);
|
||||
},
|
||||
{ transport },
|
||||
);
|
||||
|
||||
await service.unary(
|
||||
TestService.method.unary,
|
||||
undefined,
|
||||
undefined,
|
||||
{ Authorization: "Bearer somethingelse" },
|
||||
{ value: 9001 },
|
||||
);
|
||||
|
||||
expect(handler).toBeCalled();
|
||||
expect(handler.mock.calls[0][1].requestHeader.get("Authorization")).toBe("Bearer somethingelse");
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user