diff --git a/docs/quick-start-guide.adoc b/docs/quick-start-guide.adoc index fb3d09b..9e6d950 100644 --- a/docs/quick-start-guide.adoc +++ b/docs/quick-start-guide.adoc @@ -8,37 +8,31 @@ To use Go Grid Router do the following: ---- $ mkdir -p /etc/grid-router/quota ---- + . Create ```users.htpasswd``` file: + ---- $ htpasswd -bc /etc/grid-router/users.htpasswd test test-password ---- -. Start Selenium standalone server on port 4445: -+ ----- -$ java -jar selenium-server-standalone.jar -port 4445 ----- -NOTE: We are showing Selenium server command here because it is a well-known example. We recommend you to use http://aerokube.com/selenoid/latest/[Selenoid] instead - it is more efficient. + +. Start https://aerokube.com/selenoid/latest/[Selenoid] on host `selenoid.example.com` and port `4444`. . Create quota file (use correct browser name and version): + ---- $ cat /etc/grid-router/quota/test.xml - - + + - + ---- + -NOTE: File name should correspond to user name you added to `htpasswd` file. For user ```test``` we added on previous steps you should create ```test.xml```. -+ -NOTE: For Mac OS instead of "localhost" you have to use "docker.for.mac.localhost". -link:++https://docs.docker.com/docker-for-mac/networking/#use-cases-and-workarounds++[Docker for Mac - Networking]. -+ +NOTE: File name should correspond to user name you added to `htpasswd` file. +For user `test` we added on previous steps you should create `test.xml`. . Start Ggr container: + ---- @@ -46,6 +40,7 @@ link:++https://docs.docker.com/docker-for-mac/networking/#use-cases-and-workarou ggr -v /etc/grid-router/:/etc/grid-router:ro \ --net host aerokube/ggr:latest-release ---- + . Access Ggr on port 4444 in the same way you do for Selenium Hub but using the following url: + ---- diff --git a/proxy.go b/proxy.go index b25dea4..389525b 100644 --- a/proxy.go +++ b/proxy.go @@ -88,28 +88,28 @@ type Routes map[string]*Host type caps map[string]interface{} -func (c caps) capabilities(fn func(m map[string]interface{}, w3c bool)) { +func (c caps) capabilities(fn func(m map[string]interface{}, w3c bool, extension bool)) { if desiredCapabilities, ok := c[keys.desiredCapabilities]; ok { if m, ok := desiredCapabilities.(map[string]interface{}); ok { - fn(m, false) + fn(m, false, false) } - } else { - if w3cCapabilities, ok := c[keys.w3cCapabilities]; ok { - if m, ok := w3cCapabilities.(map[string]interface{}); ok { - if alwaysMatch, ok := m[keys.alwaysMatch]; ok { - if m, ok := alwaysMatch.(map[string]interface{}); ok { - fn(m, true) - for k, v := range m { // Extension capabilities have ":" in key - if ec, ok := v.(map[string]interface{}); ok && strings.Contains(k, ":") { - fn(ec, true) - } + } + if w3cCapabilities, ok := c[keys.w3cCapabilities]; ok { + if m, ok := w3cCapabilities.(map[string]interface{}); ok { + if alwaysMatch, ok := m[keys.alwaysMatch]; ok { + if m, ok := alwaysMatch.(map[string]interface{}); ok { + fn(m, true, false) + for k, v := range m { // Extension capabilities have ":" in key + if ec, ok := v.(map[string]interface{}); ok && strings.Contains(k, ":") { + fn(ec, true, true) } } } } } + } else { + fn(make(map[string]interface{}), false, false) } - fn(make(map[string]interface{}), false) } func (c caps) capability(k string) string { @@ -118,7 +118,7 @@ func (c caps) capability(k string) string { func (c caps) capabilityJsonWireW3C(jsonWire, W3C string) string { result := "" - c.capabilities(func(m map[string]interface{}, w3c bool) { + c.capabilities(func(m map[string]interface{}, w3c bool, _ bool) { k := jsonWire if w3c { k = W3C @@ -163,7 +163,10 @@ func (c caps) labels() string { } func (c caps) setVersion(version string) { - c.capabilities(func(m map[string]interface{}, w3c bool) { + c.capabilities(func(m map[string]interface{}, w3c bool, extension bool) { + if extension { + return + } if w3c { m["browserVersion"] = version } else { diff --git a/proxy_test.go b/proxy_test.go index a22294f..179dd33 100644 --- a/proxy_test.go +++ b/proxy_test.go @@ -920,6 +920,12 @@ func TestStartSessionWithDefaultVersionW3C(t *testing.T) { AssertThat(t, err, Is{nil}) AssertThat(t, sess["capabilities"]["alwaysMatch"]["browserVersion"], EqualTo{"2.0"}) + so, ok := sess["capabilities"]["alwaysMatch"]["selenoid:options"] + AssertThat(t, ok, Is{true}) + selenoidOptions, ok := so.(map[string]interface{}) + AssertThat(t, ok, Is{true}) + _, ok = selenoidOptions["browserVersion"] + AssertThat(t, ok, Is{false}) })) selenium := httptest.NewServer(mux) defer selenium.Close()