zombocom/derailed_benchmarks

Authentication with sorcery

Opened this issue · 4 comments

Hello, I am trying to setup a sorcery (https://github.com/Sorcery/sorcery) to use derailed benchmarks, but struggling with it, i try do setup this code inside perf.rake:

class SorceryAuth < DerailedBenchmarks::AuthHelper
  def setup
    require 'sorcery'
    require 'sorcery/controller'
    extend ::Sorcery::TestHelpers::Rails::Controller
    extend ::Sorcery::TestHelpers::Rails::Request
    extend ::Sorcery::TestHelpers::Rails::Integration
    extend ::Sorcery::Controller::InstanceMethods
    # initialize code here
  end

  def call(env)
    # log something in on each request
    login(User.first.email, '1234', remember_me = false)
    app.call(env)
  end
end

DerailedBenchmarks.auth = SorceryAuth.new

When i run:

USE_AUTH=true PATH_TO_HIT='/library/library/livros' derailed exec perf:stackprof

I receive the following error:

/home/pedro/.asdf/installs/ruby/2.7.2/lib/ruby/gems/2.7.0/gems/sorcery-0.16.3/lib/sorcery/controller.rb:52:in `block in login': undefined local variable or method `session' for #<SorceryAuth:0x0000556237a2a078> (NameError)
Did you mean?  old_session

Thanks for the help!!

If you can provide an https://www.codetriage.com/example_app that reproduces the problem then maybe I can take a look.

@schneems thanks for the support, i will provide soon

Hello @schneems , i have build the repo to reproduce the problem (https://github.com/PedroAugustoRamalhoDuarte/derailed_benchmarks_sorcery), try to run: USE_AUTH=true derailed exec perf:stackprof

Sorcery have 3 types of test helpers (https://github.com/Sorcery/sorcery/wiki/Testing-Rails), i have tried with all options and didn't succeed, each one with a different problem.

The best way is using auto_login from sorcery, but its uses sessions and i think is not enable when we execute derailed, because this error:

undefined local variable or method `session' for #<SorceryAuth:0x00007f259719d138 @app=#<DerailedBencgmarksSorcery::Application>> (NameError)