summaryrefslogtreecommitdiffstats
path: root/web/web_test.go
diff options
context:
space:
mode:
authorAlex Moon <moonmeister@users.noreply.github.com>2018-03-06 13:22:07 -0800
committerHarrison Healey <harrisonmhealey@gmail.com>2018-03-06 21:22:07 +0000
commit309594cedf9f39be5f557de34cc741e218cd3668 (patch)
treeed7e6487fed774a7609073de322339186f1683d6 /web/web_test.go
parent6b3c9a480a0174cc7d1b17d0a0d874eedecc2dd3 (diff)
downloadchat-309594cedf9f39be5f557de34cc741e218cd3668.tar.gz
chat-309594cedf9f39be5f557de34cc741e218cd3668.tar.bz2
chat-309594cedf9f39be5f557de34cc741e218cd3668.zip
[PLT-7574] Update and Simplify Compatibility Check and Replace UA Dependency (#7427)
* Add fix to not run browser check on Mobile Browsers or the App * remove non safari and IE checks * Replace useragent checking dependency and update UA tests * change some wording * change dependancy again to one with compatible licence * Fix typos and clarify wording * fix typo and comvert tests to use array
Diffstat (limited to 'web/web_test.go')
-rw-r--r--web/web_test.go31
1 files changed, 31 insertions, 0 deletions
diff --git a/web/web_test.go b/web/web_test.go
index 373d47103..890b1ba58 100644
--- a/web/web_test.go
+++ b/web/web_test.go
@@ -166,4 +166,35 @@ func TestMain(m *testing.M) {
}()
status = m.Run()
+
+}
+
+func TestCheckClientCompatability(t *testing.T) {
+ //Browser Name, UA String, expected result (if the browser should fail the test false and if it should pass the true)
+ type uaTest struct {
+ Name string // Name of Browser
+ UserAgent string // Useragent of Browser
+ Result bool // Expected result (true if browser should be compatible, false if browser shouldn't be compatible)
+ }
+ var uaTestParameters = []uaTest{
+ {"Mozilla 40.1", "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:40.0) Gecko/20100101 Firefox/40.1", true},
+ {"Chrome 60", "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/60.0.3112.90 Safari/537.36", true},
+ {"Chrome Mobile", "Mozilla/5.0 (Linux; Android 6.0; Nexus 5 Build/MRA58N) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/60.0.3112.113 Mobile Safari/537.36", true},
+ {"MM Classic App", "Mozilla/5.0 (Linux; Android 8.0.0; Nexus 5X Build/OPR6.170623.013; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/61.0.3163.81 Mobile Safari/537.36 Web-Atoms-Mobile-WebView", true},
+ {"MM App 3.7.1", "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_6) AppleWebKit/537.36 (KHTML, like Gecko) Mattermost/3.7.1 Chrome/56.0.2924.87 Electron/1.6.11 Safari/537.36", true},
+ {"Franz 4.0.4", "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_6) AppleWebKit/537.36 (KHTML, like Gecko) Franz/4.0.4 Chrome/52.0.2743.82 Electron/1.3.1 Safari/537.36", true},
+ {"Edge 14", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/51.0.2704.79 Safari/537.36 Edge/14.14393", true},
+ {"Internet Explorer 11", "Mozilla/5.0 (Windows NT 10.0; WOW64; Trident/7.0; rv:11.0) like Gecko", true},
+ {"Internet Explorer 9", "Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 7.1; Trident/5.0", false},
+ {"Safari 9", "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_6) AppleWebKit/604.1.38 (KHTML, like Gecko) Version/11.0 Safari/604.1.38", true},
+ {"Safari 8", "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_4) AppleWebKit/600.7.12 (KHTML, like Gecko) Version/8.0.7 Safari/600.7.12", false},
+ {"Safari Mobile", "Mozilla/5.0 (iPhone; CPU iPhone OS 9_1 like Mac OS X) AppleWebKit/601.1.46 (KHTML, like Gecko) Version/9.0 Mobile/13B137 Safari/601.1", true},
+ }
+ for _, browser := range uaTestParameters {
+ if result := CheckClientCompatability(browser.UserAgent); result == browser.Result {
+ t.Logf("Pass: %s passed browser test.", browser.Name)
+ } else {
+ t.Errorf("Fail: %s User Agent Test failed!", browser.Name)
+ }
+ }
}