The Trunk: WebClient-Tests-topa.55.mcz

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

The Trunk: WebClient-Tests-topa.55.mcz

commits-2
Tobias Pape uploaded a new version of WebClient-Tests to project The Trunk:
http://source.squeak.org/trunk/WebClient-Tests-topa.55.mcz

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

Name: WebClient-Tests-topa.55
Author: topa
Time: 28 March 2018, 9:47:24.339011 pm
UUID: af4b368e-87fd-4823-a3bd-86ef1d76eb7d
Ancestors: WebClient-Tests-ul.54

test token-based Bearer/OAuth2 auth

=============== Diff against WebClient-Tests-ul.54 ===============

Item was changed:
  ----- Method: WebClientServerTest>>setUp (in category 'setup') -----
  setUp
  server := WebServer new listenOn: self port.
  server passwordAt: 'user' realm: 'test' put: 'pass'.
+ server addToken: 'shushitsissupersecret' toRealm: 'test'.!
- !

Item was added:
+ ----- Method: WebClientServerTest>>testBerarerAuth (in category 'tests - auth') -----
+ testBerarerAuth
+ "Test client and server berarer auth"
+
+ | resp reqHeader |
+ server addService: '/test/auth' action:[:req |
+ server authenticate: req realm: 'test' methods: #(bearer) do:[
+ reqHeader := req headerAt: 'Authorization'.
+ req send200Response: 'ok'] ].
+
+ resp := WebClient new httpGet: self localHostUrl, '/test/auth'.
+ self assert: resp code = 401.
+
+ [resp := WebClient httpGet: self localHostUrl, '/test/auth']
+ on: WebAuthRequired do:[:ex| ex token: 'ihavenoideawhatiamdoing'].
+ self assert: resp code = 401.
+
+ [resp := WebClient httpGet: self localHostUrl, '/test/auth']
+ on: WebAuthRequired do:[:ex| ex token:'shushitsissupersecret'].
+ self assert: resp code = 200.
+ self assert: resp content = 'ok'.
+ self assert: (reqHeader beginsWith: 'Bearer ').
+ !