C# on .NET Core 2.0 + ASP.NET Core 2.0 + EFCore 2.0 + SQLite
You can pull the docker image of this Test Target Demonstration Web Site from bellow.
https://hub.docker.com/r/samplebyjsakamoto/otp2faauthwebappdemo/
Once you pulled this docker image,
> docker pull samplebyjsakamoto/otp2faauthwebappdemo:latest
You can run the demo app server by following command.
> docker run -p 52375:80 -d samplebyjsakamoto/otp2faauthwebappdemo:latest
- Account Name:
foo@example.com
- Password:
P@ssw0rd
- Key for two factor authenticator App:
6jm7n6xwitpjooh7ihewyyzeux7aqmw2
C# on .NET Core 2.0 + xUnit + Selenium
Once you should build the test program before configure it.
> cd OTP2FAAuthWebAppDemo.E2ETest
> dotnet build
After building success, appSettings.Development.json
will generated.
Then, edit appSettings.Development.json
and set the browser used for testing to "usingDriver" attribute.
You can choose for "usingDriver" setting from one of "Chrome", "Firefox", "Edge", and "IE".
{
...
"test": {
"usingDriver": "(set using Selenium WebDriver name)", // <- Here!
...
}
}
After save it, run the test with following command.
> dotnet xunit
Powered by Otp.NET
using OtpNet;
...
var otpKeyStr = "6jm7n6xwitpjooh7ihewyyzeux7aqmw2";
var otpKeyBytes = Base32Encoding.ToBytes(otpKeyStr);
var otp = new Totp(otpKeyBytes);
var twoFactorCode = otp.ComputeTotp(); // <- got 2FA coed at this time!