]> Entropealabs - wampex_router.git/commitdiff
more tests around insufficient roles
authorChristopher <chris@entropealabs.com>
Mon, 6 Apr 2020 14:34:07 +0000 (09:34 -0500)
committerChristopher <chris@entropealabs.com>
Mon, 6 Apr 2020 14:34:07 +0000 (09:34 -0500)
mix.exs
test/wampex_test.exs

diff --git a/mix.exs b/mix.exs
index 4c8fbc11b6e822bda39f2a85b8f4b4f0f1634778..453747179b609c81229e6efad098074346122206 100644 (file)
--- a/mix.exs
+++ b/mix.exs
@@ -50,9 +50,10 @@ defmodule Wampex.Router.MixProject do
       {:plug_cowboy, "~> 2.1"},
       {:states_language, "~> 0.2"},
       {:wampex, git: "https://gitlab.com/entropealabs/wampex.git", tag: "7d656d9748cb0e4d08c625d87e315839afecb4b2"},
+      # {:wampex_client, path: "../wampex_client", only: [:dev, :test]}
       {:wampex_client,
        git: "https://gitlab.com/entropealabs/wampex_client.git",
-       tag: "7896d51d7493fd3477de2a226d7d97f2c3098736",
+       tag: "a6478667525bbc048215a94ec237a6b45f9009f1",
        only: [:dev, :test]}
     ]
   end
index e1647f3b01497cffb6a9e080ed82ee027588b97f..7adb5be9f5390f7511916daff38cd4a5261ee0e9 100644 (file)
@@ -21,7 +21,7 @@ defmodule WampexTest do
   @realm_uri "admin"
   @auth %Authentication{authid: @authid, authmethods: ["wampcra"], secret: @auth_password}
   @realm %Realm{name: @realm_uri, authentication: @auth}
-  @roles [Callee, Caller, Publisher, Subscriber]
+  @roles [Caller, Callee, Publisher, Subscriber]
   @device "as987d9a8sd79a87ds"
   @session %Session{url: @url, realm: @realm, roles: @roles}
   setup_all do
@@ -41,6 +41,24 @@ defmodule WampexTest do
     ]
   end
 
+  test "role not supported" do
+    callee_name = TestCalleeAbortRegistration
+    Client.start_link(name: callee_name, session: @session, reconnect: false)
+    TestCallee.start_link(self(), callee_name, @device)
+
+    name = TestCallerFail
+    [_ | t] = @session.roles
+    sess = %Session{@session | roles: t}
+    {:ok, pid} = Client.start_link(name: name, session: sess, reconnect: false)
+
+    try do
+      Client.call(name, %Call{procedure: "com.actuator.#{@device}.light"})
+    catch
+      :exit, er ->
+        assert {:normal, _} = er
+    end
+  end
+
   @tag :client
   test "callee registration" do
     name = TestCalleeRegistration
@@ -51,11 +69,15 @@ defmodule WampexTest do
 
   @tag :abort
   test "abort" do
-    Process.flag(:trap_exit, true)
     callee_name = TestAbort
     {:ok, pid} = Client.start_link(name: callee_name, session: @session, reconnect: false)
-    Client.cast(callee_name, Peer.hello(%Hello{realm: "test", roles: [Callee]}))
-    assert_receive {:EXIT, ^pid, :shutdown}, 1000
+
+    try do
+      Client.cast(callee_name, Peer.hello(%Hello{realm: "test", roles: [Callee]}))
+    catch
+      :exit, er ->
+        assert {:normal, _} = er
+    end
   end
 
   @tag :client