Skip to content

Commit

Permalink
create channels/user_socket_test.exs p.292 #1
Browse files Browse the repository at this point in the history
  • Loading branch information
nelsonic committed Aug 11, 2019
1 parent 72b3f74 commit c20e5e4
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions apps/rumbl_web/test/channels/user_socket_test.exs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
defmodule RumblWeb.Channels.UserSocketTest do
use RumblWeb.ChannelCase, async: true
alias RumblWeb.UserSocket

test "socket authentication with valid token" do
token = Phoenix.Token.sign(@endpoint, "user socket", "123")

assert {:ok, socket} = connect(UserSocket, %{"token" => token})
assert socket.assigns.user_id = "123"
end

test "socket authentication with invalid token" do
assert :error = connect(UserSocket, %{"token" => "1313"})
assert :error = connect(UserSocket, %{})
end
end

0 comments on commit c20e5e4

Please sign in to comment.