Repository: aerokube/selenoid
Pull request #1074 (2021-03-17 07:11:35)

Remaining release 1.10.2 fixes


Patch:
diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
index d7b12d4..2e48fdd 100644
--- a/.github/workflows/build.yml
+++ b/.github/workflows/build.yml
@@ -14,7 +14,7 @@ jobs:
       - name: Setup Golang
         uses: actions/setup-go@v2
         with:
-          go-version: 1.15.x
+          go-version: 1.16.x
 
       - uses: actions/cache@v1
         with:
diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml
index a3d3f43..218974d 100644
--- a/.github/workflows/release.yml
+++ b/.github/workflows/release.yml
@@ -13,7 +13,7 @@ jobs:
       - name: Setup Golang
         uses: actions/setup-go@v2
         with:
-          go-version: 1.15.x
+          go-version: 1.16.x
 
       - uses: actions/cache@v1
         with:
diff --git a/Dockerfile b/Dockerfile
index 1453739..32e8269 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -1,7 +1,9 @@
-FROM alpine:3.12
+FROM alpine:3
 
 RUN apk add -U ca-certificates tzdata mailcap && rm -Rf /var/cache/apk/*
 COPY selenoid /usr/bin
 
 EXPOSE 4444
 ENTRYPOINT ["/usr/bin/selenoid", "-listen", ":4444", "-conf", "/etc/selenoid/browsers.json", "-video-output-dir", "/opt/selenoid/video/"]
+
+USER 4096:4096
diff --git a/docs/contributing.adoc b/docs/contributing.adoc
index 4f81078..080c390 100644
--- a/docs/contributing.adoc
+++ b/docs/contributing.adoc
@@ -42,7 +42,7 @@ Locally can be generated with:
 
 [source,bash]
 ----
-$ docker run --rm -v `pwd`/docs/:/documents/      \
+$ docker run --rm -v ./docs/:/documents/      \
     asciidoctor/docker-asciidoctor                \
     asciidoctor -D /documents/output/ index.adoc
 ----
diff --git a/docs/logs.adoc b/docs/logs.adoc
index a3fd0a1..df37632 100644
--- a/docs/logs.adoc
+++ b/docs/logs.adoc
@@ -19,8 +19,8 @@ $ docker run -d
 --name selenoid                                 \
 -p 4444:4444                                    \
 -v /var/run/docker.sock:/var/run/docker.sock    \
--v `pwd`/config/:/etc/selenoid/:ro              \
--v `pwd`/logs/:/opt/selenoid/logs/              \
+-v /your/directory/config/:/etc/selenoid/:ro              \
+-v /your/directory/logs/:/opt/selenoid/logs/              \
 aerokube/selenoid:latest-release -log-output-dir /opt/selenoid/logs
 ----
 
diff --git a/docs/starting-selenoid-manually.adoc b/docs/starting-selenoid-manually.adoc
index 4ad79a0..b16a950 100644
--- a/docs/starting-selenoid-manually.adoc
+++ b/docs/starting-selenoid-manually.adoc
@@ -107,7 +107,7 @@ docker run -d                                   \
 --name selenoid                                 \
 -p 4444:4444                                    \
 -v /var/run/docker.sock:/var/run/docker.sock    \
--v `pwd`/config/:/etc/selenoid/:ro              \
+-v ./config/:/etc/selenoid/:ro              \
 aerokube/selenoid:latest-release
 ----
 
diff --git a/docs/video.adoc b/docs/video.adoc
index 5e5dc82..bfe5bb0 100644
--- a/docs/video.adoc
+++ b/docs/video.adoc
@@ -21,7 +21,7 @@ $ docker pull selenoid/video-recorder:latest-release
 . When running Selenoid **in Docker container**:
 .. Mount a directory from the host machine (e.g. `~/.aerokube/selenoid/video`) to store video files to `/opt/selenoid/video`.
 .. Pass an additional `OVERRIDE_VIDEO_OUTPUT_DIR` environment variable with absolute path to video directory on host machine. This is required because video recorder container, automatically created by Selenoid should save video to host machine video storage directory.
-. When running Selenoid **as a binary** - videos will be stored in `video` directory inside current working directory. 
+. When running Selenoid **as a binary** - videos will be stored in `video` directory inside current working directory.
 +
 .Example Docker Command
 ----
@@ -29,9 +29,9 @@ $ docker run -d                                 \
 --name selenoid                                 \
 -p 4444:4444                                    \
 -v /var/run/docker.sock:/var/run/docker.sock    \
--v `pwd`/config/:/etc/selenoid/:ro              \
--v `pwd`/video/:/opt/selenoid/video/            \
--e OVERRIDE_VIDEO_OUTPUT_DIR=`pwd`/video/       \
+-v /your/directory/config/:/etc/selenoid/:ro              \
+-v /your/directory/video/:/opt/selenoid/video/            \
+-e OVERRIDE_VIDEO_OUTPUT_DIR=/your/directory/video/       \
 aerokube/selenoid:latest-release
 ----
 
diff --git a/go.mod b/go.mod
index c4d7ac6..db4e24c 100644
--- a/go.mod
+++ b/go.mod
@@ -1,6 +1,6 @@
 module github.com/aerokube/selenoid
 
-		go 1.15
+go 1.16
 
 require (
 	github.com/aandryashin/matchers v0.0.0-20161126170413-435295ea180e
diff --git a/selenoid.go b/selenoid.go
index d84a7f0..41222d9 100644
--- a/selenoid.go
+++ b/selenoid.go
@@ -199,11 +199,19 @@ func create(w http.ResponseWriter, r *http.Request) {
 	}
 	u := startedService.Url
 	cancel := startedService.Cancel
+
+	browser.Caps.ExtensionCapabilities = nil
+	browser.W3CCaps.Caps.ExtensionCapabilities = nil
+	for _, c := range browser.W3CCaps.FirstMatch {
+		c.ExtensionCapabilities = nil
+	}
+
 	var resp *http.Response
 	i := 1
 	for ; ; i++ {
 		r.URL.Host, r.URL.Path = u.Host, path.Join(u.Path, r.URL.Path)
-		req, _ := http.NewRequest(http.MethodPost, r.URL.String(), bytes.NewReader(body))
+		newBody, _ := json.Marshal(browser)
+		req, _ := http.NewRequest(http.MethodPost, r.URL.String(), bytes.NewReader(newBody))
 		ctx, done := context.WithTimeout(r.Context(), newSessionAttemptTimeout)
 		defer done()
 		log.Printf("[%d] [SESSION_ATTEMPTED] [%s] [%d]", requestId, u.String(), i)
@@ -495,6 +503,9 @@ func reverseProxy(hostFn func(sess *session.Session) string, status string) func
 		sid, remainingPath := splitRequestPath(r.URL.Path)
 		sess, ok := sessions.Get(sid)
 		if ok {
+			sess.TimeoutCh = onTimeout(sess.Timeout, func() {
+				request{r}.session(sid).Delete(requestId)
+			})
 			(&httputil.ReverseProxy{
 				Director: func(r *http.Request) {
 					r.URL.Scheme = "http"
diff --git a/session/session.go b/session/session.go
index ca53058..3aa5393 100644
--- a/session/session.go
+++ b/session/session.go
@@ -49,10 +49,6 @@ func (c *Caps) ProcessExtensionCapabilities() {
 
 	if c.ExtensionCapabilities != nil {
 		mergo.Merge(c, *c.ExtensionCapabilities, mergo.WithOverride) //We probably need to handle returned error
-
-		//According to Selenium standard vendor-specific capabilities for
-		//intermediary node should not be proxied to endpoint node
-		c.ExtensionCapabilities = nil
 	}
 }
 


Test patch:
diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml
index 3d45484..f545512 100644
--- a/.github/workflows/test.yml
+++ b/.github/workflows/test.yml
@@ -12,7 +12,7 @@ jobs:
       - name: Setup Golang
         uses: actions/setup-go@v2
         with:
-          go-version: 1.15.x
+          go-version: 1.16.x
 
       - uses: actions/cache@v1
         with:
diff --git a/selenoid_test.go b/selenoid_test.go
index c1836cf..34fae77 100644
--- a/selenoid_test.go
+++ b/selenoid_test.go
@@ -4,6 +4,7 @@ import (
 	"bytes"
 	"context"
 	"fmt"
+	"github.com/aerokube/selenoid/session"
 	"github.com/mafredri/cdp"
 	"github.com/mafredri/cdp/rpcc"
 	"io/ioutil"
@@ -390,6 +391,28 @@ func TestSessionCreatedRedirect(t *testing.T) {
 	queue.Release()
 }
 
+func TestSessionCreatedRemoveExtensionCapabilities(t *testing.T) {
+	extensionCapsMissing := true
+	var browser struct {
+		W3CCaps struct {
+			Caps session.Caps `json:"alwaysMatch"`
+		} `json:"capabilities"`
+	}
+
+	root := http.NewServeMux()
+	root.Handle("/wd/hub/", http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
+		err := json.NewDecoder(r.Body).Decode(&browser)
+		AssertThat(t, err, Is{nil})
+		extensionCapsMissing = browser.W3CCaps.Caps.ExtensionCapabilities == nil
+	}))
+	manager = &HTTPTest{Handler: root}
+
+	resp, err := httpClient.Post(With(srv.URL).Path("/wd/hub/session"), "", bytes.NewReader([]byte(`{"capabilities":{"alwaysMatch":{"browserName": "firefox", "selenoid:options":{"enableVNC": true}}}}`)))
+	AssertThat(t, err, Is{nil})
+	AssertThat(t, resp, Code{http.StatusOK})
+	AssertThat(t, extensionCapsMissing, Is{true})
+}
+
 func TestProxySession(t *testing.T) {
 	manager = &HTTPTest{Handler: Selenium()}