Skip to content

Instantly share code, notes, and snippets.

@johanb
Created November 16, 2016 16:54
Show Gist options
  • Save johanb/ff999170748051ea6f1a456d00df4489 to your computer and use it in GitHub Desktop.
Save johanb/ff999170748051ea6f1a456d00df4489 to your computer and use it in GitHub Desktop.
defmodule Kreuwel.Channels.UserSocketTest do
use Kreuwel.ChannelCase
import Kreuwel.TestFactory
alias Kreuwel.UserSocket
test "socket authentication with valid token" do
user = insert(:user)
{:ok, jwt, _} = Guardian.encode_and_sign(user)
assert {:ok, socket} = UserSocket.connect(%{"guardian_token" => "#{jwt}"}, %Phoenix.Socket{})
end
test "socket authentication without token" do
assert :error = UserSocket.connect(%{}, %Phoenix.Socket{})
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment