[squeak-dev] The Trunk: WebClient-Tests-mt.63.mcz

commits at source.squeak.org commits at source.squeak.org
Wed Mar 15 13:51:38 UTC 2023


Marcel Taeumel uploaded a new version of WebClient-Tests to project The Trunk:
http://source.squeak.org/trunk/WebClient-Tests-mt.63.mcz

==================== Summary ====================

Name: WebClient-Tests-mt.63
Author: mt
Time: 15 March 2023, 2:51:38.127794 pm
UUID: 1e30ab8e-6d62-884a-87dd-95c7b23ad15e
Ancestors: WebClient-Tests-ct.62

Remove a dependency to MorphicExtras

=============== Diff against WebClient-Tests-ct.62 ===============

Item was changed:
  ----- Method: WebClientServerTest>>testMultipartFiles (in category 'tests - fields') -----
  testMultipartFiles
  	"Test client and server handling multipart/form-data fields for file uploads"
  
  	| resp request document firstPart |
  	server addService: '/fields' action:[:req | 
  		request := req.
  		req send200Response: (String streamContents:[:s|
  			req fields keys asArray sort do:[:key | s cr; nextPutAll: key,'=', (req fields at: key)].
  		]).
  	].
  
  	document := MIMEDocument 
  				contentType: 'text/webclient-test'
  				content: 'Hello World, this is a sample file'
+ 				url: FileDirectory default asUrl asString,'test.txt'.
- 				url: FileDirectory default url,'test.txt'.
  
  	resp := WebClient httpPost: self localHostUrl,'/fields'  multipartFields: {
  		'upload' -> document.
  	}.
  	"First test just verifies that uploaded documents look just like other fields"
  	self assert: resp code = 200.
  	self assert: resp content = '
  upload=Hello World, this is a sample file'.
  
  	"Second test verifies that we have the additional data from a file upload"
  	firstPart := true.
  	request multipartFieldsDo:[:headers :params :content|
  		self assert: firstPart. "should only have one part"
  		self assert: (params at: 'name') = 'upload'.
  		self assert: (params at: 'filename') = 
  						(FileDirectory default fullNameFor: 'test.txt').
  		self assert: (headers at: 'content-type') = 'text/webclient-test'.
  		firstPart := false.
  	].
  !

Item was changed:
  ----- Method: WebClientServerTest>>testMultipartFiles2 (in category 'tests - fields') -----
  testMultipartFiles2
  	"Same as testMultpartFiles but this time using HTTPSocket API"
  
  	| resp request document firstPart fields |
  	server addService: '/fields' action:[:req | 
  		request := req.
  		req send200Response: (String streamContents:[:s|
  			req fields keys asArray sort do:[:key | s cr; nextPutAll: key,'=', (req fields at: key)].
  		]).
  	].
  
  	document := MIMEDocument 
  				contentType: 'text/webclient-test'
  				content: 'Hello World, this is a sample file'
+ 				url: FileDirectory default asUrl asString,'test.txt'.
- 				url: FileDirectory default url,'test.txt'.
  
  	fields := Dictionary new.
  	fields at: 'upload' put: {document}.
  
  	"Make sure we're *actually* using HTTPSocket and not WebClient
  	(if it's registered as HTTP handler in HTTPSocket)"
  	(HTTPSocket respondsTo: #httpRequestHandler:) ifTrue:[
  		| oldHandler |
  		oldHandler := HTTPSocket httpRequestHandler.
  		[HTTPSocket httpRequestHandler: nil.
  		resp := (self localHostUrl,'/fields') asUrl postMultipartFormArgs: fields.
  		] ensure:[HTTPSocket httpRequestHandler: oldHandler].
  	] ifFalse:[
  		resp := (self localHostUrl,'/fields') asUrl postMultipartFormArgs: fields.
  	].
  
  	"First test just verifies that uploaded documents look just like other fields"
  	self assert: resp content = '
  upload=Hello World, this is a sample file'.
  
  	"Verifies that we have the additional data from a file upload"
  	firstPart := true.
  	request multipartFieldsDo:[:headers :params :content|
  		self assert: firstPart. "should only have one part"
  		self assert: (params at: 'name') = 'upload'.
  		self assert: (params at: 'filename') = 
  						(FileDirectory default fullNameFor: 'test.txt').
  		self assert: (headers at: 'content-type') = 'text/webclient-test'.
  		firstPart := false.
  	].
  !



More information about the Squeak-dev mailing list