File tree Expand file tree Collapse file tree 3 files changed +39
-7
lines changed
src/LinkDotNet.Blog.Web/Shared
tests/LinkDotNet.Blog.UnitTests/Web Expand file tree Collapse file tree 3 files changed +39
-7
lines changed Original file line number Diff line number Diff line change 22 <Authorized >
33 <li class =" nav-item dropdown" >
44 <a class =" nav-link dropdown-toggle" href =" #" id =" navbarDropdown" role =" button" data-bs-toggle =" dropdown"
5- aria-expanded =" false" >
5+ aria-expanded =" false" >
66 Admin
77 </a >
88 <ul class =" dropdown-menu original" aria-labelledby =" navbarDropdown" >
1919 <li ><a class =" dropdown-item" target =" _blank" href =" https://github.com/linkdotnet/Blog/releases" >Version 2.12</a ></li >
2020 </ul >
2121 </li >
22- <li class =" nav-item" ><a class =" nav-link" href =" logout" >Log out</a ></li >
22+ <li class =" nav-item" ><a class =" nav-link" href =" logout?redirectUri=@CurrentUri " >Log out</a ></li >
2323 </Authorized >
2424 <NotAuthorized >
25- <li class =" nav-item" ><a class =" nav-link" href =" login?redirectUri=/ " >Log in</a ></li >
25+ <li class =" nav-item" ><a class =" nav-link" href =" login?redirectUri=@CurrentUri " >Log in</a ></li >
2626 </NotAuthorized >
27- </AuthorizeView >
27+ </AuthorizeView >
28+
29+ @code {
30+ [Parameter ]
31+ public string CurrentUri { get ; set ; } = string .Empty ;
32+
33+ }
Original file line number Diff line number Diff line change 2929 me </a ></li >
3030 }
3131
32- <AccessControl ></AccessControl >
32+ <AccessControl CurrentUri = " @navigationManager.Uri " ></AccessControl >
3333 <li class =" nav-item d-flex" >
3434 <SearchInput SearchEntered =" NavigateToSearchPage" ></SearchInput >
3535 </li >
Original file line number Diff line number Diff line change 1- using Bunit ;
1+ using AngleSharp . Html . Dom ;
2+ using AngleSharpWrappers ;
3+ using Bunit ;
24using Bunit . TestDoubles ;
35using FluentAssertions ;
46using LinkDotNet . Blog . Web . Shared ;
@@ -29,4 +31,28 @@ public void ShouldShowLogoutAndAdminWhenLoggedIn()
2931 cut . FindAll ( "a:contains('Admin')" ) . Should ( ) . HaveCount ( 1 ) ;
3032 cut . FindAll ( "a:contains('Log out')" ) . Should ( ) . HaveCount ( 1 ) ;
3133 }
32- }
34+
35+ [ Fact ]
36+ public void LoginShouldHaveCurrentUriAsRedirectUri ( )
37+ {
38+ const string currentUri = "http://localhost/test" ;
39+ this . AddTestAuthorization ( ) ;
40+
41+ var cut = RenderComponent < AccessControl > (
42+ p => p . Add ( s => s . CurrentUri , currentUri ) ) ;
43+
44+ ( ( IHtmlAnchorElement ) cut . Find ( "a:contains('Log in')" ) . Unwrap ( ) ) . Href . Should ( ) . Contain ( currentUri ) ;
45+ }
46+
47+ [ Fact ]
48+ public void LogoutShouldHaveCurrentUriAsRedirectUri ( )
49+ {
50+ const string currentUri = "http://localhost/test" ;
51+ this . AddTestAuthorization ( ) . SetAuthorized ( "steven" ) ;
52+
53+ var cut = RenderComponent < AccessControl > (
54+ p => p . Add ( s => s . CurrentUri , currentUri ) ) ;
55+
56+ ( ( IHtmlAnchorElement ) cut . Find ( "a:contains('Log out')" ) . Unwrap ( ) ) . Href . Should ( ) . Contain ( currentUri ) ;
57+ }
58+ }
You can’t perform that action at this time.
0 commit comments