Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cds.test with authentication #631

Merged
merged 10 commits into from
Jan 26, 2024
10 changes: 1 addition & 9 deletions node.js/cds-test.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,15 +83,7 @@ await POST (`/browse/submitOrder`, { book: 201, quantity: 5 })


#### Authenticated Endpoints
`cds.test()` uses the standard authentication strategy in development mode, which is the [mocked authentication](../node.js/authentication#mocked). To configure it, use `cds.requires.auth` in the _package.json_ file or directly in your test file as follows:

```js
cds.env.requires.auth.users.foo = {
password: 'bar',
roles: { admin: true, ['cds.Subscriber']: true },
attr: { name: 'Foo' }
}
```
`cds.test()` uses the standard authentication strategy in development mode, which is the [mocked authentication](../node.js/authentication#mocked). To configure it, use `cds.requires.auth` in the _package.json_ file as described in the documenation for the mocked authentication.
larslutz96 marked this conversation as resolved.
Show resolved Hide resolved
renejeglinsky marked this conversation as resolved.
Show resolved Hide resolved

After configuring the authentication, you can set the user for an authenticated request like this:

Expand Down
Loading