chore: add sms otp and password set acceptance tests

This commit is contained in:
Stefan Benz
2024-11-21 18:01:12 +01:00
parent 1baa2409be
commit f38b8b753c
15 changed files with 165 additions and 46 deletions

View File

@@ -1,6 +1,6 @@
import axios from "axios";
export async function getCodeFromSink(key: string): Promise<any> {
export async function getOtpFromSink(key: string): Promise<any> {
try {
const response = await axios.post(
process.env.SINK_NOTIFICATION_URL!,
@@ -26,3 +26,30 @@ export async function getCodeFromSink(key: string): Promise<any> {
throw error;
}
}
export async function getCodeFromSink(key: string): Promise<any> {
try {
const response = await axios.post(
process.env.SINK_NOTIFICATION_URL!,
{
recipient: key,
},
{
headers: {
"Content-Type": "application/json",
Authorization: `Bearer ${process.env.ZITADEL_SERVICE_USER_TOKEN}`,
},
},
);
if (response.status >= 400) {
const error = `HTTP Error: ${response.status} - ${response.statusText}`;
console.error(error);
throw new Error(error);
}
return response.data.args.code;
} catch (error) {
console.error("Error making request:", error);
throw error;
}
}