debian-mirror-gitlab/spec/frontend/authentication/u2f/util_spec.js

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

62 lines
2.3 KiB
JavaScript
Raw Normal View History

2020-06-23 00:09:42 +05:30
import { canInjectU2fApi } from '~/authentication/u2f/util';
2018-03-27 19:54:05 +05:30
describe('U2F Utils', () => {
describe('canInjectU2fApi', () => {
it('returns false for Chrome < 41', () => {
2018-12-13 13:39:08 +05:30
const userAgent =
'Mozilla/5.0 (Windows NT 6.3; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/40.0.2214.28 Safari/537.36';
2018-03-27 19:54:05 +05:30
expect(canInjectU2fApi(userAgent)).toBe(false);
});
it('returns true for Chrome >= 41', () => {
2018-12-13 13:39:08 +05:30
const userAgent =
'Mozilla/5.0 (Windows NT 6.3; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/63.0.3239.132 Safari/537.36';
2018-03-27 19:54:05 +05:30
expect(canInjectU2fApi(userAgent)).toBe(true);
});
it('returns false for Opera < 40', () => {
2018-12-13 13:39:08 +05:30
const userAgent =
'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/45.0.2454.85 Safari/537.36 OPR/32.0.1948.25';
2018-03-27 19:54:05 +05:30
expect(canInjectU2fApi(userAgent)).toBe(false);
});
it('returns true for Opera >= 40', () => {
2018-12-13 13:39:08 +05:30
const userAgent =
'Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/56.0.2924.87 Safari/537.36 OPR/43.0.2442.991';
2018-03-27 19:54:05 +05:30
expect(canInjectU2fApi(userAgent)).toBe(true);
});
it('returns false for Safari', () => {
2018-12-13 13:39:08 +05:30
const userAgent =
'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_5) AppleWebKit/603.2.4 (KHTML, like Gecko) Version/10.1.1 Safari/603.2.4';
2018-03-27 19:54:05 +05:30
expect(canInjectU2fApi(userAgent)).toBe(false);
});
it('returns false for Chrome on Android', () => {
2018-12-13 13:39:08 +05:30
const userAgent =
'Mozilla/5.0 (Linux; Android 7.0; VS988 Build/NRD90U) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/61.0.3145.0 Mobile Safari/537.36';
2018-03-27 19:54:05 +05:30
expect(canInjectU2fApi(userAgent)).toBe(false);
});
it('returns false for Chrome on iOS', () => {
2018-12-13 13:39:08 +05:30
const userAgent =
'Mozilla/5.0 (iPhone; CPU iPhone OS 10_3 like Mac OS X) AppleWebKit/602.1.50 (KHTML, like Gecko) CriOS/56.0.2924.75 Mobile/14E5239e Safari/602.1';
2018-03-27 19:54:05 +05:30
expect(canInjectU2fApi(userAgent)).toBe(false);
});
it('returns false for Safari on iOS', () => {
2018-12-13 13:39:08 +05:30
const userAgent =
'Mozilla/5.0 (iPhone; CPU iPhone OS 11_0 like Mac OS X) AppleWebKit/604.1.38 (KHTML, like Gecko) Version/11.0 Mobile/15A356 Safari/604.1';
2018-03-27 19:54:05 +05:30
expect(canInjectU2fApi(userAgent)).toBe(false);
});
});
});