Comments (10)
Hi @nicolo,
This is something I should have documented long before. (You ran the test suite before without issues, right?)
Solution
# to remove all the dummy app files that are not essential (i.e. under version control)
# remove the entire dummy app
rm -rf spec/dummy
# restore the minimal dummy app
git checkout spec/dummy
# Note: the minimal dummy app should not be modified, that's why `spec/dummy` is ignored.
Explanation
The test suite re-generates the dummy app on each scenario. The dummy app which is part of the repo is the minimal dummy app, and it is required to start running the Cucumber scenarii.
What appends is that after re-generating the dummy app a few times, some new files are generated (including those from the Devise installation) which make sense in their respective scenarii, but prevent the test suite to start once their context has been dropped. The solution consists in dropping them by leveraging the Git capabilities.
from simple_token_authentication.
@gonzalo-bulnes Thanks for the reply. This got me a little further.
The test suite now starts running, but now I'm seeing this failure.
And User acts_as_token_authenticatable
# features/step_definitions/dummy_app_steps.rb:246
expected app/models/user.rb to be present (RuntimeError)
features/any_controller_which_acts_as_token_authentication_handler_requires_authentication_from_the_correspoding_model.feature:17:in And User
acts_as_token_authenticatable`'
from simple_token_authentication.
At this point I need to know if you've modified the scenario which is failing. If you did, note that the step which is failing depends on the spec/dummy/app/models/user.rb
file to exist (source). In the original scenario, that file, i.e theUser
model, is created by the step which installs Devise (source).
If you were using another model, say Admin
, you should keep both steps coherent:
Given I have a dummy app with a Devise-enabled Admin
# ...
And Admin `acts_as_token_authenticatable`
Do these observations help you?
from simple_token_authentication.
I have not modified anything as of yet. I'm trying to get the test suite to pass before touching the code.
from simple_token_authentication.
@gonzalo-bulnes am I missing any other setup steps to get this to work? I haven't changed any code yet. Could it be an issue with using Ruby 2.1.2?
from simple_token_authentication.
Hi @nicolo!
Could #72 have any relation with the issue?
I really don't think the Ruby version to be involved in this, I see no reason for that. (And I just ran the v1.5.0 test suite with Ruby 2.1.2 to be sure.) The protocol you described seems perfectly fine to me:
# clone the repository in a temporary directory
mkdir tmp && cd tmp
git clone [email protected]:gonzalo-bulnes/simple_token_authentication.git
# use a clean gemset
cd simple_token_authentication
rvm use --create 2.1.2@tmp_simple_token_authentication
bundle install
# run the test suite
rake
from simple_token_authentication.
Implementing the fix in #72 seemed to help. Down to failures from 19, but I'm now getting the error:
PrivatePosts GET /private_posts since User and Admin act as token authenticatable and PrivatePostsController acts_as_token_authentication_handler_for
both when User credentials are provided token authentication is performed for that User
Failure/Error: lambda do
expected RuntimeError with "sign_in
was called with resource or scope User
.", got #<RuntimeError: authenticate_admin!
was called.> with backtrace:
# ./app/controllers/application_controller.rb:23:in authenticate_admin!' # /Users/nicolo/projects/simple_token_authentication/lib/simple_token_authentication/acts_as_token_authentication_handler.rb:21:in
call'
# /Users/nicolo/projects/simple_token_authentication/lib/simple_token_authentication/acts_as_token_authentication_handler.rb:21:in authenticate_entity!' # /Users/nicolo/projects/simple_token_authentication/lib/simple_token_authentication/acts_as_token_authentication_handler.rb:126:in
authenticate_admin_from_token!'
# ./spec/requests/private_posts_spec.rb:47:in block (7 levels) in <top (required)>' # ./spec/requests/private_posts_spec.rb:46:in
block (6 levels) in <top (required)>'
# ./spec/requests/private_posts_spec.rb:46:in `block (6 levels) in <top (required)>'
Do the tests not run in OSX? Should I try using my linux machine?
from simple_token_authentication.
Hi @nicolo! Of course you can use another machine, but I wish we could fix the MacOS X issues... What do you think?
... OK, I think I know where that error comes from:
expected RuntimeError with "sign_in was called with resource or scope User.", got #
The failing scenario uses a variant of the step that was fixed by #72. It also uses sed
and the same fix is missing here.
I'm sorry for the duplication there, I had doubts about that, but considering that the Cucumber steps mecanism would be unfamiliar to most users, I finally decided to favor readability over cleanliness.
from simple_token_authentication.
Sorry for the slow response. Those fixes got the tests to work. Thanks!
from simple_token_authentication.
Yay! Very good news! Thanks for the feedback! :D
from simple_token_authentication.
Related Issues (20)
- Is that gem work with API? HOT 4
- Mongoid does support Rails 6 now/soon HOT 3
- uninitialized constant SimpleTokenAuthentication::Adapters HOT 5
- Gem doesn't protect data?
- separate registration and signin so no token is received by client when registering
- how to auth 2 different models with same alias ?
- acts_as_token_authenticatable causes a DEPRECATION WARNING
- Q: How to do not require user_email? HOT 1
- Getting 401 unauthorized Error
- Where should I store the token on the frontend? HOT 3
- Entering fallback! with token_correct? set to true HOT 1
- 406 Errors on Authentication Test
- The mongoid range of supported versions needs review
- Discussions are set up! HOT 1
- Identify support requests, feature requests in issues and pull requests HOT 1
- Update the contributing guidelines to mention Discussions etc.
- Add (actual) example of maintenance trade-off for discussion HOT 1
- split responsibilities of acts_as_token_authentication_handler_for method HOT 1
- Rails 7 support? HOT 30
- Can we use JWT as a user token?
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from simple_token_authentication.