mirror of
https://github.com/strukturag/nextcloud-spreed-signaling
synced 2024-06-15 20:25:12 +02:00
Don't include empty "auth" field in hello client messages.
This commit is contained in:
parent
6960912681
commit
3721fb131f
|
@ -387,7 +387,7 @@ type HelloClientMessage struct {
|
||||||
Features []string `json:"features,omitempty"`
|
Features []string `json:"features,omitempty"`
|
||||||
|
|
||||||
// The authentication credentials.
|
// The authentication credentials.
|
||||||
Auth HelloClientMessageAuth `json:"auth"`
|
Auth *HelloClientMessageAuth `json:"auth,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *HelloClientMessage) CheckValid() error {
|
func (m *HelloClientMessage) CheckValid() error {
|
||||||
|
@ -395,7 +395,7 @@ func (m *HelloClientMessage) CheckValid() error {
|
||||||
return InvalidHelloVersion
|
return InvalidHelloVersion
|
||||||
}
|
}
|
||||||
if m.ResumeId == "" {
|
if m.ResumeId == "" {
|
||||||
if m.Auth.Params == nil || len(*m.Auth.Params) == 0 {
|
if m.Auth == nil || m.Auth.Params == nil || len(*m.Auth.Params) == 0 {
|
||||||
return fmt.Errorf("params missing")
|
return fmt.Errorf("params missing")
|
||||||
}
|
}
|
||||||
if m.Auth.Type == "" {
|
if m.Auth.Type == "" {
|
||||||
|
|
|
@ -95,14 +95,14 @@ func TestHelloClientMessage(t *testing.T) {
|
||||||
// Hello version 1
|
// Hello version 1
|
||||||
&HelloClientMessage{
|
&HelloClientMessage{
|
||||||
Version: HelloVersionV1,
|
Version: HelloVersionV1,
|
||||||
Auth: HelloClientMessageAuth{
|
Auth: &HelloClientMessageAuth{
|
||||||
Params: &json.RawMessage{'{', '}'},
|
Params: &json.RawMessage{'{', '}'},
|
||||||
Url: "https://domain.invalid",
|
Url: "https://domain.invalid",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
&HelloClientMessage{
|
&HelloClientMessage{
|
||||||
Version: HelloVersionV1,
|
Version: HelloVersionV1,
|
||||||
Auth: HelloClientMessageAuth{
|
Auth: &HelloClientMessageAuth{
|
||||||
Type: "client",
|
Type: "client",
|
||||||
Params: &json.RawMessage{'{', '}'},
|
Params: &json.RawMessage{'{', '}'},
|
||||||
Url: "https://domain.invalid",
|
Url: "https://domain.invalid",
|
||||||
|
@ -110,7 +110,7 @@ func TestHelloClientMessage(t *testing.T) {
|
||||||
},
|
},
|
||||||
&HelloClientMessage{
|
&HelloClientMessage{
|
||||||
Version: HelloVersionV1,
|
Version: HelloVersionV1,
|
||||||
Auth: HelloClientMessageAuth{
|
Auth: &HelloClientMessageAuth{
|
||||||
Type: "internal",
|
Type: "internal",
|
||||||
Params: (*json.RawMessage)(&internalAuthParams),
|
Params: (*json.RawMessage)(&internalAuthParams),
|
||||||
},
|
},
|
||||||
|
@ -122,14 +122,14 @@ func TestHelloClientMessage(t *testing.T) {
|
||||||
// Hello version 2
|
// Hello version 2
|
||||||
&HelloClientMessage{
|
&HelloClientMessage{
|
||||||
Version: HelloVersionV2,
|
Version: HelloVersionV2,
|
||||||
Auth: HelloClientMessageAuth{
|
Auth: &HelloClientMessageAuth{
|
||||||
Params: (*json.RawMessage)(&tokenAuthParams),
|
Params: (*json.RawMessage)(&tokenAuthParams),
|
||||||
Url: "https://domain.invalid",
|
Url: "https://domain.invalid",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
&HelloClientMessage{
|
&HelloClientMessage{
|
||||||
Version: HelloVersionV2,
|
Version: HelloVersionV2,
|
||||||
Auth: HelloClientMessageAuth{
|
Auth: &HelloClientMessageAuth{
|
||||||
Type: "client",
|
Type: "client",
|
||||||
Params: (*json.RawMessage)(&tokenAuthParams),
|
Params: (*json.RawMessage)(&tokenAuthParams),
|
||||||
Url: "https://domain.invalid",
|
Url: "https://domain.invalid",
|
||||||
|
@ -147,40 +147,40 @@ func TestHelloClientMessage(t *testing.T) {
|
||||||
&HelloClientMessage{Version: HelloVersionV1},
|
&HelloClientMessage{Version: HelloVersionV1},
|
||||||
&HelloClientMessage{
|
&HelloClientMessage{
|
||||||
Version: HelloVersionV1,
|
Version: HelloVersionV1,
|
||||||
Auth: HelloClientMessageAuth{
|
Auth: &HelloClientMessageAuth{
|
||||||
Params: &json.RawMessage{'{', '}'},
|
Params: &json.RawMessage{'{', '}'},
|
||||||
Type: "invalid-type",
|
Type: "invalid-type",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
&HelloClientMessage{
|
&HelloClientMessage{
|
||||||
Version: HelloVersionV1,
|
Version: HelloVersionV1,
|
||||||
Auth: HelloClientMessageAuth{
|
Auth: &HelloClientMessageAuth{
|
||||||
Url: "https://domain.invalid",
|
Url: "https://domain.invalid",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
&HelloClientMessage{
|
&HelloClientMessage{
|
||||||
Version: HelloVersionV1,
|
Version: HelloVersionV1,
|
||||||
Auth: HelloClientMessageAuth{
|
Auth: &HelloClientMessageAuth{
|
||||||
Params: &json.RawMessage{'{', '}'},
|
Params: &json.RawMessage{'{', '}'},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
&HelloClientMessage{
|
&HelloClientMessage{
|
||||||
Version: HelloVersionV1,
|
Version: HelloVersionV1,
|
||||||
Auth: HelloClientMessageAuth{
|
Auth: &HelloClientMessageAuth{
|
||||||
Params: &json.RawMessage{'{', '}'},
|
Params: &json.RawMessage{'{', '}'},
|
||||||
Url: "invalid-url",
|
Url: "invalid-url",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
&HelloClientMessage{
|
&HelloClientMessage{
|
||||||
Version: HelloVersionV1,
|
Version: HelloVersionV1,
|
||||||
Auth: HelloClientMessageAuth{
|
Auth: &HelloClientMessageAuth{
|
||||||
Type: "internal",
|
Type: "internal",
|
||||||
Params: &json.RawMessage{'{', '}'},
|
Params: &json.RawMessage{'{', '}'},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
&HelloClientMessage{
|
&HelloClientMessage{
|
||||||
Version: HelloVersionV1,
|
Version: HelloVersionV1,
|
||||||
Auth: HelloClientMessageAuth{
|
Auth: &HelloClientMessageAuth{
|
||||||
Type: "internal",
|
Type: "internal",
|
||||||
Params: &json.RawMessage{'x', 'y', 'z'}, // Invalid JSON.
|
Params: &json.RawMessage{'x', 'y', 'z'}, // Invalid JSON.
|
||||||
},
|
},
|
||||||
|
@ -188,33 +188,33 @@ func TestHelloClientMessage(t *testing.T) {
|
||||||
// Hello version 2
|
// Hello version 2
|
||||||
&HelloClientMessage{
|
&HelloClientMessage{
|
||||||
Version: HelloVersionV2,
|
Version: HelloVersionV2,
|
||||||
Auth: HelloClientMessageAuth{
|
Auth: &HelloClientMessageAuth{
|
||||||
Url: "https://domain.invalid",
|
Url: "https://domain.invalid",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
&HelloClientMessage{
|
&HelloClientMessage{
|
||||||
Version: HelloVersionV2,
|
Version: HelloVersionV2,
|
||||||
Auth: HelloClientMessageAuth{
|
Auth: &HelloClientMessageAuth{
|
||||||
Params: (*json.RawMessage)(&tokenAuthParams),
|
Params: (*json.RawMessage)(&tokenAuthParams),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
&HelloClientMessage{
|
&HelloClientMessage{
|
||||||
Version: HelloVersionV2,
|
Version: HelloVersionV2,
|
||||||
Auth: HelloClientMessageAuth{
|
Auth: &HelloClientMessageAuth{
|
||||||
Params: (*json.RawMessage)(&tokenAuthParams),
|
Params: (*json.RawMessage)(&tokenAuthParams),
|
||||||
Url: "invalid-url",
|
Url: "invalid-url",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
&HelloClientMessage{
|
&HelloClientMessage{
|
||||||
Version: HelloVersionV2,
|
Version: HelloVersionV2,
|
||||||
Auth: HelloClientMessageAuth{
|
Auth: &HelloClientMessageAuth{
|
||||||
Params: (*json.RawMessage)(&internalAuthParams),
|
Params: (*json.RawMessage)(&internalAuthParams),
|
||||||
Url: "https://domain.invalid",
|
Url: "https://domain.invalid",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
&HelloClientMessage{
|
&HelloClientMessage{
|
||||||
Version: HelloVersionV2,
|
Version: HelloVersionV2,
|
||||||
Auth: HelloClientMessageAuth{
|
Auth: &HelloClientMessageAuth{
|
||||||
Params: &json.RawMessage{'x', 'y', 'z'}, // Invalid JSON.
|
Params: &json.RawMessage{'x', 'y', 'z'}, // Invalid JSON.
|
||||||
Url: "https://domain.invalid",
|
Url: "https://domain.invalid",
|
||||||
},
|
},
|
||||||
|
|
|
@ -601,7 +601,7 @@ func main() {
|
||||||
Type: "hello",
|
Type: "hello",
|
||||||
Hello: &signaling.HelloClientMessage{
|
Hello: &signaling.HelloClientMessage{
|
||||||
Version: signaling.HelloVersionV1,
|
Version: signaling.HelloVersionV1,
|
||||||
Auth: signaling.HelloClientMessageAuth{
|
Auth: &signaling.HelloClientMessageAuth{
|
||||||
Url: backendUrl + "/auth",
|
Url: backendUrl + "/auth",
|
||||||
Params: &json.RawMessage{'{', '}'},
|
Params: &json.RawMessage{'{', '}'},
|
||||||
},
|
},
|
||||||
|
|
|
@ -493,7 +493,7 @@ func (c *TestClient) SendHelloParams(url string, version string, clientType stri
|
||||||
Hello: &HelloClientMessage{
|
Hello: &HelloClientMessage{
|
||||||
Version: version,
|
Version: version,
|
||||||
Features: features,
|
Features: features,
|
||||||
Auth: HelloClientMessageAuth{
|
Auth: &HelloClientMessageAuth{
|
||||||
Type: clientType,
|
Type: clientType,
|
||||||
Url: url,
|
Url: url,
|
||||||
Params: (*json.RawMessage)(&data),
|
Params: (*json.RawMessage)(&data),
|
||||||
|
|
Loading…
Reference in a new issue