Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'spec/frontend/authentication/u2f/mock_u2f_device.js')
-rw-r--r--spec/frontend/authentication/u2f/mock_u2f_device.js23
1 files changed, 23 insertions, 0 deletions
diff --git a/spec/frontend/authentication/u2f/mock_u2f_device.js b/spec/frontend/authentication/u2f/mock_u2f_device.js
new file mode 100644
index 00000000000..ec8425a4e3e
--- /dev/null
+++ b/spec/frontend/authentication/u2f/mock_u2f_device.js
@@ -0,0 +1,23 @@
+/* eslint-disable no-unused-expressions */
+
+export default class MockU2FDevice {
+ constructor() {
+ this.respondToAuthenticateRequest = this.respondToAuthenticateRequest.bind(this);
+ this.respondToRegisterRequest = this.respondToRegisterRequest.bind(this);
+ window.u2f || (window.u2f = {});
+ window.u2f.register = (appId, registerRequests, signRequests, callback) => {
+ this.registerCallback = callback;
+ };
+ window.u2f.sign = (appId, challenges, signRequests, callback) => {
+ this.authenticateCallback = callback;
+ };
+ }
+
+ respondToRegisterRequest(params) {
+ return this.registerCallback(params);
+ }
+
+ respondToAuthenticateRequest(params) {
+ return this.authenticateCallback(params);
+ }
+}