diff --git a/Google.Authenticator.Tests/QRCodeTest.cs b/Google.Authenticator.Tests/QRCodeAndSetupUrlTests.cs similarity index 79% rename from Google.Authenticator.Tests/QRCodeTest.cs rename to Google.Authenticator.Tests/QRCodeAndSetupUrlTests.cs index 1fa7fa7..95d23b0 100644 --- a/Google.Authenticator.Tests/QRCodeTest.cs +++ b/Google.Authenticator.Tests/QRCodeAndSetupUrlTests.cs @@ -8,7 +8,7 @@ namespace Google.Authenticator.Tests { - public class QRCodeTest + public class QRCodeAndSetupUrlTests { [Theory] [InlineData("issuer", "otpauth://totp/issuer:a%40b.com?secret=ONSWG4TFOQ&issuer=issuer")] @@ -25,8 +25,13 @@ public void CanGenerateQRCode(string issuer, string expectedUrl) 2); var actualUrl = ExtractUrlFromQRImage(setupCodeInfo.QrCodeSetupImageUrl); + var rawUrl = setupCodeInfo.SetupUrl; - actualUrl.ShouldBe(expectedUrl); + Assert.Multiple(() => + { + actualUrl.ShouldBe(expectedUrl, "QR Code Url is not as expected"); + rawUrl.ShouldBe(expectedUrl, "SetupUrl is not as expected"); + }); } [Theory] @@ -44,8 +49,13 @@ public void CanGenerateSHA256QRCode(string issuer, string expectedUrl) 2); var actualUrl = ExtractUrlFromQRImage(setupCodeInfo.QrCodeSetupImageUrl); + var rawUrl = setupCodeInfo.SetupUrl; - actualUrl.ShouldBe(expectedUrl); + Assert.Multiple(() => + { + actualUrl.ShouldBe(expectedUrl, "QR Code Url is not as expected"); + rawUrl.ShouldBe(expectedUrl, "SetupUrl is not as expected"); + }); } [Theory] @@ -63,8 +73,13 @@ public void CanGenerateSHA512QRCode(string issuer, string expectedUrl) 2); var actualUrl = ExtractUrlFromQRImage(setupCodeInfo.QrCodeSetupImageUrl); + var rawUrl = setupCodeInfo.SetupUrl; - actualUrl.ShouldBe(expectedUrl); + Assert.Multiple(() => + { + actualUrl.ShouldBe(expectedUrl, "QR Code Url is not as expected"); + rawUrl.ShouldBe(expectedUrl, "SetupUrl is not as expected"); + }); } private static string ExtractUrlFromQRImage(string qrCodeSetupImageUrl) diff --git a/Google.Authenticator/SetupCode.cs b/Google.Authenticator/SetupCode.cs index 7964d14..ad90cab 100644 --- a/Google.Authenticator/SetupCode.cs +++ b/Google.Authenticator/SetupCode.cs @@ -9,13 +9,19 @@ public class SetupCode /// public string QrCodeSetupImageUrl { get; internal set; } + /// + /// The Raw otp:// url + /// + public string SetupUrl { get; internal set; } + public SetupCode() { } - public SetupCode(string account, string manualEntryKey, string qrCodeSetupImageUrl) + public SetupCode(string account, string manualEntryKey, string qrCodeSetupImageUrl, string setupUrl) { Account = account; ManualEntryKey = manualEntryKey; QrCodeSetupImageUrl = qrCodeSetupImageUrl; + SetupUrl = setupUrl; } } } \ No newline at end of file diff --git a/Google.Authenticator/TwoFactorAuthenticator.cs b/Google.Authenticator/TwoFactorAuthenticator.cs index 50dbb24..1060387 100644 --- a/Google.Authenticator/TwoFactorAuthenticator.cs +++ b/Google.Authenticator/TwoFactorAuthenticator.cs @@ -98,7 +98,8 @@ public SetupCode GenerateSetupCode(string issuer, return new SetupCode( accountTitleNoSpaces, encodedSecretKey.Trim('='), - generateQrCode ? GenerateQrCodeUrl(qrPixelsPerModule, provisionUrl) : ""); + generateQrCode ? GenerateQrCodeUrl(qrPixelsPerModule, provisionUrl) : "", + provisionUrl); } private static string GenerateQrCodeUrl(int qrPixelsPerModule, string provisionUrl) diff --git a/build/azure-pipeline.yaml b/build/azure-pipeline.yaml index c3b75c8..074a766 100644 --- a/build/azure-pipeline.yaml +++ b/build/azure-pipeline.yaml @@ -35,6 +35,18 @@ jobs: - script: dotnet build ./Google.Authenticator.Tests/Google.Authenticator.Tests.csproj --configuration $(buildConfiguration) --no-restore --no-dependencies displayName: build tests + - task: UseDotNet@2 + displayName: Install dotnet 6 + inputs: + packageType: sdk + version: 6.x + + - task: UseDotNet@2 + displayName: Install dotnet 7 + inputs: + packageType: sdk + version: 7.x + - task: DotNetCoreCLI@2 displayName: test inputs: