[InlineData("otpauth://totp/SomeLabel?secret=ABABABABABABABAB&algorithm=SHA256&digits=d")] //Digits not a number public void InvalidUriCreatesNullGenerator(string uriString) { var uri = new Uri(uriString); var model = OTPUriConverter.OTPGeneratorFromUri(uri); Assert.Null(model); }
public void GenerateUriWorks() { var reference = "otpauth://totp/Test:Alice Loller%40test.com?secret=ABABABABABABABAB&algorithm=SHA256&digits=6&issuer=Test"; var uri = OTPUriConverter.UriFromOTPGenerator(SampleGenerator); Assert.Equal(reference, uri.ToString()); }
public void LabelAndIssuerAreCorrectlyParsed(string uriString, string expectedLabel, string expectedIssuer) { var uri = new Uri(uriString); var model = OTPUriConverter.OTPGeneratorFromUri(uri); Assert.Equal(expectedLabel, model.Label); Assert.Equal(expectedIssuer, model.Issuer); }
public void InitializeFromUriWorks() { var generatedUri = OTPUriConverter.UriFromOTPGenerator(SampleGenerator); var model = OTPUriConverter.OTPGeneratorFromUri(generatedUri); Assert.NotNull(model); Assert.NotNull(model.Label); Assert.Equal(SampleGenerator.Label, model.Label); Assert.NotNull(SampleGenerator.Secret); Assert.Equal(SampleGenerator.Secret, model.Secret); Assert.Equal(SampleGenerator.NumDigits, model.NumDigits); Assert.NotEmpty(model.AlgorithmName); Assert.Equal(SampleGenerator.AlgorithmName, model.AlgorithmName); Assert.NotNull(model.Issuer); Assert.Equal(SampleGenerator.Issuer, model.Issuer); Assert.Equal(SampleGenerator.AllowExporting, model.AllowExporting); Assert.NotNull(model.Uid); Assert.NotEqual(SampleGenerator.Uid, model.Uid); }