You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: core/jwt.md
+68Lines changed: 68 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -60,6 +60,74 @@ security:
60
60
- { path: ^/, roles: [ ROLE_READER ] }
61
61
```
62
62
63
+
## Testing with Behat
64
+
65
+
Let's configure Behat to automatically send a `Authorization` HTTP header containing a valid JWT token when a scenario is marked with a `@login` annotation. Edit `features/bootstrap/FeatureContext.php` and add the following methods:
66
+
67
+
```php
68
+
<?php
69
+
70
+
// features/bootstrap/FeatureContext.php
71
+
72
+
use AppBundle\Entity\User;
73
+
use Behat\Behat\Hook\Scope\BeforeScenarioScope;
74
+
use Behatch\Context\RestContext;
75
+
76
+
class FeatureContext implements Context, SnippetAcceptingContext
77
+
{
78
+
// ...
79
+
// Must be aster createDatabase() and dropDatabase() functions (the order matters)
Finally, mark your scenarios with the `@login` annotation to automatically add a valid `Authorization` header and with `@logout` to be sure to detroy the token after this scerario.
0 commit comments