mirror of
https://gitlab.alpinelinux.org/alpine/aports.git
synced 2025-07-25 20:25:28 +03:00
go 1.16 is defaulting to go modules, but this project does not provide any, so provide them ourselves. There are also some build issues that are fixed.
222 lines
10 KiB
Diff
222 lines
10 KiB
Diff
diff --git a/Makefile.am b/Makefile.am
|
|
index 9933adf..a4a2260 100644
|
|
--- a/Makefile.am
|
|
+++ b/Makefile.am
|
|
@@ -74,7 +74,7 @@ dependencies.tsv:
|
|
rm -rf $$TMP
|
|
|
|
binary:
|
|
- GOPATH=$(GOPATH) $(GO) build $(GOBUILDFLAGS) -o bin/$(EXENAME) -ldflags '$(INTERNALLDFLAGS)' app/$(EXENAME)
|
|
+ GOPATH=$(GOPATH) $(GO) build $(GOBUILDFLAGS) -o bin/$(EXENAME) -ldflags '$(INTERNALLDFLAGS)' github.com/strukturag/spreed-webrtc/src/app/$(EXENAME)
|
|
|
|
binaryrace: GOBUILDFLAGS := $(GOBUILDFLAGS) -race
|
|
binaryrace: binary
|
|
@@ -88,7 +88,7 @@ gofmt:
|
|
fmt: gofmt
|
|
|
|
test:
|
|
- GOPATH=$(GOPATH) $(GO) test -v $(GOTESTFLAGS) app/... ./go/...
|
|
+ GOPATH=$(GOPATH) $(GO) test -v $(GOTESTFLAGS) github.com/strukturag/spreed-webrtc/src/app/... github.com/strukturag/spreed-webrtc/go/...
|
|
|
|
dist_gopath: $(DIST_SRC)
|
|
[ -d $(SYSTEM_GOPATH) ] && \
|
|
diff --git a/go/channelling/hub.go b/go/channelling/hub.go
|
|
index 068e1e8..bccd2ce 100644
|
|
--- a/go/channelling/hub.go
|
|
+++ b/go/channelling/hub.go
|
|
@@ -190,7 +190,7 @@ func (h *hub) GetContactID(session *Session, token string) (userid string, err e
|
|
contact := &Contact{}
|
|
err = h.contacts.Decode("contact", token, contact)
|
|
if err != nil {
|
|
- err = fmt.Errorf("Failed to decode incoming contact token", err, token)
|
|
+ err = fmt.Errorf("Failed to decode incoming contact token: %s, %s", err, token)
|
|
return
|
|
}
|
|
// Use the userid which is not ours from the contact data.
|
|
@@ -201,7 +201,7 @@ func (h *hub) GetContactID(session *Session, token string) (userid string, err e
|
|
userid = contact.A
|
|
}
|
|
if userid == "" {
|
|
- err = fmt.Errorf("Ignoring foreign contact token", contact.A, contact.B)
|
|
+ err = fmt.Errorf("Ignoring foreign contact token, contact.A: %s, contact.B: %s", contact.A, contact.B)
|
|
}
|
|
|
|
return
|
|
diff --git a/go/channelling/room_manager_test.go b/go/channelling/room_manager_test.go
|
|
index a31f69f..efb69df 100644
|
|
--- a/go/channelling/room_manager_test.go
|
|
+++ b/go/channelling/room_manager_test.go
|
|
@@ -24,13 +24,11 @@ package channelling
|
|
import (
|
|
"regexp"
|
|
"testing"
|
|
-
|
|
- "github.com/strukturag/spreed-webrtc/go/channelling"
|
|
)
|
|
|
|
func NewTestRoomManager() (RoomManager, *Config) {
|
|
config := &Config{
|
|
- RoomTypeDefault: channelling.RoomTypeRoom,
|
|
+ RoomTypeDefault: RoomTypeRoom,
|
|
}
|
|
return NewRoomManager(config, nil), config
|
|
}
|
|
@@ -41,16 +39,16 @@ func Test_RoomManager_JoinRoom_ReturnsAnErrorForUnauthenticatedSessionsWhenCreat
|
|
config.AuthorizeRoomCreation = true
|
|
|
|
unauthenticatedSession := &Session{}
|
|
- _, err := roomManager.JoinRoom(channelling.RoomTypeRoom+":foo", "foo", channelling.RoomTypeRoom, nil, unauthenticatedSession, false, nil)
|
|
+ _, err := roomManager.JoinRoom(RoomTypeRoom+":foo", "foo", RoomTypeRoom, nil, unauthenticatedSession, false, nil)
|
|
assertDataError(t, err, "room_join_requires_account")
|
|
|
|
authenticatedSession := &Session{userid: "9870457"}
|
|
- _, err = roomManager.JoinRoom(channelling.RoomTypeRoom+":foo", "foo", channelling.RoomTypeRoom, nil, authenticatedSession, true, nil)
|
|
+ _, err = roomManager.JoinRoom(RoomTypeRoom+":foo", "foo", RoomTypeRoom, nil, authenticatedSession, true, nil)
|
|
if err != nil {
|
|
t.Fatalf("Unexpected error %v joining room while authenticated", err)
|
|
}
|
|
|
|
- _, err = roomManager.JoinRoom(channelling.RoomTypeRoom+":foo", "foo", channelling.RoomTypeRoom, nil, unauthenticatedSession, false, nil)
|
|
+ _, err = roomManager.JoinRoom(RoomTypeRoom+":foo", "foo", RoomTypeRoom, nil, unauthenticatedSession, false, nil)
|
|
if err != nil {
|
|
t.Fatalf("Unexpected error %v joining room while unauthenticated", err)
|
|
}
|
|
@@ -62,16 +60,16 @@ func Test_RoomManager_JoinRoom_ReturnsAnErrorForUnauthenticatedSessionsWhenJoinR
|
|
config.AuthorizeRoomJoin = true
|
|
|
|
unauthenticatedSession := &Session{}
|
|
- _, err := roomManager.JoinRoom(channelling.RoomTypeRoom+":foo", "foo", channelling.RoomTypeRoom, nil, unauthenticatedSession, false, nil)
|
|
+ _, err := roomManager.JoinRoom(RoomTypeRoom+":foo", "foo", RoomTypeRoom, nil, unauthenticatedSession, false, nil)
|
|
assertDataError(t, err, "room_join_requires_account")
|
|
|
|
authenticatedSession := &Session{userid: "9870457"}
|
|
- _, err = roomManager.JoinRoom(channelling.RoomTypeRoom+":foo", "foo", channelling.RoomTypeRoom, nil, authenticatedSession, true, nil)
|
|
+ _, err = roomManager.JoinRoom(RoomTypeRoom+":foo", "foo", RoomTypeRoom, nil, authenticatedSession, true, nil)
|
|
if err != nil {
|
|
t.Fatalf("Unexpected error %v joining room while authenticated", err)
|
|
}
|
|
|
|
- _, err = roomManager.JoinRoom(channelling.RoomTypeRoom+":foo", "foo", channelling.RoomTypeRoom, nil, unauthenticatedSession, false, nil)
|
|
+ _, err = roomManager.JoinRoom(RoomTypeRoom+":foo", "foo", RoomTypeRoom, nil, unauthenticatedSession, false, nil)
|
|
assertDataError(t, err, "room_join_requires_account")
|
|
}
|
|
|
|
@@ -81,16 +79,16 @@ func Test_RoomManager_JoinPublicRoom_ForUnauthenticatedSessionsWhenCreationRequi
|
|
config.AuthorizeRoomCreation = true
|
|
|
|
unauthenticatedSession := &Session{}
|
|
- _, err := roomManager.JoinRoom(channelling.RoomTypeRoom+":public", "public", channelling.RoomTypeRoom, nil, unauthenticatedSession, false, nil)
|
|
+ _, err := roomManager.JoinRoom(RoomTypeRoom+":public", "public", RoomTypeRoom, nil, unauthenticatedSession, false, nil)
|
|
assertDataError(t, err, "room_join_requires_account")
|
|
|
|
config.PublicRoomNames = regexp.MustCompile("^public$")
|
|
- _, err = roomManager.JoinRoom(channelling.RoomTypeRoom+":public", "public", channelling.RoomTypeRoom, nil, unauthenticatedSession, false, nil)
|
|
+ _, err = roomManager.JoinRoom(RoomTypeRoom+":public", "public", RoomTypeRoom, nil, unauthenticatedSession, false, nil)
|
|
if err != nil {
|
|
t.Fatalf("Unexpected error %v joining public room", err)
|
|
}
|
|
|
|
- _, err = roomManager.JoinRoom(channelling.RoomTypeRoom+":private", "private", channelling.RoomTypeRoom, nil, unauthenticatedSession, false, nil)
|
|
+ _, err = roomManager.JoinRoom(RoomTypeRoom+":private", "private", RoomTypeRoom, nil, unauthenticatedSession, false, nil)
|
|
assertDataError(t, err, "room_join_requires_account")
|
|
}
|
|
|
|
@@ -100,27 +98,27 @@ func Test_RoomManager_JoinPublicRoom_ForUnauthenticatedSessionsWhenJoinRequiresA
|
|
config.AuthorizeRoomJoin = true
|
|
|
|
authenticatedSession := &Session{userid: "9870457"}
|
|
- _, err := roomManager.JoinRoom(channelling.RoomTypeRoom+":public", "public", channelling.RoomTypeRoom, nil, authenticatedSession, true, nil)
|
|
+ _, err := roomManager.JoinRoom(RoomTypeRoom+":public", "public", RoomTypeRoom, nil, authenticatedSession, true, nil)
|
|
if err != nil {
|
|
t.Fatalf("Unexpected error %v joining room while authenticated", err)
|
|
}
|
|
|
|
unauthenticatedSession := &Session{}
|
|
- _, err = roomManager.JoinRoom(channelling.RoomTypeRoom+":public", "public", channelling.RoomTypeRoom, nil, unauthenticatedSession, false, nil)
|
|
+ _, err = roomManager.JoinRoom(RoomTypeRoom+":public", "public", RoomTypeRoom, nil, unauthenticatedSession, false, nil)
|
|
assertDataError(t, err, "room_join_requires_account")
|
|
|
|
config.PublicRoomNames = regexp.MustCompile("^public$")
|
|
- _, err = roomManager.JoinRoom(channelling.RoomTypeRoom+":public", "public", channelling.RoomTypeRoom, nil, unauthenticatedSession, false, nil)
|
|
+ _, err = roomManager.JoinRoom(RoomTypeRoom+":public", "public", RoomTypeRoom, nil, unauthenticatedSession, false, nil)
|
|
if err != nil {
|
|
t.Fatalf("Unexpected error %v joining public room", err)
|
|
}
|
|
|
|
- _, err = roomManager.JoinRoom(channelling.RoomTypeRoom+":private", "private", channelling.RoomTypeRoom, nil, authenticatedSession, true, nil)
|
|
+ _, err = roomManager.JoinRoom(RoomTypeRoom+":private", "private", RoomTypeRoom, nil, authenticatedSession, true, nil)
|
|
if err != nil {
|
|
t.Fatalf("Unexpected error %v joining room while authenticated", err)
|
|
}
|
|
|
|
- _, err = roomManager.JoinRoom(channelling.RoomTypeRoom+":private", "private", channelling.RoomTypeRoom, nil, unauthenticatedSession, false, nil)
|
|
+ _, err = roomManager.JoinRoom(RoomTypeRoom+":private", "private", RoomTypeRoom, nil, unauthenticatedSession, false, nil)
|
|
assertDataError(t, err, "room_join_requires_account")
|
|
}
|
|
|
|
@@ -133,36 +131,36 @@ func Test_RoomManager_UpdateRoom_ReturnsAnErrorIfNoRoomHasBeenJoined(t *testing.
|
|
|
|
func Test_RoomManager_UpdateRoom_ReturnsAnErrorIfUpdatingAnUnjoinedRoom(t *testing.T) {
|
|
roomManager, _ := NewTestRoomManager()
|
|
- session := &Session{Hello: true, Roomid: channelling.RoomTypeRoom + ":foo"}
|
|
+ session := &Session{Hello: true, Roomid: RoomTypeRoom + ":foo"}
|
|
_, err := roomManager.UpdateRoom(session, &DataRoom{Name: "bar"})
|
|
assertDataError(t, err, "not_in_room")
|
|
}
|
|
|
|
func Test_RoomManager_UpdateRoom_ReturnsACorrectlyTypedDocument(t *testing.T) {
|
|
roomManager, _ := NewTestRoomManager()
|
|
- session := &Session{Hello: true, Roomid: channelling.RoomTypeRoom + ":foo"}
|
|
+ session := &Session{Hello: true, Roomid: RoomTypeRoom + ":foo"}
|
|
room, err := roomManager.UpdateRoom(session, &DataRoom{Name: "foo"})
|
|
if err != nil {
|
|
t.Fatalf("Unexpected error %v updating room", err)
|
|
}
|
|
|
|
- if room.Type != channelling.RoomTypeRoom {
|
|
- t.Errorf("Expected document type to be %s, but was %v", channelling.RoomTypeRoom, room.Type)
|
|
+ if room.Type != RoomTypeRoom {
|
|
+ t.Errorf("Expected document type to be %s, but was %v", RoomTypeRoom, room.Type)
|
|
}
|
|
}
|
|
|
|
func Test_RoomManager_TypeThroughNats(t *testing.T) {
|
|
theRoomManager, _ := NewTestRoomManager()
|
|
rm := theRoomManager.(*roomManager)
|
|
- if rt := rm.getConfiguredRoomType("foo"); rt != channelling.RoomTypeRoom {
|
|
- t.Errorf("Expected room type to be %s, but was %v", channelling.RoomTypeRoom, rt)
|
|
+ if rt := rm.getConfiguredRoomType("foo"); rt != RoomTypeRoom {
|
|
+ t.Errorf("Expected room type to be %s, but was %v", RoomTypeRoom, rt)
|
|
}
|
|
rm.setNatsRoomType(&roomTypeMessage{Path: "foo", Type: "Conference"})
|
|
if rt := rm.getConfiguredRoomType("foo"); rt != "Conference" {
|
|
t.Errorf("Expected room type to be %s, but was %v", "Conference", rt)
|
|
}
|
|
rm.setNatsRoomType(&roomTypeMessage{Path: "foo", Type: ""})
|
|
- if rt := rm.getConfiguredRoomType("foo"); rt != channelling.RoomTypeRoom {
|
|
- t.Errorf("Expected room type to be %s, but was %v", channelling.RoomTypeRoom, rt)
|
|
+ if rt := rm.getConfiguredRoomType("foo"); rt != RoomTypeRoom {
|
|
+ t.Errorf("Expected room type to be %s, but was %v", RoomTypeRoom, rt)
|
|
}
|
|
}
|
|
diff --git a/go/channelling/roomworker_test.go b/go/channelling/roomworker_test.go
|
|
index 21af563..616bced 100644
|
|
--- a/go/channelling/roomworker_test.go
|
|
+++ b/go/channelling/roomworker_test.go
|
|
@@ -23,14 +23,12 @@ package channelling
|
|
|
|
import (
|
|
"testing"
|
|
-
|
|
- "github.com/strukturag/spreed-webrtc/go/channelling"
|
|
)
|
|
|
|
const (
|
|
- testRoomID string = channelling.RoomTypeRoom + ":a-room-name"
|
|
+ testRoomID string = RoomTypeRoom + ":a-room-name"
|
|
testRoomName string = "a-room-name"
|
|
- testRoomType string = channelling.RoomTypeRoom
|
|
+ testRoomType string = RoomTypeRoom
|
|
)
|
|
|
|
func NewTestRoomWorker() RoomWorker {
|