@@ -105,12 +105,100 @@ public async Task Ensure_that_OnRedirectToIdentityProviderForSignOut_clears_sess
105105 scheme ,
106106 oidcOptions ,
107107 new AuthenticationProperties ( )
108+ )
109+ {
110+ ProtocolMessage = new OpenIdConnectMessage
111+ {
112+ PostLogoutRedirectUri = "https://test-oidc.signin" ,
113+ } ,
114+ } ;
115+
116+ // Act
117+ await oidcOptions . Events . OnRedirectToIdentityProviderForSignOut ( redirectContext ) ;
118+
119+ // Assert
120+ mockSession . Received ( 1 ) . Clear ( ) ;
121+ }
122+
123+ [ Fact ]
124+ public async Task Ensure_that_OnRedirectToIdentityProviderForSignOut_logout_redirect_uri_is_https ( )
125+ {
126+ // Arrange
127+ var services = new Microsoft . Extensions . DependencyInjection . ServiceCollection ( ) ;
128+ using var configuration = BuildConfiguration ( ) ;
129+ services . AddDsiAuthentication ( configuration ) ;
130+ var provider = services . BuildServiceProvider ( ) ;
131+
132+ var oidcOptions = provider
133+ . GetRequiredService < IOptionsMonitor < OpenIdConnectOptions > > ( )
134+ . Get ( OpenIdConnectDefaults . AuthenticationScheme ) ;
135+
136+ var mockSession = Substitute . For < ISession > ( ) ;
137+ var httpContext = new DefaultHttpContext { Session = mockSession } ;
138+
139+ var scheme = new AuthenticationScheme (
140+ OpenIdConnectDefaults . AuthenticationScheme ,
141+ OpenIdConnectDefaults . AuthenticationScheme ,
142+ typeof ( OpenIdConnectHandler )
108143 ) ;
109144
145+ var redirectContext = new RedirectContext (
146+ httpContext ,
147+ scheme ,
148+ oidcOptions ,
149+ new AuthenticationProperties ( )
150+ )
151+ {
152+ ProtocolMessage = new OpenIdConnectMessage
153+ {
154+ PostLogoutRedirectUri = "http://test-oidc.signin" ,
155+ } ,
156+ } ;
157+
110158 // Act
111159 await oidcOptions . Events . OnRedirectToIdentityProviderForSignOut ( redirectContext ) ;
112160
113161 // Assert
114162 mockSession . Received ( 1 ) . Clear ( ) ;
163+ redirectContext . ProtocolMessage . PostLogoutRedirectUri . ShouldBe ( "https://test-oidc.signin" ) ;
164+ }
165+
166+ [ Fact ]
167+ public async Task Ensure_that_OnRedirectToIdentityProvider_redirect_uri_is_https ( )
168+ {
169+ // Arrange
170+ var services = new Microsoft . Extensions . DependencyInjection . ServiceCollection ( ) ;
171+ using var configuration = BuildConfiguration ( ) ;
172+ services . AddDsiAuthentication ( configuration ) ;
173+ var provider = services . BuildServiceProvider ( ) ;
174+
175+ var oidcOptions = provider
176+ . GetRequiredService < IOptionsMonitor < OpenIdConnectOptions > > ( )
177+ . Get ( OpenIdConnectDefaults . AuthenticationScheme ) ;
178+
179+ var mockSession = Substitute . For < ISession > ( ) ;
180+ var httpContext = new DefaultHttpContext { Session = mockSession } ;
181+
182+ var scheme = new AuthenticationScheme (
183+ OpenIdConnectDefaults . AuthenticationScheme ,
184+ OpenIdConnectDefaults . AuthenticationScheme ,
185+ typeof ( OpenIdConnectHandler )
186+ ) ;
187+
188+ var redirectContext = new RedirectContext (
189+ httpContext ,
190+ scheme ,
191+ oidcOptions ,
192+ new AuthenticationProperties ( )
193+ )
194+ {
195+ ProtocolMessage = new OpenIdConnectMessage { RedirectUri = "http://test-oidc.signin" } ,
196+ } ;
197+
198+ // Act
199+ await oidcOptions . Events . OnRedirectToIdentityProvider ( redirectContext ) ;
200+
201+ // Assert
202+ redirectContext . ProtocolMessage . RedirectUri . ShouldBe ( "https://test-oidc.signin" ) ;
115203 }
116204}
0 commit comments