|
1 | 1 | import { AuthorizationError, AuthorizationIdpError } from "../errors"; |
2 | | -import { completeUserAuthorizationWithQueryMode } from "../04-complete-user-authorization"; |
| 2 | +import { |
| 3 | + buildAuthorizationUrl, |
| 4 | + completeUserAuthorizationWithQueryMode, |
| 5 | +} from "../04-complete-user-authorization"; |
| 6 | +import type { Out } from "src/utils/misc"; |
| 7 | +import type { EvaluateIssuerTrust } from "src/credential/status"; |
3 | 8 |
|
4 | 9 | describe("authorizeUserWithQueryMode", () => { |
5 | 10 | it("should return the authorization result when the authorization server responds with a valid response", async () => { |
@@ -45,3 +50,40 @@ describe("authorizeUserWithQueryMode", () => { |
45 | 50 | } |
46 | 51 | }); |
47 | 52 | }); |
| 53 | + |
| 54 | +describe("buildAuthorizationUrl", () => { |
| 55 | + it("should build the authorization URL", async () => { |
| 56 | + const authUrl = await buildAuthorizationUrl( |
| 57 | + "issuerRequestUri", |
| 58 | + "clientId", |
| 59 | + { |
| 60 | + oauth_authorization_server: { |
| 61 | + authorization_endpoint: "https://issuer.com/authorize", |
| 62 | + }, |
| 63 | + } as Out<EvaluateIssuerTrust>["issuerConf"], |
| 64 | + "idpHint" |
| 65 | + ); |
| 66 | + |
| 67 | + expect(authUrl).toMatchObject({ |
| 68 | + authUrl: |
| 69 | + "https://issuer.com/authorize?client_id=clientId&request_uri=issuerRequestUri&idphint=idpHint", |
| 70 | + }); |
| 71 | + }); |
| 72 | + |
| 73 | + it("should build the authorization URL without idpHint", async () => { |
| 74 | + const authUrl = await buildAuthorizationUrl( |
| 75 | + "issuerRequestUri", |
| 76 | + "clientId", |
| 77 | + { |
| 78 | + oauth_authorization_server: { |
| 79 | + authorization_endpoint: "https://issuer.com/authorize", |
| 80 | + }, |
| 81 | + } as Out<EvaluateIssuerTrust>["issuerConf"] |
| 82 | + ); |
| 83 | + |
| 84 | + expect(authUrl).toMatchObject({ |
| 85 | + authUrl: |
| 86 | + "https://issuer.com/authorize?client_id=clientId&request_uri=issuerRequestUri", |
| 87 | + }); |
| 88 | + }); |
| 89 | +}); |
0 commit comments