quo_vadis 2.2.2 → 2.2.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +5 -0
- data/README.md +21 -0
- data/lib/quo_vadis/controller.rb +9 -0
- data/lib/quo_vadis/version.rb +1 -1
- data/test/integration/controller_test.rb +8 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e38d43ca3eb42e7fe421725da06631c57c15308a0ee0fcb395043b3c8d922bde
|
4
|
+
data.tar.gz: 2e09223593c598cdfcad8cb5947dc4065b499e9a9dee06e8eec1a7cd6124003a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 69048fb28b48d94329ee3269cb706f583796893a2a8a6d7177adfb2b9b022f7fe84e4076044816d33d6e4a02b6529b3413c12b38f6dc6a3f3672095683a04610
|
7
|
+
data.tar.gz: fd2a1c93a899e07d1e9bb2a393a52eccbdb5f9256c894d03ca1eb34bc867f351dfe12149d45879ab5bc5960f9d393cdbbe7f5dc24ab43a46cc3cfa50a6454b44
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -12,6 +12,7 @@ Simple to integrate into your application. The main task is customising the exa
|
|
12
12
|
### General features
|
13
13
|
|
14
14
|
- Works with any model, e.g. `User` or `Person`.
|
15
|
+
- Works with multiple models, e.g. `User` and `Admin`.
|
15
16
|
- Works with any identifier, e.g. `:username` or `:email`.
|
16
17
|
- Minimal footprint in your models and controllers.
|
17
18
|
- Does not touch your existing database tables.
|
@@ -31,6 +32,10 @@ Simple to integrate into your application. The main task is customising the exa
|
|
31
32
|
- Email-notifications of updates to authentication details.
|
32
33
|
- Audit trail.
|
33
34
|
|
35
|
+
### Testing
|
36
|
+
|
37
|
+
- Can shortcut logging in for speedier tests.
|
38
|
+
|
34
39
|
|
35
40
|
## Installation
|
36
41
|
|
@@ -384,6 +389,22 @@ They must be in `app/views/quo_vadis/mailer/NAME.{text,html}.erb`.
|
|
384
389
|
You can revoke a user's access by calling `#revoke_authentication_credentials` on the model instance. This deletes the user's password, TOTP credential, recovery codes, and active sessions. Their authentication logs, or audit trail, are preserved.
|
385
390
|
|
386
391
|
|
392
|
+
## Shortcut logging in for functional, integration, and system tests
|
393
|
+
|
394
|
+
Instead of going through your login page to log in before every test, you can tell QuoVadis which model to authenticate as when visiting the first URL in your test.
|
395
|
+
|
396
|
+
Use a `login` param pointing to your model's global ID. Note that the model must be able to log in normally, i.e. it must have a password (and therefore a `qv_account`).
|
397
|
+
|
398
|
+
For example:
|
399
|
+
|
400
|
+
```ruby
|
401
|
+
@user = User.create(email: '...', password: '...')
|
402
|
+
visit dashboard_path(login: @user.to_global_id)
|
403
|
+
```
|
404
|
+
|
405
|
+
This only works in the test environment.
|
406
|
+
|
407
|
+
|
387
408
|
## Configuration
|
388
409
|
|
389
410
|
This is QuoVadis' [default configuration](https://github.com/airblade/quo_vadis/blob/master/lib/quo_vadis/defaults.rb):
|
data/lib/quo_vadis/controller.rb
CHANGED
@@ -4,6 +4,15 @@ module QuoVadis
|
|
4
4
|
module Controller
|
5
5
|
|
6
6
|
def self.included(base)
|
7
|
+
if Rails.env.test?
|
8
|
+
base.before_action {
|
9
|
+
if params[:login]
|
10
|
+
model = GlobalID::Locator.locate(params.delete(:login))
|
11
|
+
login model
|
12
|
+
end
|
13
|
+
}
|
14
|
+
end
|
15
|
+
|
7
16
|
base.before_action { CurrentRequestDetails.request = request }
|
8
17
|
|
9
18
|
base.helper_method :authenticated_model, :logged_in?
|
data/lib/quo_vadis/version.rb
CHANGED
@@ -14,6 +14,14 @@ class ControllerTest < IntegrationTest
|
|
14
14
|
end
|
15
15
|
|
16
16
|
|
17
|
+
test 'shortcut login' do
|
18
|
+
get secret_articles_path(login: User.first.to_global_id)
|
19
|
+
|
20
|
+
assert_response :success
|
21
|
+
assert_equal secret_articles_path, path
|
22
|
+
end
|
23
|
+
|
24
|
+
|
17
25
|
test 'require_authentication when not logged in' do
|
18
26
|
get secret_articles_path
|
19
27
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: quo_vadis
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.2.
|
4
|
+
version: 2.2.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andy Stewart
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-
|
11
|
+
date: 2024-05-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|