-
Notifications
You must be signed in to change notification settings - Fork 50
[Test Post] Access to a running Whenbot app must be password protected #1
Description
Since Whenbot will be hosted on Heroku, the app itself should be protected by a login and password.
As Tristan suggested below, we'll be going with a single password field for authentication.
Requirements
- When the User runs the
installcommand, they're asked to include their password.- E.g.
rails generate whenbot:install --password=my_password
- E.g.
- There should be a method that can be run as a
before_filterin the controllers to ensure that a user is logged in. - When the User visits any page without an active, authenticated session, they are redirected to an unlock page that requests their password.
- The password must be encrypted when stored in the database.
- Bonus: Allow the user to also include their email address during setup, so that Whenbot can email the User if needed.
- E.g.
rails generate whenbot:install --email=me@example.com --password=my_password
- E.g.
Feel free to ask any questions that you may have.
This feature should be developed via Test Driven Development. Either way, a proper set of tests is required for this to be pulled into the main repository.
Contributing
If you'd like to work on this, and no-one else has assigned this task to themselves yet, assign this task to yourself. You can do this by clicking the gear icon beside the "No on is assigned" text above, and selecting your name.
If someone else beat you to it, do not reassign the task to yourself. Instead, check the comments (below) to see if they added a comment that says "Accepting teammates."
If you see "Accepting teammates" and would to join in, add a post here to say so and connect. You can also try reaching out to the original assignee via a private message or email.
Working in pairs or teams is encouraged. If you managed to snag this task by being the first to assign it to yourself, consider working with a teammate or two. To let people know you'd like to team up, add a comment below saying "Accepting teammates."
Keep an eye on new comments for this task, there may be someone reaching out to work with you.
Implementation
This can be implemented anyway you want. You may choose to use a pre-existing solution, such as Devise, or roll your own.
If you're interested in writing password protected login from scratch, read sections 7.1 and 7.2 of the Rails Tutorial Book for some hints.
You may want to supplement it with this section of the Rails Tutorial book, ignoring the parts about the username and email. It will walk you through creating a user account.
Testing hints:
Here's a few test ideas to get you started:
- Write a test that
- Gets the
/whenbot/tasks/page - Asserts that you're redirected to the login page
- Gets the
- Run the tests, make sure it fails.
- Implement the code needed to make the test pass
- Write a Capybara test that
- Visits the
/whenbot/tasks/without signing in - Checks that you're redirected to page that has the content "Enter Password"
- Fill in the
passwordfield with your password (set via a Factory) - Clicks on the "Sign In" button
- Checks that you're successfully logged in and brought to the
/whenbot/tasks/page
- Visits the
- Run the tests, make sure it fails.
- Implement the code needed to make the test pass
- Write a test that
- Logs into a User's account
- Visits the
/whenbot/tasks/newpage - Asserts that you're not redirected away from the
/whenbot/tasks/newpage - Asserts that the page contains text that says "Trigger Channel" (as in "Choose a Trigger Channel")
- Run the test, make sure it fails
- Write the code needed to make the test pass
- Add in any other functionality using TDD.