summaryrefslogtreecommitdiff
path: root/test/polyjuice
diff options
context:
space:
mode:
authorHubert Chathi <hubert@uhoreg.ca>2020-04-25 13:11:01 -0400
committerHubert Chathi <hubert@uhoreg.ca>2020-04-25 13:11:01 -0400
commitd9aec015c8e8ca098b9992d40a54277e49fdc20c (patch)
tree750aa1d00179f331a541c7e29873270a81b3c372 /test/polyjuice
parentpass through errors from hackney (diff)
move log in/out functions to user module
Diffstat (limited to 'test/polyjuice')
-rw-r--r--test/polyjuice/client/user_test.exs105
-rw-r--r--test/polyjuice/client_test.exs88
2 files changed, 105 insertions, 88 deletions
diff --git a/test/polyjuice/client/user_test.exs b/test/polyjuice/client/user_test.exs
new file mode 100644
index 0000000..06b95bd
--- /dev/null
+++ b/test/polyjuice/client/user_test.exs
@@ -0,0 +1,105 @@
+# Copyright 2020 Hubert Chathi <hubert@uhoreg.ca>
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+defmodule Polyjuice.Client.UserTest do
+ use ExUnit.Case
+
+ test "log in" do
+ with client = %DummyClient{
+ response: {
+ %Polyjuice.Client.Endpoint.PostLogin{
+ type: "m.login.password",
+ identifier: %{
+ "type" => "m.id.user",
+ "user" => "user"
+ },
+ password: "password"
+ },
+ {:ok, %{}}
+ }
+ } do
+ {:ok, %{}} = Polyjuice.Client.User.log_in_with_password(client, "user", "password")
+ end
+
+ with client = %DummyClient{
+ response: {
+ %Polyjuice.Client.Endpoint.PostLogin{
+ type: "m.login.password",
+ identifier: %{
+ "type" => "m.id.thirdparty",
+ "medium" => "email",
+ "address" => "user@example.com"
+ },
+ password: "password",
+ device_id: "device_id",
+ initial_device_display_name: "Device name"
+ },
+ {:ok, %{}}
+ }
+ } do
+ {:ok, %{}} =
+ Polyjuice.Client.User.log_in_with_password(
+ client,
+ {:email, "user@example.com"},
+ "password",
+ device_id: "device_id",
+ initial_device_display_name: "Device name"
+ )
+ end
+
+ with client = %DummyClient{
+ response: {
+ %Polyjuice.Client.Endpoint.PostLogin{
+ type: "m.login.password",
+ identifier: %{
+ "type" => "m.id.phone",
+ "country" => "CA",
+ "phone" => "1234567890"
+ },
+ password: "password"
+ },
+ {:ok, %{}}
+ }
+ } do
+ {:ok, %{}} =
+ Polyjuice.Client.User.log_in_with_password(
+ client,
+ {:phone, "CA", "1234567890"},
+ "password"
+ )
+
+ {:ok, %{}} =
+ Polyjuice.Client.User.log_in_with_password(
+ client,
+ %{
+ "type" => "m.id.phone",
+ "country" => "CA",
+ "phone" => "1234567890"
+ },
+ "password"
+ )
+ end
+ end
+
+ test "log out" do
+ with client = %DummyClient{
+ response: {
+ %Polyjuice.Client.Endpoint.PostLogout{},
+ {:ok}
+ }
+ } do
+ {:ok} = Polyjuice.Client.User.log_out(client)
+ end
+ end
+end
diff --git a/test/polyjuice/client_test.exs b/test/polyjuice/client_test.exs
index ca512d2..de680a6 100644
--- a/test/polyjuice/client_test.exs
+++ b/test/polyjuice/client_test.exs
@@ -15,94 +15,6 @@
defmodule Polyjuice.ClientTest do
use ExUnit.Case
- test "log in" do
- with client = %DummyClient{
- response: {
- %Polyjuice.Client.Endpoint.PostLogin{
- type: "m.login.password",
- identifier: %{
- "type" => "m.id.user",
- "user" => "user"
- },
- password: "password"
- },
- {:ok, %{}}
- }
- } do
- {:ok, %{}} = Polyjuice.Client.log_in_with_password(client, "user", "password")
- end
-
- with client = %DummyClient{
- response: {
- %Polyjuice.Client.Endpoint.PostLogin{
- type: "m.login.password",
- identifier: %{
- "type" => "m.id.thirdparty",
- "medium" => "email",
- "address" => "user@example.com"
- },
- password: "password",
- device_id: "device_id",
- initial_device_display_name: "Device name"
- },
- {:ok, %{}}
- }
- } do
- {:ok, %{}} =
- Polyjuice.Client.log_in_with_password(
- client,
- {:email, "user@example.com"},
- "password",
- device_id: "device_id",
- initial_device_display_name: "Device name"
- )
- end
-
- with client = %DummyClient{
- response: {
- %Polyjuice.Client.Endpoint.PostLogin{
- type: "m.login.password",
- identifier: %{
- "type" => "m.id.phone",
- "country" => "CA",
- "phone" => "1234567890"
- },
- password: "password"
- },
- {:ok, %{}}
- }
- } do
- {:ok, %{}} =
- Polyjuice.Client.log_in_with_password(
- client,
- {:phone, "CA", "1234567890"},
- "password"
- )
-
- {:ok, %{}} =
- Polyjuice.Client.log_in_with_password(
- client,
- %{
- "type" => "m.id.phone",
- "country" => "CA",
- "phone" => "1234567890"
- },
- "password"
- )
- end
- end
-
- test "log out" do
- with client = %DummyClient{
- response: {
- %Polyjuice.Client.Endpoint.PostLogout{},
- {:ok}
- }
- } do
- {:ok} = Polyjuice.Client.log_out(client)
- end
- end
-
test "sync" do
with client = %DummyClient{
response: {