@@ -1642,6 +1642,34 @@ func Test_parseSeleniumGridScalerMetadata(t *testing.T) {
1642
1642
NodeMaxSessions : 1 ,
1643
1643
},
1644
1644
},
1645
+ {
1646
+ name : "valid username and password in AuthParams, url, browsername, and sessionbrowsername should return metadata" ,
1647
+ args : args {
1648
+ config : & scalersconfig.ScalerConfig {
1649
+ AuthParams : map [string ]string {
1650
+ "username" : "username" ,
1651
+ "password" : "password" ,
1652
+ },
1653
+ TriggerMetadata : map [string ]string {
1654
+ "url" : "http://selenium-hub:4444/graphql" ,
1655
+ "browserName" : "MicrosoftEdge" ,
1656
+ "sessionBrowserName" : "msedge" ,
1657
+ },
1658
+ },
1659
+ },
1660
+ wantErr : false ,
1661
+ want : & seleniumGridScalerMetadata {
1662
+ URL : "http://selenium-hub:4444/graphql" ,
1663
+ BrowserName : "MicrosoftEdge" ,
1664
+ SessionBrowserName : "msedge" ,
1665
+ TargetValue : 1 ,
1666
+ BrowserVersion : "latest" ,
1667
+ PlatformName : "linux" ,
1668
+ Username : "username" ,
1669
+ Password : "password" ,
1670
+ NodeMaxSessions : 1 ,
1671
+ },
1672
+ },
1645
1673
{
1646
1674
name : "valid url and browsername should return metadata" ,
1647
1675
args : args {
@@ -1761,20 +1789,22 @@ func Test_parseSeleniumGridScalerMetadata(t *testing.T) {
1761
1789
},
1762
1790
},
1763
1791
{
1764
- name : "valid url, browsername, unsafeSsl, activationThreshold, nodeMaxSessions and platformName should return metadata" ,
1792
+ name : "valid url, browsername, unsafeSsl, activationThreshold, nodeMaxSessions and platformName with trigger auth params should return metadata" ,
1765
1793
args : args {
1766
1794
config : & scalersconfig.ScalerConfig {
1767
1795
TriggerMetadata : map [string ]string {
1768
1796
"url" : "http://selenium-hub:4444/graphql" ,
1769
- "username" : "user" ,
1770
- "password" : "password" ,
1771
1797
"browserName" : "chrome" ,
1772
1798
"browserVersion" : "91.0" ,
1773
1799
"unsafeSsl" : "true" ,
1774
1800
"activationThreshold" : "10" ,
1775
1801
"platformName" : "Windows 11" ,
1776
1802
"nodeMaxSessions" : "3" ,
1777
1803
},
1804
+ AuthParams : map [string ]string {
1805
+ "username" : "user" ,
1806
+ "password" : "password" ,
1807
+ },
1778
1808
},
1779
1809
},
1780
1810
wantErr : false ,
@@ -1792,6 +1822,110 @@ func Test_parseSeleniumGridScalerMetadata(t *testing.T) {
1792
1822
NodeMaxSessions : 3 ,
1793
1823
},
1794
1824
},
1825
+ {
1826
+ name : "url in trigger auth param takes precedence over url in trigger metadata" ,
1827
+ args : args {
1828
+ config : & scalersconfig.ScalerConfig {
1829
+ TriggerMetadata : map [string ]string {
1830
+ "url" : "http://invalid.dns:4444/graphql" ,
1831
+ "browserName" : "chrome" ,
1832
+ "browserVersion" : "91.0" ,
1833
+ "unsafeSsl" : "true" ,
1834
+ "activationThreshold" : "10" ,
1835
+ "platformName" : "Windows 11" ,
1836
+ "nodeMaxSessions" : "3" ,
1837
+ },
1838
+ AuthParams : map [string ]string {
1839
+ "url" : "http://selenium-hub:4444/graphql" ,
1840
+ "username" : "user" ,
1841
+ "password" : "password" ,
1842
+ },
1843
+ },
1844
+ },
1845
+ wantErr : false ,
1846
+ want : & seleniumGridScalerMetadata {
1847
+ URL : "http://selenium-hub:4444/graphql" ,
1848
+ Username : "user" ,
1849
+ Password : "password" ,
1850
+ BrowserName : "chrome" ,
1851
+ SessionBrowserName : "chrome" ,
1852
+ TargetValue : 1 ,
1853
+ ActivationThreshold : 10 ,
1854
+ BrowserVersion : "91.0" ,
1855
+ UnsafeSsl : true ,
1856
+ PlatformName : "Windows 11" ,
1857
+ NodeMaxSessions : 3 ,
1858
+ },
1859
+ },
1860
+ {
1861
+ name : "auth type is not Basic and access token is provided" ,
1862
+ args : args {
1863
+ config : & scalersconfig.ScalerConfig {
1864
+ TriggerMetadata : map [string ]string {
1865
+ "url" : "http://selenium-hub:4444/graphql" ,
1866
+ "browserName" : "chrome" ,
1867
+ "browserVersion" : "91.0" ,
1868
+ "unsafeSsl" : "true" ,
1869
+ "activationThreshold" : "10" ,
1870
+ "platformName" : "Windows 11" ,
1871
+ "nodeMaxSessions" : "3" ,
1872
+ },
1873
+ AuthParams : map [string ]string {
1874
+ "url" : "http://selenium-hub:4444/graphql" ,
1875
+ "authType" : "OAuth2" ,
1876
+ "accessToken" : "my-access-token" ,
1877
+ },
1878
+ },
1879
+ },
1880
+ wantErr : false ,
1881
+ want : & seleniumGridScalerMetadata {
1882
+ URL : "http://selenium-hub:4444/graphql" ,
1883
+ AuthType : "OAuth2" ,
1884
+ AccessToken : "my-access-token" ,
1885
+ BrowserName : "chrome" ,
1886
+ SessionBrowserName : "chrome" ,
1887
+ TargetValue : 1 ,
1888
+ ActivationThreshold : 10 ,
1889
+ BrowserVersion : "91.0" ,
1890
+ UnsafeSsl : true ,
1891
+ PlatformName : "Windows 11" ,
1892
+ NodeMaxSessions : 3 ,
1893
+ },
1894
+ },
1895
+ {
1896
+ name : "authenticating with bearer access token" ,
1897
+ args : args {
1898
+ config : & scalersconfig.ScalerConfig {
1899
+ TriggerMetadata : map [string ]string {
1900
+ "browserName" : "chrome" ,
1901
+ "browserVersion" : "91.0" ,
1902
+ "unsafeSsl" : "true" ,
1903
+ "activationThreshold" : "10" ,
1904
+ "platformName" : "Windows 11" ,
1905
+ "nodeMaxSessions" : "3" ,
1906
+ },
1907
+ AuthParams : map [string ]string {
1908
+ "url" : "http://selenium-hub:4444/graphql" ,
1909
+ "authType" : "Bearer" ,
1910
+ "accessToken" : "my-access-token" ,
1911
+ },
1912
+ },
1913
+ },
1914
+ wantErr : false ,
1915
+ want : & seleniumGridScalerMetadata {
1916
+ URL : "http://selenium-hub:4444/graphql" ,
1917
+ AuthType : "Bearer" ,
1918
+ AccessToken : "my-access-token" ,
1919
+ BrowserName : "chrome" ,
1920
+ SessionBrowserName : "chrome" ,
1921
+ TargetValue : 1 ,
1922
+ ActivationThreshold : 10 ,
1923
+ BrowserVersion : "91.0" ,
1924
+ UnsafeSsl : true ,
1925
+ PlatformName : "Windows 11" ,
1926
+ NodeMaxSessions : 3 ,
1927
+ },
1928
+ },
1795
1929
}
1796
1930
for _ , tt := range tests {
1797
1931
t .Run (tt .name , func (t * testing.T ) {
0 commit comments