dczajkowski / auth-tests Goto Github PK
View Code? Open in Web Editor NEWAlways-current tests for Laravel's authentication system. Curated by the community.
License: MIT License
Always-current tests for Laravel's authentication system. Curated by the community.
License: MIT License
For whatever reason, GitHub Actions stopped working recently.
Please see this output for debugging purposes: https://github.com/DCzajkowski/auth-tests/pull/42/checks?check_run_id=340654075
It would be much appreciated to get it working again π
For starters there's no test for Invalidating Sessions On Other Devices and since that changes the password hash on the cookie, the remember me test becomes a failing test.
Also, we shouldn't be using the bcrypt helper anymore, since i think argon2id will become the default once php 7.1 is no longer supported, which should be this December.
1.- Fresh Laravel Install
2.- Add Invalidating Sessions On Other Devices Functionality
3.- Test
There was 1 warning:
1) Tests\Feature\Auth\LoginTest::testUserCannotMakeMoreThanFiveAttemptsInOneMinute
Using assertContains() with string haystacks is deprecated and will not be supported in PHPUnit 9. Refactor your test to use assertStringContainsString() or assertStringContainsStr
ingIgnoringCase() instead.
Simply run the tests
Any plans to add tests for "remember me" functionality?
None
Can we get a release for laravel 5.6?
When installing in a laravel 5.6 project composer pulls in version 5.5.4 of your lib, which doesnt have all the flags.
Two tests are failing because the guest middleware for ResetPasswordController.php
and ForgotPasswordController.php
was removed in a recent version of Laravel. See this commit.
There were 2 failures:
1) Tests\Feature\Auth\ForgotPasswordTest::testUserCannotViewAnEmailPasswordFormWhenAuthenticated
Response status code [200] is not a redirect status code.
Failed asserting that false is true.
/playground-testing-stuff/vendor/laravel/framework/src/Illuminate/Foundation/Testing/TestResponse.php:198
/Applications/MAMP/htdocs/playground-testing-stuff/tests/Feature/Auth/ForgotPasswordTest.php:51
2) Tests\Feature\Auth\ResetPasswordTest::testUserCannotViewAPasswordResetFormWhenAuthenticated
Response status code [200] is not a redirect status code.
Failed asserting that false is true.
/playground-testing-stuff/vendor/laravel/framework/src/Illuminate/Foundation/Testing/TestResponse.php:198
/Applications/MAMP/htdocs/playground-testing-stuff/tests/Feature/Auth/ResetPasswordTest.php:64
Getting some really weird issues with this.. My test results are failing randomly. Sometimes none fail, sometimes two.. sometimes three? Examples:
1) Tests\Feature\Auth\ForgotPasswordTest::testUserReceivesAnEmailWithAPasswordResetLink
Failed asserting that null is not null.
..xxx/tests/Feature/Auth/ForgotPasswordTest.php:66
2) Tests\Feature\Auth\LoginTest::testUserCanLoginWithCorrectCredentials
Failed asserting that two strings are equal.
--- Expected
+++ Actual
@@ @@
-'http://localhost/dashboard'
+'http://localhost'
...xxx/vendor/laravel/framework/src/Illuminate/Foundation/Testing/TestResponse.php:96
...xxx/tests/Feature/Auth/LoginTest.php:72
Note my home is really 'dashboard' now, dashboard is behind auth (part of web,auth middleware) - could this be it?
Any ideas?
Can we get a release for laravel 5.7 and test the new Email Verification thingy?
Your requirements could not be resolved to an installable set of packages.
Problem 1
- The requested package laravel/framework 5.9.* is satisfiable by laravel/framework[5.9.x-dev] but these conflict with your requirements or minimum-stability.
Problem 2
- The requested package laravel/framework (locked at v5.8.13, required as 5.9.*) is satisfiable by laravel/framework[v5.8.13] but these conflict with your requirements or minimum-stability.
Problem 3
- dczajkowski/auth-tests 5.8.1 requires laravel/framework ~5.8 -> satisfiable by laravel/framework[5.8.x-dev, 5.9.x-dev, v5.8.0, v5.8.1, v5.8.10, v5.8.11, v5.8.12, v5.8.13, v5.8.2, v5.8.3, v5.8.4, v5.8.5, v5.8.6, v5.8.7, v5.8.8, v5.8.9] but these conflict with your requirements or minimum-stability.
- dczajkowski/auth-tests 5.8 requires laravel/framework ~5.8 -> satisfiable by laravel/framework[5.8.x-dev, 5.9.x-dev, v5.8.0, v5.8.1, v5.8.10, v5.8.11, v5.8.12, v5.8.13, v5.8.2, v5.8.3, v5.8.4, v5.8.5, v5.8.6, v5.8.7, v5.8.8, v5.8.9] but these conflict with your requirements or minimum-stability.
- Installation request for dczajkowski/auth-tests ^5.8 -> satisfiable by dczajkowski/auth-tests[5.8, 5.8.1].
$ php artisan test
Warning: TTY mode is not supported on Windows platform.
RUNS Tests\Unit\ExampleTest
β’ basic test
Tests: 44 pending
PASS Tests\Unit\ExampleTest
β basic test
RUNS Tests\Feature\Auth\EmailVerificationTest
β’ guest cannot see the verification notice
Tests: 1 passed, 43 pending
RUNS Tests\Feature\Auth\EmailVerificationTest
β’ user sees the verification notice when not verified
Tests: 2 passed, 42 pending
FAIL Tests\Feature\Auth\EmailVerificationTest
β guest cannot see the verification notice
β user sees the verification notice when not verified
Tests: 1 failed, 2 passed, 41 pending
The response is not a view.
at E:\Websites\BBX\BBXCentral\vendor\phpunit\phpunit\src\Framework\Assert.php:3309
3305| public static function fail(string $message = ''): void
3306| {
3307| self::$count++;
3308|
> 3309| throw new AssertionFailedError($message);
3310| }
3311|
3312| /**
3313| * Returns the value of an attribute of a class or an object.
1 E:\Websites\BBX\BBXCentral\vendor\laravel\framework\src\Illuminate\Testing\TestResponse.php:938
PHPUnit\Framework\Assert::fail("The response is not a view.")
2 E:\Websites\BBX\BBXCentral\vendor\laravel\framework\src\Illuminate\Testing\TestResponse.php:848
Illuminate\Testing\TestResponse::ensureResponseHasView()
Basically when testing my self manually when a user is not verified it takes you to the email verification route and works fine but for some reason the test fails and says the response is not a view.
All of my Auth routes are default and match what are in the tests.
The user model has MustVerifyEmail.
All the Auth stuff works at the moment when testing manually
I know I'm using an old laravel, this is a legacy project.
I've used this package previously and I found it really pleasurable.
Now I have an issue which bugs me for hours now and maybe you have an idea.
$user = factory(User::class)->create([
'email' => '[email protected]',
]);
$this->post($this->passwordEmailPostRoute(), [
'email' => '[email protected]',
]);
$this->assertNotNull($token = DB::table('password_resets')->first());
The user gets written into the database, but for some reason, the provider can't return it, it always fetches null.
I dumped the data, the queries, everything seems to be fine, still, always null. Any idea?
Thank you!
When running the testUserCannotMakeMoreThanFiveAttemptsInOneMinute
test, I see the following deprecation warning:
assertRegExp() is deprecated and will be removed in PHPUnit 10. Refactor your code to use assertMatchesRegularExpression() instead
Laravel 8 marked the laravel/ui package as deprecated in favor of Jetstream.
From what I can see, Jetstream hides all of its controllers inside the package, meaning it doesn't make sense to test those controllers, as Jetstream has its own tests.
From what I understand, using this package (and upgrading it to new releases) makes only sense for people already using the old authentication flow, who want to upgrade their existing projects. The question I have as a maintainer β is it worth it?
I am @'βing a few people who have contributed/were active on/are watching this repo. Please let me know what you think. See #54 and the deprecation notice in particular to get a sense of what all of this means. :)
Have a good day,
Dariusz
cc: @drbyte @nhedger @benyou1969 @zaknesler @FaizAhmadSE @drehimself
I want to suggest a small recomendation. My app is in spanish, so the texts are in spanish and the fallback locale is in english. So, the LoginTest natuarally fails:
There was 1 failure:
1) Tests\Feature\Auth\LoginTest::testUserCannotMakeMoreThanFiveAttemptsInOneMinute
Failed asserting that 'Demasiados intentos de acceso. Por favor intente nuevamente en 60 segundos.' contains "Too many login attempts.".
/home/vagrant/code/ce/tests/Feature/Auth/LoginTest.php:174
It can easily be solved forcing the app to be in english before executing the tests :)
public function testUserCannotMakeMoreThanFiveAttemptsInOneMinute()
{
$this->app->setLocale('en');
// ...
By the way, amazing package. I love it!
Thanks for putting this together. saved me a lot of time.
Laravel Version: 5.7.
PHP Version: PHP 7.2.12-1+ubuntu18.04.1+deb.sury.org+1 (cli) (built: Nov 12 2018 09:55:44) ( NTS )
testUserCannotVereifyOthers() fails on a correct redirect assertion
public function testUserCannotVerifyOthers()
{
$user = factory(User::class)->create([
'id' => 1,
'email_verified_at' => null,
]);
$response = $this->actingAs($user)->get($this->validVerificationVerifyRoute(2));
$response->assertRedirect($this->successfulVerificationRoute());
// Should be ???
// $response->assertForbidden();
}
A declarative, efficient, and flexible JavaScript library for building user interfaces.
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. πππ
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google β€οΈ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.