Skip to content

Commit 144202e

Browse files
committed
fix virtual authenticator
1 parent 5f91881 commit 144202e

File tree

1 file changed

+23
-23
lines changed

1 file changed

+23
-23
lines changed

examples/ruby/spec/interactions/virtual_authenticator_spec.rb

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# frozen_string_literal: true
22

3-
require 'selenium-webdriver'
3+
require 'spec_helper'
44

55
RSpec.describe 'Virtual Authenticator' do
66
let(:driver) { start_session }
@@ -41,32 +41,32 @@
4141

4242
it 'creates virtual authenticator' do
4343
options = Selenium::WebDriver::VirtualAuthenticatorOptions.new(protocol: :u2f, resident_key: false)
44-
@authenticator = driver.add_virtual_authenticator(options)
44+
authenticator = driver.add_virtual_authenticator(options)
4545

46-
expect(@authenticator.valid?).to eq true
46+
expect(authenticator.valid?).to eq true
4747
end
4848

4949
it 'removes virtual authenticator' do
5050
options = Selenium::WebDriver::VirtualAuthenticatorOptions.new
51-
@authenticator = driver.add_virtual_authenticator(options)
52-
@authenticator.remove!
51+
authenticator = driver.add_virtual_authenticator(options)
52+
authenticator.remove!
5353

54-
expect(@authenticator.valid?).to eq false
54+
expect(authenticator.valid?).to eq false
5555
end
5656

5757
it 'creates and add resident credential' do
5858
options = Selenium::WebDriver::VirtualAuthenticatorOptions.new(protocol: :ctap2, resident_key: true,
5959
user_verification: true, user_verified: true)
60-
@authenticator = driver.add_virtual_authenticator(options)
60+
authenticator = driver.add_virtual_authenticator(options)
6161

6262
resident_credential = Selenium::WebDriver::Credential.resident(id: [1, 2, 3, 4],
6363
rp_id: 'localhost',
6464
user_handle: [1],
6565
private_key: Selenium::WebDriver::Credential
6666
.decode(encoded_private_key),
6767
sign_count: 0)
68-
@authenticator.add_credential(resident_credential)
69-
credential_list = @authenticator.credentials
68+
authenticator.add_credential(resident_credential)
69+
credential_list = authenticator.credentials
7070
expect(credential_list.length).to eq 1
7171

7272
credential_id = credential_list.first.id
@@ -75,7 +75,7 @@
7575

7676
it 'does not support resident credential when authenticator uses u2f protocol' do
7777
options = Selenium::WebDriver::VirtualAuthenticatorOptions.new(protocol: :u2f, resident_key: true)
78-
@authenticator = driver.add_virtual_authenticator(options)
78+
authenticator = driver.add_virtual_authenticator(options)
7979

8080
resident_credential = Selenium::WebDriver::Credential.resident(id: [1, 2, 3, 4],
8181
rp_id: 'localhost',
@@ -85,21 +85,21 @@
8585
sign_count: 0)
8686

8787
expect {
88-
@authenticator.add_credential(resident_credential)
88+
authenticator.add_credential(resident_credential)
8989
}.to raise_error(Selenium::WebDriver::Error::InvalidArgumentError)
9090
end
9191

9292
it 'creates and add non-resident credential' do
9393
options = Selenium::WebDriver::VirtualAuthenticatorOptions.new(protocol: :u2f, resident_key: false)
94-
@authenticator = driver.add_virtual_authenticator(options)
94+
authenticator = driver.add_virtual_authenticator(options)
9595

9696
non_resident_credential = Selenium::WebDriver::Credential.non_resident(id: [1, 2, 3, 4],
9797
rp_id: 'localhost',
9898
private_key: Selenium::WebDriver::Credential
9999
.decode(pkcs8_private_key),
100100
sign_count: 0)
101-
@authenticator.add_credential(non_resident_credential)
102-
credentials = @authenticator.credentials
101+
authenticator.add_credential(non_resident_credential)
102+
credentials = authenticator.credentials
103103

104104
expect(credentials.length).to eq 1
105105
expect(credentials.first.id).to eq [1, 2, 3, 4]
@@ -108,7 +108,7 @@
108108
it 'gets all credentials' do
109109
options = Selenium::WebDriver::VirtualAuthenticatorOptions.new(protocol: :ctap2, resident_key: true,
110110
user_verification: true, user_verified: true)
111-
@authenticator = @driver.add_virtual_authenticator(options)
111+
authenticator = driver.add_virtual_authenticator(options)
112112

113113
resident_credential = Selenium::WebDriver::Credential.resident(id: [1, 2, 3, 4],
114114
rp_id: 'localhost',
@@ -121,27 +121,27 @@
121121
private_key: Selenium::WebDriver::Credential
122122
.decode(encoded_private_key),
123123
sign_count: 0)
124-
@authenticator.add_credential(resident_credential)
125-
@authenticator.add_credential(non_resident_credential)
124+
authenticator.add_credential(resident_credential)
125+
authenticator.add_credential(non_resident_credential)
126126

127-
credentials = @authenticator.credentials
127+
credentials = authenticator.credentials
128128
expect(credentials.length).to eq 2
129129
expect(credentials.first.id).to eq [1, 2, 3, 4]
130130
end
131131

132132
it 'removes all credentials' do
133133
options = Selenium::WebDriver::VirtualAuthenticatorOptions.new
134-
@authenticator = driver.add_virtual_authenticator(options)
134+
authenticator = driver.add_virtual_authenticator(options)
135135

136136
non_resident_credential = Selenium::WebDriver::Credential.non_resident(id: [1, 2, 3, 4],
137137
rp_id: 'localhost',
138138
private_key: Selenium::WebDriver::Credential
139139
.decode(encoded_private_key),
140140
sign_count: 0)
141-
@authenticator.add_credential(non_resident_credential)
142-
expect(@authenticator.credentials.length).to eq 1
141+
authenticator.add_credential(non_resident_credential)
142+
expect(authenticator.credentials.length).to eq 1
143143

144-
@authenticator.remove_all_credentials
145-
expect(@authenticator.credentials).to be_empty
144+
authenticator.remove_all_credentials
145+
expect(authenticator.credentials).to be_empty
146146
end
147147
end

0 commit comments

Comments
 (0)