An invoice contained an empty oddb2c.csv file. Why?
Uninstalled rbenv from oddb-ci2. Changed /service/sandoz.bbmb.ch/run to contain
cd /var/www/sandoz.bbmb.ch exec sudo -u bbmb /usr/local/bin/ruby231 -I/var/www/sandoz.bbmb.ch/lib -rydim/invoice /usr/local/bin/bbmbd config=/var/www/sandoz.bbmb.ch/etc/config.yml
to avoid error about the missing git repository.
Verified that the _session_id cookie is present after loading http://sandoz.bbmb.ngiger.ch/.
There are occurrences of 'cookie' in the test directory under /var/www/sandoz.bbmb.ch. But as test/selenium.rb is local copy of Selenium and test/stub/http_server.rb is the stub for the mod_ruby (desribed in the top of the file as "## compatibility-brainfuck for integrating Apache-SBSM-Requests with WEBrick") I must check with other means, whether cookies work or not.
After setting a pry debug at line 156 of /usr/local/lib64/ruby/gems/2.3.0/gems/sbsm-1.2.7/lib/sbsm/request.rb I started manually sudo -u bbmb /usr/local/bin/ruby231 -I/var/www/sandoz.bbmb.ch/lib -rydim/invoice /usr/local/bin/bbmbd config=/var/www/sandoz.bbmb.ch/etc/config.yml
. After the login I did not fall into the pry debug.
Setting pry breakpoints in lines 11 of /usr/local/lib64/ruby/gems/2.3.0/gems/sbsm-1.2.7/lib/cgi/drbsession.rb.
Last week I started debugging via a pry at line 19 in /usr/local/lib64/ruby/gems/2.3.0/gems/bbmb-2.0.1/lib/bbmb/html/state/login.rb.
Redoing I get
[1] pry(#<BBMB::Html::Util::Session>)> user_input(:email) => "admin@sandoz.ch" [2] pry(#<BBMB::Html::Util::Session>)> user_input(:pass) => "7289563ea270842e082c08199f07ed81" [3] pry(#<BBMB::Html::Util::Session>)> next From: /usr/local/lib/ruby/gems/2.3.0/gems/bbmb-2.0.2/lib/bbmb/html/util/session.rb @ line 21 BBMB::Html::Util::Session#login: 19: def login 20: @user = @app.login(user_input(:email), user_input(:pass)) => 21: @user.session = self if(@user.respond_to?(:session=)) 22: @user 23: end [3] pry(#<BBMB::Html::Util::Session>)> @user => #<BBMB::Html::Util::KnownUser:0x007f55b017c980 @auth_session=#<DRb::DRbObject:0x007f55b0162698 @ref=70036191732660, @uri="druby://localhost:12005">> [4] pry(#<BBMB::Html::Util::Session>)> @user.respond_to?(:session=) => false [5] pry(#<BBMB::Html::Util::Session>)> continue D, [2016-06-06T10:21:36.615860 #31577] DEBUG -- User: admin@sandoz.ch: allowed?(login, ch.bbmb.sandoz.Admin) -> true D, [2016-06-06T10:21:36.638994 #31577] DEBUG -- User: admin@sandoz.ch: allowed?(login, ch.bbmb.sandoz.Customer) -> false D, [2016-06-06T10:21:36.924016 #31577] DEBUG -- State: Customers#init: loaded 1661 customers in 0.28389s From: /usr/local/lib/ruby/gems/2.3.0/gems/bbmb-2.0.2/lib/bbmb/html/state/login.rb @ line 19 BBMB::Html::State::Login#login: <..> [1] pry(#<BBMB::Html::State::Login>)> step From: /usr/local/lib/ruby/gems/2.3.0/gems/bbmb-2.0.2/lib/bbmb/html/util/session.rb @ line 20 BBMB::Html::Util::Session#login: 19: def login => 20: @user = @app.login(user_input(:email), user_input(:pass)) [1] pry(#<BBMB::Html::Util::Session>)> @user.respond_to?(:session=) => false [2] pry(#<BBMB::Html::Util::Session>)> self.class => BBMB::Html::Util::Session
I suspect that with Ruby 1.8.6 @user hat a method session= and therefore the @user was set to self. Trying to set @user.session = self results in the following error
[3] pry(#<BBMB::Html::Util::Session>)> @user => #<BBMB::Html::Util::KnownUser:0x007f55b0cf3f48 @auth_session=#<DRb::DRbObject:0x007f55b0ce5448 @ref=70036191908700, @uri="druby://localhost:12005">> [4] pry(#<BBMB::Html::Util::Session>)> @user.session = self NoMethodError: undefined method `session=' for #<Yus::EntitySession:0x7f6524ae2aa0> from /usr/local/lib/ruby/gems/2.3.0/gems/bbmb-2.0.2/lib/bbmb/html/util/known_user.rb:43:in `remote_call'
The error is probably causes by on of the following reasons:
Installed cookie-inspector. which shows ERR_TO_MANY_REDIRECTS
After replacing most references from CGI to ::CGI in the sbsm files, I could see the cookie bbmb-barcodereader. Here the list of replaced occcurrences:
grep -rn '::CGI' /usr/local/lib64/ruby/gems/1.9.1/gems/sbsm-1.2.3/lib /usr/local/lib64/ruby/gems/1.9.1/gems/sbsm-1.2.3/lib/cgi/drbsession.rb:7:class ::CGI /usr/local/lib64/ruby/gems/1.9.1/gems/sbsm-1.2.3/lib/sbsm/request.rb:40: def initialize(drb_uri, html_version = "html4", cgiclass = ::CGI) /usr/local/lib64/ruby/gems/1.9.1/gems/sbsm-1.2.3/lib/sbsm/request.rb:149: 'database_manager' => ::CGI::Session::DRbSession, /usr/local/lib64/ruby/gems/1.9.1/gems/sbsm-1.2.3/lib/sbsm/request.rb:162: @session = ::CGI::Session.new(@cgi, args) /usr/local/lib64/ruby/gems/1.9.1/gems/sbsm-1.2.3/lib/sbsm/request.rb:196: (@cgi.params.has_key?("pretty")) ? ::CGI.pretty( res ) : res /usr/local/lib64/ruby/gems/1.9.1/gems/sbsm-1.2.3/lib/sbsm/request.rb:214: ::CGI::Cookie.new(cookie_hash).to_s /usr/local/lib64/ruby/gems/1.9.1/gems/sbsm-1.2.3/lib/sbsm/session.rb:54: @@cgi = ::CGI.new('html4') /usr/local/lib64/ruby/gems/1.9.1/gems/sbsm-1.2.3/lib/sbsm/session.rb:210: ::CGI.parse(::CGI.unescape(cuki_str)).each { |key, val| /usr/local/lib64/ruby/gems/1.9.1/gems/sbsm-1.2.3/lib/sbsm/lookandfeel.rb:77: args = args.collect { |value| ::CGI.escape(value.to_s) } /usr/local/lib64/ruby/gems/1.9.1/gems/sbsm-1.2.3/lib/sbsm/cgi.rb:29:class ::CGI /usr/local/lib64/ruby/gems/1.9.1/gems/sbsm-1.2.3/lib/sbsm/cgi.rb:39: '="' + ::CGI::escapeHTML(value) + '"' /usr/local/lib64/ruby/gems/1.9.1/gems/sbsm-1.2.3/lib/sbsm/trans_handler.rb:71: values.add(key.to_s, ::CGI.unescape(value.to_s)) /usr/local/lib64/ruby/gems/1.9.1/gems/sbsm-1.2.3/lib/sbsm/trans_handler.rb:86: ::CGI.unescape(pair.value.value.to_s)
ydim-html and bb have different method to establish a connection. Trying, whether I can create a similar setup to ydim-html. For this I have to
Made the adjustments. Now I have problems because I get the following error
In /usr/local/lib/ruby/gems/2.3.0/gems/bbmb-2.0.3/lib/bbmb/html/state/info.rb:7 /usr/local/lib/ruby/gems/2.3.0/gems/bbmb-2.0.3/lib/bbmb/html/state/info.rb:11:in `<module:State>': uninitialized constant SBSM::Global (NameError)
This stems from the fact that lib/bbmb/html/state/global.rb and lib/ydim/html/state/global.rb implment different methods.
If I move require 'bbmb/html/state/login'
to the end of lib/bbmb/html/state/global.rb I can avoid the uninitialized constant SBSM::Global. Looking at the next error about the LOOKANDFEEL. Now it starts up. It does not have the correct lnf and after a login I get undefined method `pagestep' for #<SBSM::UnknownUser:0x00000003426cd0>
Fixed the error with the lookandfeel. Now I am getting the correct login screen again:
But the pagestep error persists. Now I must have look how ydim handles this feature. After adding empty implementations for the following methods for the class SBSM::UnknownUser in lib/bbmb/html/util/known_user.rb
I could view the list of customers, but they are all of the class UnknownUser. There is still something fundamentally wrong!
Placed a pry debug at /usr/local/lib/ruby/gems/2.3.0/gems/bbmb-2.0.3/lib/bbmb/html/view/customers.rb @ line 122 BBMB::Html::View::CustomersComposite#customers. And I get
[1] pry(#<BBMB::Html::View::CustomersComposite>)> model.customers.first => #<BBMB::Model::Customer:0x000000029568c8 @address1="Boulevard de P\xC3\xA9rolles 6", @archive=#<ODBA::Stub:21672400#139367 @odba_class= @odba_container=21673060#139365>, @city="Fribourg", @current_order=#<ODBA::Stub:21672580#139451 @odba_class=BBMB::Model::Order @odba_container=21673060#139365>, @customer_id="4100609297", @ean13="7601001392335", @email=nil, @favorites=#<ODBA::Stub:21672980#139366 @odba_class=BBMB::Model::Order @odba_container=21673060#139365>, @fax="026 321 12 12", @firstname="xx", @lastname="zzz", @odba_id=139365, @odba_observers=[], @odba_persistent=true, @organisation="some SA", @phone_business="026 012345", @plz="1755", @protected={}, @quotas=#<ODBA::Stub:21672280#139368 @odba_class= @odba_container=21673060#139365>, @title="Docteur">
Setting a pry debug statement into /usr/local/lib/ruby/gems/2.3.0/gems/bbmb-2.0.3/lib/bbmb/util/server.rb:73 (login). This goes to /usr/local/lib/ruby/gems/2.3.0/gems/bbmb-2.0.3/lib/bbmb/html/state/login.rb:19 and calls trigger(:home)
But I still have no idea why while processing the request the user is a SBSM::UnkownUser.
List of customers appears now. Discovered that lib/bbmb/html/util/server.rb is not needed. Used the following patch. See Attach:0001-List-of-customers-is-displayed-now.patch.txt
But it does not work correctly, eg. navigation to http://sandoz.bbmb.ngiger.ch/de/customers/sortvalue/last_login does not sort by login.
Removing and reinstalling sbsm-1.2.3 to see whether the changes to ::CGI are required or not. No. It is not needed, neither are the monkey methods for SBSM::UnknownUser.
Todo for tomorrow:
needed?