From 5790376d8119e22a363db53b2cc83bdaca2104b7 Mon Sep 17 00:00:00 2001 From: Christopher Date: Mon, 6 Apr 2020 09:34:07 -0500 Subject: [PATCH] more tests around insufficient roles --- mix.exs | 3 ++- test/wampex_test.exs | 30 ++++++++++++++++++++++++++---- 2 files changed, 28 insertions(+), 5 deletions(-) diff --git a/mix.exs b/mix.exs index 4c8fbc1..4537471 100644 --- 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 diff --git a/test/wampex_test.exs b/test/wampex_test.exs index e1647f3..7adb5be 100644 --- a/test/wampex_test.exs +++ b/test/wampex_test.exs @@ -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 -- 2.45.3