@@ -169,11 +169,13 @@ def test_cgi_session_specify_session_key
169169 session . close
170170 end
171171
172- def test_cgi_session_filestore_digest
172+ def test_cgi_session_filestore_path
173173 session_id = "banana"
174174 path_default = session_file_store_path ( "tmpdir" => @session_dir , "session_id" => session_id )
175+ assert_session_filestore_path ( path_default )
175176 assert_equal path_default , session_file_store_path ( "tmpdir" => @session_dir , "session_id" => session_id )
176177 path_sha512 = session_file_store_path ( "tmpdir" => @session_dir , "session_id" => session_id , "digest" => "SHA512" )
178+ assert_session_filestore_path ( path_default )
177179 assert_not_equal path_sha512 , path_default
178180
179181 path = session_file_store_path ( "tmpdir" => @session_dir , "session_id" => session_id , "digest" => Digest ::SHA256 )
@@ -184,6 +186,14 @@ def test_cgi_session_filestore_digest
184186
185187 private
186188
189+ def assert_session_filestore_path ( path , dir : @session_dir , prefix : "cgi_sid_" , suffix : nil )
190+ base = File . basename ( path )
191+ assert_equal dir , File . dirname ( path )
192+ assert_operator base , :start_with? , prefix if prefix
193+ assert_operator base , :end_with? , suffix if suffix
194+ path
195+ end
196+
187197 def session_file_store_path ( options )
188198 cgi = Object . new
189199 session = CGI ::Session . new ( cgi , options )
0 commit comments