Skip to content

Commit

Permalink
Remove auth usage from tests
Browse files Browse the repository at this point in the history
  • Loading branch information
bogh committed Mar 20, 2017
1 parent d7e52b4 commit 22ef638
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 17 deletions.
13 changes: 6 additions & 7 deletions server/sms/utils_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,16 @@ package sms
import (
"encoding/json"
"fmt"
"io/ioutil"
"math/rand"
"testing"
"time"

"github.com/cosminrentea/gobbler/protocol"
"github.com/cosminrentea/gobbler/server/auth"
"github.com/cosminrentea/gobbler/server/kvstore"
"github.com/cosminrentea/gobbler/server/router"
"github.com/cosminrentea/gobbler/server/store/dummystore"
"github.com/stretchr/testify/assert"
"io/ioutil"
"math/rand"
"testing"
"time"
)

var (
Expand Down Expand Up @@ -121,9 +121,8 @@ func createGateway(t *testing.T, kvStore kvstore.KVStore) *gateway {
sender := createNexmoSender(t)
config := createConfig()
msgStore := dummystore.New(kvStore)
accessManager := auth.NewAllowAllAccessManager(true)

unstartedRouter := router.New(accessManager, msgStore, kvStore, nil)
unstartedRouter := router.New(msgStore, kvStore, nil)

gw, err := New(unstartedRouter, sender, config)
a.NoError(err)
Expand Down
15 changes: 5 additions & 10 deletions server/websocket/websocket_connector_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (
"github.com/cosminrentea/gobbler/server/router"
"github.com/cosminrentea/gobbler/server/store"
"github.com/cosminrentea/gobbler/testutil"
"github.com/smancke/guble/server/auth"

"github.com/golang/mock/gomock"
"github.com/stretchr/testify/assert"
Expand Down Expand Up @@ -54,7 +53,7 @@ func Test_WebSocket_SubscribeAndUnsubscribe(t *testing.T) {
Send([]byte("#" + protocol.SUCCESS_CANCELED + " /foo")).
Do(doneGroup)

websocket := runNewWebSocket(wsconn, routerMock, messageStore, nil)
websocket := runNewWebSocket(wsconn, routerMock, messageStore)
wg.Wait()

a.Equal(1, len(websocket.receivers))
Expand All @@ -71,7 +70,7 @@ func Test_SendMessage(t *testing.T) {
routerMock.EXPECT().HandleMessage(messageMatcher{path: "/path", message: "Hello, this is a test", header: `{"key": "value"}`})
wsconn.EXPECT().Send([]byte("#send"))

runNewWebSocket(wsconn, routerMock, messageStore, nil)
runNewWebSocket(wsconn, routerMock, messageStore)
}

func Test_AnIncomingMessageIsDelivered(t *testing.T) {
Expand All @@ -82,7 +81,7 @@ func Test_AnIncomingMessageIsDelivered(t *testing.T) {

wsconn.EXPECT().Send(aTestMessage.Bytes())

handler := runNewWebSocket(wsconn, routerMock, messageStore, nil)
handler := runNewWebSocket(wsconn, routerMock, messageStore)

handler.sendChannel <- aTestMessage.Bytes()
time.Sleep(time.Millisecond * 2)
Expand Down Expand Up @@ -114,7 +113,7 @@ func Test_BadCommands(t *testing.T) {
return nil
}).AnyTimes()

runNewWebSocket(wsconn, routerMock, messageStore, nil)
runNewWebSocket(wsconn, routerMock, messageStore)

wg.Wait()
assert.Equal(t, len(badRequests), counter, "expected number of bad requests does not match")
Expand All @@ -138,12 +137,8 @@ func testWSHandler(
func runNewWebSocket(
wsconn *MockWSConnection,
routerMock *MockRouter,
messageStore store.MessageStore,
accessManager auth.AccessManager) *WebSocket {
messageStore store.MessageStore) *WebSocket {

if accessManager == nil {
accessManager = auth.NewAllowAllAccessManager(true)
}
websocket := NewWebSocket(
testWSHandler(routerMock),
wsconn,
Expand Down

0 comments on commit 22ef638

Please sign in to comment.