mirror of
https://github.com/zitadel/zitadel.git
synced 2025-12-12 01:02:17 +00:00
chore: otp starting
This commit is contained in:
31
acceptance/tests/otp.ts
Normal file
31
acceptance/tests/otp.ts
Normal file
@@ -0,0 +1,31 @@
|
||||
import * as http from "node:http";
|
||||
|
||||
let messages = new Map<string, any>();
|
||||
|
||||
export function startSink() {
|
||||
const hostname = "127.0.0.1"
|
||||
const port = 3030
|
||||
|
||||
const server = http.createServer((req, res) => {
|
||||
console.log("Sink received message: ")
|
||||
let body = '';
|
||||
req.on('data', (chunk) => {
|
||||
body += chunk;
|
||||
});
|
||||
|
||||
req.on('end', () => {
|
||||
console.log(body);
|
||||
const data = JSON.parse(body)
|
||||
messages.set(data.contextInfo.recipientEmailAddress, data.args.code)
|
||||
res.statusCode = 200;
|
||||
res.setHeader('Content-Type', 'text/plain');
|
||||
res.write('OK');
|
||||
res.end();
|
||||
});
|
||||
});
|
||||
|
||||
server.listen(port, hostname, () => {
|
||||
console.log(`Sink running at http://${hostname}:${port}/`);
|
||||
});
|
||||
return server
|
||||
}
|
||||
36
acceptance/tests/username-password-otp_sms.spec.ts
Normal file
36
acceptance/tests/username-password-otp_sms.spec.ts
Normal file
@@ -0,0 +1,36 @@
|
||||
import {test as base} from "@playwright/test";
|
||||
import {OtpType, PasswordUserWithOTP} from './user';
|
||||
import path from 'path';
|
||||
import dotenv from 'dotenv';
|
||||
import {loginScreenExpect, loginWithPassword} from "./login";
|
||||
import {startSink} from "./otp";
|
||||
|
||||
// Read from ".env" file.
|
||||
dotenv.config({path: path.resolve(__dirname, '.env.local')});
|
||||
|
||||
const test = base.extend<{ user: PasswordUserWithOTP }>({
|
||||
user: async ({page}, use) => {
|
||||
const user = new PasswordUserWithOTP({
|
||||
email: "otp_sms@example.com",
|
||||
firstName: "first",
|
||||
lastName: "last",
|
||||
password: "Password1!",
|
||||
organization: "",
|
||||
type: OtpType.sms,
|
||||
});
|
||||
|
||||
await user.ensure(page);
|
||||
await use(user);
|
||||
},
|
||||
});
|
||||
|
||||
test("username, password and otp login", async ({user, page}) => {
|
||||
const server = startSink()
|
||||
await loginWithPassword(page, user.getUsername(), user.getPassword())
|
||||
|
||||
|
||||
await loginScreenExpect(page, user.getFullName());
|
||||
server.close()
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user