view · edit · sidebar · attach · print · history

Index>

20161019-steinwies-rack-post

Summary

  • port sbsm/steinwies.ch to use the rack webserver. Fix handling POST requests
  • Keep in Mind

Commits

Index

port sbsm/steinwies.ch to use the rack webserver. Fix handling POST requests

Why does a POST request not return the correct content?

When running several unit test I sometimes receive errors like Address already in use - bind(2) for "localhost" port 10001 or problems removing /tmp/smb_lock. Why? Solved this problem by waiting for the drb_server to be ready with until @drb_server && @drb_server.alive? do sleep 0.005 end after calling DRb.start_service. Pushed the commit Reworked the unit test for rack

Improved the POST test by setting cookies with result = post '/hello/', "HTTP_COOKIE" => "_session_id=332b306f524c0cee31dddabe5bbaaaa". Now the session_id gets passed as a cookie. Do I have to add also a sbsm-persistent-cookie? Added it, but still getting wrong content.

Debugging with pry I see in sbsm/lib/sbsm/state.rb in the method trigger(event) that the event :confirm is triggered, but the self does not respond to it. Why? self is Steinwies::HomeState.

in sbsm/request.rb (method drb_process) added the lines

      cookie_input['_session_id'] = @session.session_id
      cookie_input['language'] = @cgi.params[ "rack.request.query_hash"]['language']

and now the response contains header-lines of type Set-Cookie. But it still does not return the correct confirm page.

Somehow I must extract event=confirm from the Rack::Request.env, which is e.g.

  request.env[ "rack.request.form_vars"]
   => "email=test%40user.org&anrede=Herr&name=Bond&vorname=James&telefon=&firma=MI6&ort=1234+name&bestell_diss=\n
      &bestell_pedi=&confirm=Weiter&text=Test-Mail.+Bitte+ignorieren&flavor=&language=en&event=confirm&state_id=40452440"

Tried various variants to generate good cookies. But now I think this should be okay.

Pushed commits:

But I must still solve the failing unit test, as shown by the travis-CI log https://travis-ci.org/ngiger/steinwies.ch/jobs/168970530

  Fabulous ru0mn in 0.333834s, 29.9550 runs/s, 158.7615 assertions/s.
  1) Failure:
  SteinwiesTest#test_kontakt_submit_kontakt [/home/travis/build/ngiger/steinwies.ch/test/feature/kontakt_test.rb:89]:
  Response body must include <Mail senden>.
  Expected: true
  Actual: false
view · edit · sidebar · attach · print · history
Page last modified on October 19, 2016, at 06:04 PM