1
0
mirror of https://github.com/flarum/core.git synced 2025-07-25 10:41:24 +02:00
Commit Graph

149 Commits

Author SHA1 Message Date
Franz Liedke
3246fb3fea Make tests compatible with PHPUnit 8 2020-03-28 11:06:47 +01:00
Franz Liedke
20bc1e50fc Convert last two controller tests to request tests 2020-03-27 13:39:38 +01:00
Franz Liedke
2deae4b058 Rename API tests for more consistency
I could not come up with a noun for the new "UpdateTest" for users, so
this is easier in terms of consistency.
2020-03-27 13:22:27 +01:00
Franz Liedke
4e2f91fa00 Convert more controller tests to request tests 2020-03-27 13:21:10 +01:00
Matt Kilgore
b0fd63adc3 Fix test and extender for middleware (#2084) 2020-03-27 11:00:30 +01:00
Matt Kilgore
84dafdd5c3 fix insertAfter and insertBefore middleware extender functions (#2063) 2020-03-20 22:59:57 +01:00
Franz Liedke
b3dc2c7571 Convert more controller tests to request tests 2020-03-20 18:54:20 +01:00
Franz Liedke
a70acdf9cb Apply fixes from StyleCI
[ci skip] [skip ci]
2020-03-20 17:28:58 +00:00
Franz Liedke
2b0bc2865d Tests: Use new authenticatedAs option where useful
There are two more API integration tests that explicitly add the
"Authorization" header right now:

- `Flarum\Tests\integration\api\authentication\WithApiKeyTest`
- `Flarum\Tests\integration\api\csrf_protection\RequireCsrfTokenTest`

These two specifically test authentication, so in those cases the
explicitness seems desirable.
2020-03-20 18:28:35 +01:00
Franz Liedke
8e21fee06c Replace authenticatedRequest() by request() option
I feel this makes the parameters a bit more clear, does not rely on
inheritance (you can only inherit from one class, but we might want more
of these helpers in the future), and has less side effects (e.g. no
creation and, more importantly, deletion of users in the database).

Refs #2052.
2020-03-20 18:23:06 +01:00
Franz Liedke
6540049421 Tests: Extract trait for building requests 2020-03-20 17:51:03 +01:00
Alexander Skvortsov
fe8df6df4e Add Authenticated Test Case utility 2020-03-20 17:18:35 +01:00
Franz Liedke
7096da722e Add a baseline test for the middleware extender
Refs #2017.
2020-03-06 15:05:16 +01:00
Franz Liedke
a1a2b35221 Apply fixes from StyleCI
[ci skip] [skip ci]
2020-03-06 13:55:39 +00:00
Matt Kilgore
390b529da7 Test Middleware extender (#2017) 2020-03-06 14:55:21 +01:00
Franz Liedke
d30f2a0ca9 Merge pull request #2002 from flarum/fl/extender-tests
Start testing extenders
2020-02-14 18:47:58 +01:00
Clark Winkelmann
4350baa1f1 Rename dead is_activated references with the new is_email_confirmed (#1974) 2020-02-14 15:34:32 +01:00
Franz Liedke
12ff8dbcc3 Start testing Route extender 2020-02-08 00:04:32 +01:00
Franz Liedke
b2c3392a83 Integration tests: Allow registering extenders 2020-02-07 23:29:14 +01:00
Franz Liedke
d0aa0b7920 Integration tests: Add lazy server helper
This allows sending requests directly in an integration test, without
having *explicitly* booted the app.
2020-02-07 23:28:37 +01:00
Franz Liedke
010f1939e0 Integration tests: Create app lazily when needed
This will allow registering extenders in test scenarios. Previously,
this would not have had any effect as the app would have booted already.
2020-02-07 23:22:22 +01:00
Franz Liedke
c80d704c0b Convert another test
Test the request, not a controller (implementation detail). This also
focuses on the observable behavior instead of hacking our way into the
middleware pipeline in order to observe internal behavior.

The authenticated user is now determined by looking at the API response
to compare permissions and (non-)existing JSON keys.
2020-01-22 23:39:41 +01:00
Matt Kilgore
d55daf2a8c Change Zend namespace to Laminas (#1963)
Also ensure backwards compatibility for extensions that use the Zend framework but don't explicitly require it.
2020-01-06 22:29:34 +01:00
Franz Liedke
5020a3a927 Apply fixes from StyleCI
[ci skip] [skip ci]
2019-11-28 00:16:50 +00:00
Clark Winkelmann
c7634e48b6 Fix tests to include expectation count and run user saving events 2019-11-26 10:13:18 +01:00
Clark Winkelmann
c2cd9174e4 Add unit test for AvatarUploader 2019-11-26 10:13:18 +01:00
Daniel Klabbers
a0ed6c5d69 incorrect ability used, drop prefix discussion. 2019-11-22 08:17:02 +01:00
Daniel Klabbers
07313a15c4 test only on the hidePosts policy ability 2019-11-22 08:17:02 +01:00
Daniël Klabbers
b35afc2be7 [review] using orWhere to allow any where to follow in extensions 2019-11-22 08:17:02 +01:00
Daniël Klabbers
78e146dac8 fixes #1827
- set default statement to block access
- added tests to confirm all scenarios work as intended
2019-11-22 08:17:02 +01:00
Franz Liedke
2a71ee215c Automatically set up Mockery for unit tests
- Use provided PhpUnit listener to enforce verification of expectations.
- Include Mockery's trait to auto-close Mockery after each test.
2019-11-21 00:51:11 +01:00
David Sevilla Martin
c357907c73 Add test for discussion posts being deleted on discussion delete from DB 2019-11-18 09:23:53 +01:00
David Sevilla Martin
41d55e6fe2 Fix failing tests 2019-11-18 09:23:53 +01:00
Franz Liedke
fef6612d62 Revert search performance regression
We decided it is better to have a less intelligent search (that does not
match search terms in titles) for some people than a bad-performing
search for everyone.

We will revisit the search performance topic in the next release cycle,
possibly with larger changes around indexing.

Refs #1738, #1741, #1764.
2019-10-26 15:41:39 +02:00
Franz Liedke
5a9c1a91b2 Cleanup code from #1876
- Extract a method for email address generation
- Consistent types
- No docblocks for types where superfluous
- Tweak console output
- Don't inherit from integration test's base class in unit test
2019-09-24 01:00:22 +02:00
Stefan Totev
522d3356ca Normalize Base URL during installation
- Fix base url when is appended with a script filename
- Add default base url http://flarum.local when CLI wizard used
- Remove some code duplication
- Add minor improvement to the UX when CLI wizard used
- Add tests
- Extract base url normalisation into its own value object
2019-09-24 00:26:51 +02:00
Franz Liedke
cbe7d4dfdb Restore beta.9 behavior of assertCan()
In flarum/core#1854, I changed the implementation of `assertCan()` to be
more aware of the user's log-in status. I came across this when unifying
our API's response status code when actors are not authenticated or not
authorized to do something.

@luceos rightfully had to tweak this again in 8e3eb59, because the
behavior changed for one of the few API endpoints that checked for a
permission that even guests can have.

It turns out having this complex behavior in `assertCan()` is quite
misleading, because the name suggests a simple permission check and
nothing more.

Where we actually want to differ between HTTP 401 and 403, we can do
this using two method calls, and enforce it with our tests.

If this turns out to be problematic or extremely common, we can revisit
this and introduce a method with a different, better name in the future.

This commit restores the method's behavior in the last release, so we
also avoid another breaking change for extensions.
2019-09-14 21:32:00 +02:00
Franz Liedke
26d2031aa4 Add a test for viewUserList guest permission
This test would have failed without commit 8e3eb59. Next, I will revert
that commit and most of my PR #1854, so we need this test to ensure the
API continues to behave as desired.
2019-09-14 21:30:09 +02:00
Franz Liedke
f4219b0de6 Apply fixes from StyleCI
[ci skip] [skip ci]
2019-09-14 18:57:28 +00:00
Franz Liedke
9120e556eb Convert more controller tests to feature tests 2019-09-14 13:09:56 +02:00
Franz Liedke
eca288f525 Send a HTTP 401 for incorrect login credentials
This fixes a regression from #1843 and #1854. Now, the frontend again
shows the proper "Incorrect login details" message instead of "You
do not have permission to do that".
2019-09-13 15:03:03 +02:00
Franz Liedke
b75e8284da Convert another controller test to feature test
Decouple from implementation, test closer to HTTP...
2019-09-13 14:58:45 +02:00
Franz Liedke
ef38660f08 Fix failing test 2019-09-05 00:07:40 +02:00
Franz Liedke
429b8e1a32 Restore error details in JSON-API error formatter
Fixes #1865. Refs #1843.
2019-09-04 01:44:22 +02:00
Franz Liedke
a7b19284b9 Convert controller test to request test
This further decouples these tests from the implementation (i.e. which
controller are we calling?).
2019-09-04 01:27:24 +02:00
Franz Liedke
7d52a49cfb Fix inconsistent status codes
HTTP 401 should be used when logging in (i.e. authenticating) would make
a difference; HTTP 403 is reserved for requests that fail because the
already authenticated user is not authorized (i.e. lacking permissions)
to do something.
2019-08-21 00:06:31 +02:00
Franz Liedke
f73a39d3f4 Remove old error handler, middleware and tests 2019-08-10 00:26:24 +02:00
Franz Liedke
8e0cd27f54 API Client: Use new error handling mechanism 2019-08-10 00:26:24 +02:00
Franz Liedke
817e54abe0 Wire up new error handling stack 2019-08-10 00:26:23 +02:00
Franz Liedke
2fc2cd5863 Bypass CSRF token check when using access tokens
Fixes #1828.
2019-08-01 22:53:31 +02:00