Skip to content

Commit

Permalink
fix(middleware-sdk-machinelearning): ensure request query is object (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
kuhe committed Oct 6, 2023
1 parent 6e139f7 commit 55995ec
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 5 deletions.
Expand Up @@ -6,20 +6,49 @@ describe("middleware-sdk-machine-learning", () => {
describe(MachineLearning.name, () => {
it("should use the input predict endpoint", async () => {
const client = new MachineLearning({
region: "us-west-2",
region: "us-east-1",
});

requireRequestsFrom(client).toMatch({
hostname: "predict-custom-endpoint.us-west-2.amazonaws.com",
hostname: "predict-custom-endpoint.us-east-1.amazonaws.com",
protocol: "https:",
path: "/my-path",
headers: {
authorization: /.{10,}/,
},
query: {
apples: "oranges",
},
});

await client.predict({
PredictEndpoint: `https://predict-custom-endpoint.us-west-2.amazonaws.com/my-path?apples=oranges`,
PredictEndpoint: `https://predict-custom-endpoint.us-east-1.amazonaws.com/my-path?apples=oranges`,
MLModelId: "1",
Record: {
hello: "world",
},
});

expect.hasAssertions();
});

it("should be signed when URL query is empty", async () => {
const client = new MachineLearning({
region: "us-east-1",
});

requireRequestsFrom(client).toMatch({
hostname: "predict-custom-endpoint.us-east-1.amazonaws.com",
protocol: "https:",
path: "/my-path",
headers: {
authorization: /.{10,}/,
},
query: {},
});

await client.predict({
PredictEndpoint: `https://predict-custom-endpoint.us-east-1.amazonaws.com/my-path`,
MLModelId: "1",
Record: {
hello: "world",
Expand Down
Expand Up @@ -24,8 +24,8 @@ export function predictEndpointMiddleware(options: { urlParser: UrlParser }): Bu
path: endpoint.path,
port: endpoint.port,
protocol: endpoint.protocol,
query: endpoint.query,
};
query: endpoint.query ?? {},
} as HttpRequest;
}
}
return next({
Expand Down

0 comments on commit 55995ec

Please sign in to comment.