Skip to content
Snippets Groups Projects
Unverified Commit 68d09f70 authored by Vasilii Iakliushin's avatar Vasilii Iakliushin Committed by GitLab
Browse files

Merge branch 'cherry-pick-b5cf54b4' into '17-1-stable-ee'

Backport 17.1: Field needs to be called Url

See merge request https://gitlab.com/gitlab-org/gitlab/-/merge_requests/158332



Merged-by: default avatarVasilii Iakliushin <viakliushin@gitlab.com>
Approved-by: default avatarIgor Drozdov <idrozdov@gitlab.com>
Approved-by: default avatarJay McCure <jmccure@gitlab.com>
Reviewed-by: default avatarVasilii Iakliushin <viakliushin@gitlab.com>
parents 88339e05 b6621a64
No related merge requests found
...@@ -174,7 +174,7 @@ func webSocketHandler(upgrader *websocket.Upgrader, connCh chan connWithReq) htt ...@@ -174,7 +174,7 @@ func webSocketHandler(upgrader *websocket.Upgrader, connCh chan connWithReq) htt
func channelOkBody(remote *httptest.Server, header http.Header, subprotocols ...string) *api.Response { func channelOkBody(remote *httptest.Server, header http.Header, subprotocols ...string) *api.Response {
out := &api.Response{ out := &api.Response{
Channel: &api.ChannelSettings{ Channel: &api.ChannelSettings{
WsURL: websocketURL(remote.URL), Url: websocketURL(remote.URL),
Header: header, Header: header,
Subprotocols: subprotocols, Subprotocols: subprotocols,
MaxSessionTime: 0, MaxSessionTime: 0,
......
...@@ -19,7 +19,7 @@ type ChannelSettings struct { ...@@ -19,7 +19,7 @@ type ChannelSettings struct {
Subprotocols []string Subprotocols []string
// The websocket URL to connect to. // The websocket URL to connect to.
WsURL string Url string //nolint:revive,stylecheck // when JSON decoding, the value is provided via 'url'
// Any headers (e.g., Authorization) to send with the websocket request // Any headers (e.g., Authorization) to send with the websocket request
Header http.Header Header http.Header
...@@ -35,7 +35,7 @@ type ChannelSettings struct { ...@@ -35,7 +35,7 @@ type ChannelSettings struct {
// URL parses the websocket URL in the ChannelSettings and returns a *url.URL. // URL parses the websocket URL in the ChannelSettings and returns a *url.URL.
func (t *ChannelSettings) URL() (*url.URL, error) { func (t *ChannelSettings) URL() (*url.URL, error) {
return url.Parse(t.WsURL) return url.Parse(t.Url)
} }
// Dialer returns a websocket Dialer configured with the settings from ChannelSettings. // Dialer returns a websocket Dialer configured with the settings from ChannelSettings.
...@@ -72,7 +72,7 @@ func (t *ChannelSettings) Clone() *ChannelSettings { ...@@ -72,7 +72,7 @@ func (t *ChannelSettings) Clone() *ChannelSettings {
// Dial establishes a websocket connection using the settings from ChannelSettings. // Dial establishes a websocket connection using the settings from ChannelSettings.
// It returns a websocket connection, an HTTP response, and an error if any. // It returns a websocket connection, an HTTP response, and an error if any.
func (t *ChannelSettings) Dial() (*websocket.Conn, *http.Response, error) { func (t *ChannelSettings) Dial() (*websocket.Conn, *http.Response, error) {
return t.Dialer().Dial(t.WsURL, t.Header) return t.Dialer().Dial(t.Url, t.Header)
} }
// Validate checks if the ChannelSettings instance is valid. // Validate checks if the ChannelSettings instance is valid.
...@@ -133,7 +133,7 @@ func (t *ChannelSettings) IsEqual(other *ChannelSettings) bool { ...@@ -133,7 +133,7 @@ func (t *ChannelSettings) IsEqual(other *ChannelSettings) bool {
} }
} }
return t.WsURL == other.WsURL && return t.Url == other.Url &&
t.CAPem == other.CAPem && t.CAPem == other.CAPem &&
t.MaxSessionTime == other.MaxSessionTime t.MaxSessionTime == other.MaxSessionTime
} }
...@@ -9,7 +9,7 @@ import ( ...@@ -9,7 +9,7 @@ import (
func channel(url string, subprotocols ...string) *ChannelSettings { func channel(url string, subprotocols ...string) *ChannelSettings {
return &ChannelSettings{ return &ChannelSettings{
WsURL: url, Url: url,
Subprotocols: subprotocols, Subprotocols: subprotocols,
MaxSessionTime: 0, MaxSessionTime: 0,
} }
...@@ -146,7 +146,7 @@ func TestIsEqual(t *testing.T) { ...@@ -146,7 +146,7 @@ func TestIsEqual(t *testing.T) {
{chann, chann, true}, {chann, chann, true},
{chann.Clone(), chann.Clone(), true}, {chann.Clone(), chann.Clone(), true},
{chann, channel("foo:"), false}, {chann, channel("foo:"), false},
{chann, channel(chann.WsURL), false}, {chann, channel(chann.Url), false},
{header(chann), header(chann), true}, {header(chann), header(chann), true},
{channHeader2, channHeader2, true}, {channHeader2, channHeader2, true},
{channHeader3, channHeader3, true}, {channHeader3, channHeader3, true},
......
...@@ -19,7 +19,7 @@ func checkerSeries(values ...*api.ChannelSettings) AuthCheckerFunc { ...@@ -19,7 +19,7 @@ func checkerSeries(values ...*api.ChannelSettings) AuthCheckerFunc {
} }
func TestAuthCheckerStopsWhenAuthFails(t *testing.T) { func TestAuthCheckerStopsWhenAuthFails(t *testing.T) {
template := &api.ChannelSettings{WsURL: "ws://example.com"} template := &api.ChannelSettings{Url: "ws://example.com"}
stopCh := make(chan error) stopCh := make(chan error)
series := checkerSeries(template, template, template) series := checkerSeries(template, template, template)
ac := NewAuthChecker(series, template, stopCh) ac := NewAuthChecker(series, template, stopCh)
...@@ -35,9 +35,9 @@ func TestAuthCheckerStopsWhenAuthFails(t *testing.T) { ...@@ -35,9 +35,9 @@ func TestAuthCheckerStopsWhenAuthFails(t *testing.T) {
} }
func TestAuthCheckerStopsWhenAuthChanges(t *testing.T) { func TestAuthCheckerStopsWhenAuthChanges(t *testing.T) {
template := &api.ChannelSettings{WsURL: "ws://example.com"} template := &api.ChannelSettings{Url: "ws://example.com"}
changed := template.Clone() changed := template.Clone()
changed.WsURL = "wss://example.com" changed.Url = "wss://example.com"
stopCh := make(chan error) stopCh := make(chan error)
series := checkerSeries(template, changed, template) series := checkerSeries(template, changed, template)
ac := NewAuthChecker(series, template, stopCh) ac := NewAuthChecker(series, template, stopCh)
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment