booth 0.1.6 → 0.1.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 567601ef14e25c620c7d2d8ab39810cb23fac87850f6e960b997674ddc770187
4
- data.tar.gz: dc4edd0a924d9878a3d0759ac28f20a9245012e645e874448bc442079972f1aa
3
+ metadata.gz: d8e2da057058f232ca308dcb2476c51680f99633dab61b14ea0290ff0036d86b
4
+ data.tar.gz: b1a0a4e0d8514a34b455070adb3c5bfb2e349df3989392f896ac48c9afc1cce9
5
5
  SHA512:
6
- metadata.gz: 872fe471556a1d07f9944741ab09aca261dadadfa130eba4b6599610d5ef8fd0db21b09d23a5c55c3e742a8a4286d86bb8dfe335c057d8e89615f6d91d3481ba
7
- data.tar.gz: 305f826130c100261e7d6ec7dd34f2f326e02294ad6beb210f151e0fca1227b812e8c94cd4b9dbf261d536eb1feae6e6a4006d9890409e133fe833387844da56
6
+ metadata.gz: 318999c852e79ac40e1cc4cf1c00a613c0f5f8871fa62307491ddf92c102074378825c071ab388ed583d8b11bb9c1f1088ffcb91913a2c3d13e8d5676c689dd7
7
+ data.tar.gz: 542b4409646b3ea8d865a4f8908436707103a1ca57a86bf0bc836f926c0652c973e6126ce44a08ce7723e97874ffe3802c25b9b6622b0148cacac18a3191c9ac
data/CHANGELOG.md CHANGED
@@ -1,5 +1,13 @@
1
1
  # main
2
2
 
3
+ # 0.1.8
4
+
5
+ * Add Credential block and unblock to Adminland
6
+
7
+ # 0.1.7
8
+
9
+ * Fix time travel actually returning in test suite
10
+
3
11
  # 0.1.6
4
12
 
5
13
  - Remove the unused `domain` option from `Booth::Userland::Webauths::Destroy`. It was mandatory but never read, so `Booth::Userland.destroy_webauth` crashed with `KeyError: option 'domain' is required`
@@ -0,0 +1,38 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Booth
4
+ module Adminland
5
+ module Credentials
6
+ # Blocks a credential from authenticating.
7
+ class Block
8
+ include Calls
9
+
10
+ option :credential_id
11
+
12
+ def call
13
+ return Tron.failure(:credential_not_found) unless credential
14
+
15
+ if credential.blocked?
16
+ return Tron.success(:already_blocked,
17
+ id: credential.id,
18
+ blocked_at: credential.blocked_at)
19
+ end
20
+
21
+ blocked_at = Time.current
22
+ credential.update!(blocked_at:)
23
+
24
+ Tron.success(:credential_blocked, id: credential.id, blocked_at:)
25
+ end
26
+
27
+ private
28
+
29
+ def credential
30
+ return @credential if defined?(@credential)
31
+
32
+ uuid = ::Booth::Syntaxes::Uuid.call(credential_id, raise_if_invalid: false).uuid
33
+ @credential = ::Booth::Models::Credential.find_by(id: uuid) if uuid
34
+ end
35
+ end
36
+ end
37
+ end
38
+ end
@@ -0,0 +1,37 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Booth
4
+ module Adminland
5
+ module Credentials
6
+ # Allows a credential to authenticate again.
7
+ class Unblock
8
+ include Calls
9
+
10
+ option :credential_id
11
+
12
+ def call
13
+ return Tron.failure(:credential_not_found) unless credential
14
+
15
+ unless credential.blocked?
16
+ return Tron.success(:already_unblocked,
17
+ id: credential.id,
18
+ blocked_at: credential.blocked_at)
19
+ end
20
+
21
+ credential.update!(blocked_at: nil)
22
+
23
+ Tron.success(:credential_unblocked, id: credential.id, blocked_at: nil)
24
+ end
25
+
26
+ private
27
+
28
+ def credential
29
+ return @credential if defined?(@credential)
30
+
31
+ uuid = ::Booth::Syntaxes::Uuid.call(credential_id, raise_if_invalid: false).uuid
32
+ @credential = ::Booth::Models::Credential.find_by(id: uuid) if uuid
33
+ end
34
+ end
35
+ end
36
+ end
37
+ end
@@ -7,6 +7,14 @@ module Booth
7
7
  # Credential Helpers
8
8
  # ------------------
9
9
 
10
+ def self.block_credential(...)
11
+ ::Booth::Adminland::Credentials::Block.call(...)
12
+ end
13
+
14
+ def self.unblock_credential(...)
15
+ ::Booth::Adminland::Credentials::Unblock.call(...)
16
+ end
17
+
10
18
  def self.create_credential(...)
11
19
  ::Booth::Adminland::Credentials::Create.call(...)
12
20
  end
@@ -17,6 +17,28 @@ module Booth
17
17
  option :before_test, default: -> {}
18
18
  option :after_credential, default: -> { ->(credential_id:) {} }
19
19
 
20
+ # Scenarios call `travel`/`travel_to` (non-block form) from their own
21
+ # `call` method. Those stubs are tracked in the scenario instance's own
22
+ # SimpleStubs, but `Calls::ClassMethods#call` discards the instance
23
+ # after running — so nobody would ever call `travel_back`, and the
24
+ # frozen clock would leak into every subsequent test.
25
+ #
26
+ # Each scenario class defines its own `call`, so a `prepend` on this
27
+ # base class would be shadowed. Instead, hook `inherited` to prepend
28
+ # the cleanup onto every scenario subclass as it is defined.
29
+ module TimeTravelCleanup
30
+ def call(...)
31
+ super
32
+ ensure
33
+ travel_back
34
+ end
35
+ end
36
+
37
+ def self.inherited(subclass)
38
+ super
39
+ subclass.prepend(TimeTravelCleanup)
40
+ end
41
+
20
42
  private
21
43
 
22
44
  def virtual_authenticators
data/lib/booth/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Booth
4
- VERSION = '0.1.6'
4
+ VERSION = '0.1.8'
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: booth
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.6
4
+ version: 0.1.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - halo
@@ -228,8 +228,10 @@ files:
228
228
  - lib/booth.rb
229
229
  - lib/booth/adminland.rb
230
230
  - lib/booth/adminland/authenticators/exist.rb
231
+ - lib/booth/adminland/credentials/block.rb
231
232
  - lib/booth/adminland/credentials/create.rb
232
233
  - lib/booth/adminland/credentials/index.rb
234
+ - lib/booth/adminland/credentials/unblock.rb
233
235
  - lib/booth/adminland/incognitos/consume_token.rb
234
236
  - lib/booth/adminland/incognitos/generate_secret_key.rb
235
237
  - lib/booth/adminland/incognitos/stop_incognito.rb
@@ -417,7 +419,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
417
419
  - !ruby/object:Gem::Version
418
420
  version: '0'
419
421
  requirements: []
420
- rubygems_version: 3.6.9
422
+ rubygems_version: 4.0.20
421
423
  specification_version: 4
422
424
  summary: Opinionated authentication framework for Rails
423
425
  test_files: []