Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
P
pleroma
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
href
pleroma
Commits
4e7d9892
Commit
4e7d9892
authored
6 years ago
by
Ivan Tashkinov
Browse files
Options
Downloads
Patches
Plain Diff
[
#114
] Added tests for "POST /api/account/password_reset".
parent
f5afb110
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
config/test.exs
+2
-0
2 additions, 0 deletions
config/test.exs
test/web/twitter_api/twitter_api_controller_test.exs
+42
-1
42 additions, 1 deletion
test/web/twitter_api/twitter_api_controller_test.exs
with
44 additions
and
1 deletion
config/test.exs
+
2
−
0
View file @
4e7d9892
...
...
@@ -11,6 +11,8 @@
config
:pleroma
,
Pleroma
.
Uploaders
.
Local
,
uploads:
"test/uploads"
config
:pleroma
,
Pleroma
.
Mailer
,
adapter:
Swoosh
.
Adapters
.
Test
# Configure your database
config
:pleroma
,
Pleroma
.
Repo
,
adapter:
Ecto
.
Adapters
.
Postgres
,
...
...
This diff is collapsed.
Click to expand it.
test/web/twitter_api/twitter_api_controller_test.exs
+
42
−
1
View file @
4e7d9892
...
...
@@ -9,6 +9,7 @@ defmodule Pleroma.Web.TwitterAPI.ControllerTest do
alias
Pleroma
.
Web
.
CommonAPI
alias
Pleroma
.
Web
.
TwitterAPI
.
TwitterAPI
alias
Comeonin
.
Pbkdf2
alias
Ecto
.
Changeset
import
Pleroma
.
Factory
...
...
@@ -270,7 +271,7 @@ test "with credentials", %{conn: conn, user: current_user} do
since_id
=
List
.
last
(
activities
)
.
id
current_user
=
Ecto
.
Changeset
.
change
(
current_user
,
following:
[
User
.
ap_followers
(
user
)])
Changeset
.
change
(
current_user
,
following:
[
User
.
ap_followers
(
user
)])
|>
Repo
.
update!
()
conn
=
...
...
@@ -832,6 +833,46 @@ test "it returns errors on a problem", %{conn: conn} do
end
end
describe
"POST /api/account/password_reset, with valid parameters"
do
setup
%{
conn:
conn
}
do
user
=
insert
(
:user
)
conn
=
post
(
conn
,
"/api/account/password_reset?email=
#{
user
.
email
}
"
)
%{
conn:
conn
,
user:
user
}
end
test
"it returns 204"
,
%{
conn:
conn
}
do
assert
json_response
(
conn
,
:no_content
)
end
test
"it creates a PasswordResetToken record for user"
,
%{
user:
user
}
do
token_record
=
Repo
.
get_by
(
Pleroma
.
PasswordResetToken
,
user_id:
user
.
id
)
assert
token_record
end
test
"it sends an email to user"
,
%{
user:
user
}
do
token_record
=
Repo
.
get_by
(
Pleroma
.
PasswordResetToken
,
user_id:
user
.
id
)
Swoosh
.
TestAssertions
.
assert_email_sent
(
Pleroma
.
UserEmail
.
password_reset_email
(
user
,
token_record
.
token
)
)
end
end
describe
"POST /api/account/password_reset, with invalid parameters"
do
setup
[
:valid_user
]
test
"it returns 500 when user is not found"
,
%{
conn:
conn
,
user:
user
}
do
conn
=
post
(
conn
,
"/api/account/password_reset?email=nonexisting_
#{
user
.
email
}
"
)
assert
json_response
(
conn
,
:internal_server_error
)
end
test
"it returns 500 when user is not local"
,
%{
conn:
conn
,
user:
user
}
do
{
:ok
,
user
}
=
Repo
.
update
(
Changeset
.
change
(
user
,
local:
false
))
conn
=
post
(
conn
,
"/api/account/password_reset?email=
#{
user
.
email
}
"
)
assert
json_response
(
conn
,
:internal_server_error
)
end
end
describe
"GET /api/externalprofile/show"
do
test
"it returns the user"
,
%{
conn:
conn
}
do
user
=
insert
(
:user
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment