Skip to content

Commit

Permalink
Add support for Google Search App detection
Browse files Browse the repository at this point in the history
A new browser type, Google Search App, has been added to the Browser enumeration in the Detection library. Corresponding unit tests for the Google Search App have also been added to ensure proper identification and version resolution.

Ref: #960
  • Loading branch information
wangkanai committed Apr 27, 2024
1 parent e8ced58 commit 0e9bdbb
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
5 changes: 3 additions & 2 deletions Detection/src/Models/Browser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,6 @@ public enum Browser
Firefox = 1 << 3, // Firefox
Edge = 1 << 4, // Microsoft Edge
Opera = 1 << 5, // Opera
Others = 1 << 6 // Others
}
GoogleSearchApp = 1 << 6, // Google Search App
Others = 1 << 7 // Others
}
13 changes: 12 additions & 1 deletion Detection/tests/Services/BrowserServiceTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ public void Unknown()
[InlineData("1.0.154.53", "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US) AppleWebKit/525.19 (KHTML, like Gecko) Chrome/1.0.154.53 Safari/525.19")]
[InlineData("75.0.3770.90", "Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/75.0.3770.90 Atom/4.0.0.141 Safari/537.36")]
[InlineData("8.0.552.237", "Mozilla/5.0 (X11; U; Linux x86_64; en-US) AppleWebKit/534.10 (KHTML, like Gecko) Ubuntu/10.10 Chromium/8.0.552.237 Chrome/8.0.552.237 Safari/534.10")]
[InlineData("124.0.6367.71","Mozilla/5.0 (iPhone; CPU iPhone OS 17_4 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) CriOS/124.0.6367.71 Mobile/15E148 Safari/604.1")]
public void Chrome(string version, string agent)
{
var resolver = MockService.BrowserService(agent);
Expand Down Expand Up @@ -62,6 +63,16 @@ public void Safari(string version, string agent)
Assert.Equal(new Version(version), resolver.Version);
}

[Theory]
[InlineData("312.2.624279232", "Mozilla/5.0 (iPhone; CPU iPhone OS 17_4 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) GSA/312.2.624279232 Mobile/15E148 Safari/604.1")]

public void GoogleSearchApp(string version, string agent)
{
var resolver = MockService.BrowserService(agent);
Assert.Equal(Browser.GoogleSearchApp, resolver.Name);
Assert.Equal(new Version(version), resolver.Version);
}

[Theory]
[InlineData("Mozilla/5.0 (Windows NT x.y; rv:10.0) Gecko/20100101 Firefox/10.0")]
[InlineData("Mozilla/5.0 (Windows NT 5.1; rv:11.0) Gecko Firefox/11.0 (via ggpht.com GoogleImageProxy)")]
Expand Down Expand Up @@ -107,4 +118,4 @@ public void Others(string agent)
var resolver = MockService.BrowserService(agent);
Assert.Equal(Browser.Others, resolver.Name);
}
}
}

0 comments on commit 0e9bdbb

Please sign in to comment.