diff options
author | Kamil Trzcinski <ayufan@ayufan.eu> | 2016-06-06 16:33:52 +0200 |
---|---|---|
committer | Kamil Trzcinski <ayufan@ayufan.eu> | 2016-06-06 16:33:52 +0200 |
commit | d9b292f8726e46050e2d882a9a9fc1be95007d18 (patch) | |
tree | 6f254d2829d113b41d18a12b43be5a10a96847e3 /spec/support | |
parent | 7ad7e10feed624e263b5b80f5cafd4b0ed900ad7 (diff) | |
parent | aa7cef9325f1f4b9db91c28f41fad3d4bc7252f0 (diff) | |
download | gitlab-ce-d9b292f8726e46050e2d882a9a9fc1be95007d18.tar.gz |
Merge remote-tracking branch 'origin/master' into rename-ci-commit
# Conflicts:
# spec/features/builds_spec.rb
Diffstat (limited to 'spec/support')
-rw-r--r-- | spec/support/fake_u2f_device.rb | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/spec/support/fake_u2f_device.rb b/spec/support/fake_u2f_device.rb new file mode 100644 index 00000000000..553fe9f1fbc --- /dev/null +++ b/spec/support/fake_u2f_device.rb @@ -0,0 +1,36 @@ +class FakeU2fDevice + def initialize(page) + @page = page + end + + def respond_to_u2f_registration + app_id = @page.evaluate_script('gon.u2f.app_id') + challenges = @page.evaluate_script('gon.u2f.challenges') + + json_response = u2f_device(app_id).register_response(challenges[0]) + + @page.execute_script(" + u2f.register = function(appId, registerRequests, signRequests, callback) { + callback(#{json_response}); + }; + ") + end + + def respond_to_u2f_authentication + app_id = @page.evaluate_script('gon.u2f.app_id') + challenges = @page.evaluate_script('gon.u2f.challenges') + json_response = u2f_device(app_id).sign_response(challenges[0]) + + @page.execute_script(" + u2f.sign = function(appId, challenges, signRequests, callback) { + callback(#{json_response}); + }; + ") + end + + private + + def u2f_device(app_id) + @u2f_device ||= U2F::FakeU2F.new(app_id) + end +end |