@@ -52,7 +52,8 @@ async fn test_sessions(cptestctx: &ControlPlaneTestContext) {
5252 . expect ( "failed to clear cookie and 204 on logout" ) ;
5353
5454 // log in and pull the token out of the header so we can use it for authed requests
55- let session_token = create_console_session ( cptestctx) . await ;
55+ let session_cookie =
56+ format ! ( "session={}" , create_console_session( cptestctx) . await ) ;
5657
5758 let project_params = ProjectCreate {
5859 identity : IdentityMetadataCreateParams {
@@ -101,7 +102,7 @@ async fn test_sessions(cptestctx: &ControlPlaneTestContext) {
101102
102103 // now make same requests with cookie
103104 RequestBuilder :: new ( & testctx, Method :: POST , "/v1/projects" )
104- . header ( header:: COOKIE , & session_token )
105+ . header ( header:: COOKIE , & session_cookie )
105106 . body ( Some ( & project_params) )
106107 // TODO: explicit expect_status not needed. decide whether to keep it anyway
107108 . expect_status ( Some ( StatusCode :: CREATED ) )
@@ -110,7 +111,7 @@ async fn test_sessions(cptestctx: &ControlPlaneTestContext) {
110111 . expect ( "failed to create org with session cookie" ) ;
111112
112113 RequestBuilder :: new ( & testctx, Method :: GET , "/projects/whatever" )
113- . header ( header:: COOKIE , & session_token )
114+ . header ( header:: COOKIE , & session_cookie )
114115 . expect_console_asset ( )
115116 . execute ( )
116117 . await
@@ -124,7 +125,7 @@ async fn test_sessions(cptestctx: &ControlPlaneTestContext) {
124125
125126 // logout with an actual session should delete the session in the db
126127 RequestBuilder :: new ( & testctx, Method :: POST , "/v1/logout" )
127- . header ( header:: COOKIE , & session_token )
128+ . header ( header:: COOKIE , & session_cookie )
128129 . expect_status ( Some ( StatusCode :: NO_CONTENT ) )
129130 // logout also clears the cookie client-side
130131 . expect_response_header (
@@ -151,15 +152,15 @@ async fn test_sessions(cptestctx: &ControlPlaneTestContext) {
151152 // now the same requests with the same session cookie should 401/302 because
152153 // logout also deletes the session server-side
153154 RequestBuilder :: new ( & testctx, Method :: POST , "/v1/projects" )
154- . header ( header:: COOKIE , & session_token )
155+ . header ( header:: COOKIE , & session_cookie )
155156 . body ( Some ( & project_params) )
156157 . expect_status ( Some ( StatusCode :: UNAUTHORIZED ) )
157158 . execute ( )
158159 . await
159160 . expect ( "failed to get 401 for unauthed API request" ) ;
160161
161162 RequestBuilder :: new ( & testctx, Method :: GET , "/projects/whatever" )
162- . header ( header:: COOKIE , & session_token )
163+ . header ( header:: COOKIE , & session_cookie )
163164 . expect_status ( Some ( StatusCode :: FOUND ) )
164165 . execute ( )
165166 . await
@@ -173,8 +174,9 @@ async fn expect_console_page(
173174) {
174175 let mut builder = RequestBuilder :: new ( testctx, Method :: GET , path) ;
175176
176- if let Some ( session_token) = session_token {
177- builder = builder. header ( http:: header:: COOKIE , & session_token)
177+ if let Some ( token) = session_token {
178+ builder =
179+ builder. header ( http:: header:: COOKIE , & format ! ( "session={token}" ) )
178180 }
179181
180182 let console_page = builder
@@ -954,13 +956,13 @@ async fn test_session_idle_timeout_deletes_session() {
954956 let testctx = & cptestctx. external_client ;
955957
956958 // Start session
957- let session_cookie = create_console_session ( & cptestctx) . await ;
959+ let session_token = create_console_session ( & cptestctx) . await ;
958960
959961 // sleep here not necessary given TTL of 0
960962
961963 // Make a request with the expired session cookie
962964 let me_response = RequestBuilder :: new ( testctx, Method :: GET , "/v1/me" )
963- . header ( header:: COOKIE , & session_cookie )
965+ . header ( header:: COOKIE , & format ! ( "session={}" , session_token ) )
964966 . expect_status ( Some ( StatusCode :: UNAUTHORIZED ) )
965967 . execute ( )
966968 . await
@@ -977,10 +979,9 @@ async fn test_session_idle_timeout_deletes_session() {
977979 let opctx =
978980 OpContext :: for_tests ( cptestctx. logctx . log . new ( o ! ( ) ) , datastore. clone ( ) ) ;
979981
980- let token = session_cookie. strip_prefix ( "session=" ) . unwrap ( ) ;
981982 let db_token_error = nexus
982983 . datastore ( )
983- . session_lookup_by_token ( & opctx, token . to_string ( ) )
984+ . session_lookup_by_token ( & opctx, session_token )
984985 . await
985986 . expect_err ( "session should be deleted" ) ;
986987 assert_matches:: assert_matches!(
0 commit comments