Skip to content
This repository has been archived by the owner on Dec 17, 2024. It is now read-only.

Commit

Permalink
Merge pull request #1074 from vania-pooh/master
Browse files Browse the repository at this point in the history
Remaining release 1.10.2 fixes
  • Loading branch information
aandryashin authored Mar 23, 2021
2 parents e89b7ab + 69405ae commit b60fc21
Show file tree
Hide file tree
Showing 12 changed files with 50 additions and 18 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
4 changes: 3 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -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
2 changes: 1 addition & 1 deletion docs/contributing.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -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
----
4 changes: 2 additions & 2 deletions docs/logs.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -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
----

Expand Down
2 changes: 1 addition & 1 deletion docs/starting-selenoid-manually.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -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
----

Expand Down
8 changes: 4 additions & 4 deletions docs/video.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,17 @@ $ 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
----
$ 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
----

Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -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
Expand Down
13 changes: 12 additions & 1 deletion selenoid.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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"
Expand Down
23 changes: 23 additions & 0 deletions selenoid_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"bytes"
"context"
"fmt"
"github.com/aerokube/selenoid/session"
"github.com/mafredri/cdp"
"github.com/mafredri/cdp/rpcc"
"io/ioutil"
Expand Down Expand Up @@ -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()}

Expand Down
4 changes: 0 additions & 4 deletions session/session.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}

Expand Down

0 comments on commit b60fc21

Please sign in to comment.