File tree Expand file tree Collapse file tree 1 file changed +28
-0
lines changed Expand file tree Collapse file tree 1 file changed +28
-0
lines changed Original file line number Diff line number Diff line change 1+ // Licensed to the .NET Foundation under one or more agreements.
2+ // The .NET Foundation licenses this file to you under the Apache 2.0 License
3+ // See the LICENSE file in the project root for more information.
4+ // Maintainer: Argo Zhang([email protected] ) Website: https://www.blazor.zone 5+
6+ namespace UnitTest . Services ;
7+
8+ public class TotpServiceTest
9+ {
10+ [ Fact ]
11+ public void TotpService_Ok ( )
12+ {
13+ var serviceCollection = new ServiceCollection ( ) ;
14+ serviceCollection . AddBootstrapBlazor ( ) ;
15+
16+ var provider = serviceCollection . BuildServiceProvider ( ) ;
17+ var service = provider . GetRequiredService < ITotpService > ( ) ;
18+ var data = service . GenerateSecretKey ( ) ;
19+ Assert . Equal ( "OMM2LVLFX6QJHMYI" , data ) ;
20+ Assert . Equal ( "123456" , service . Compute ( "OMM2LVLFX6QJHMYI" ) ) ;
21+ Assert . Equal ( "otpauth://totp/BootstrapBlazor?secret=OMM2LVLFX6QJHMYI&issuer=Simulator" , service . GenerateOtpUri ( ) ) ;
22+ Assert . Empty ( service . GetSecretKeyBytes ( "" ) ) ;
23+ Assert . Equal ( 30 , service . GetRemainingSeconds ( ) ) ;
24+ Assert . False ( service . Verify ( "123456" ) ) ;
25+ Assert . Equal ( 30 , service . Instance . GetRemainingSeconds ( ) ) ;
26+ Assert . False ( service . Instance . Verify ( "123456" ) ) ;
27+ }
28+ }
You can’t perform that action at this time.
0 commit comments