auth method

TestRequest auth(
  1. String username,
  2. String password
)

Set HTTP Basic Authentication header.

Automatically encodes credentials in Base64 format and sets the Authorization header. Commonly used for API authentication.

Example:

testApp.get('/api/admin')
  .auth('admin', 'secret123');

username Username for authentication. password Password for authentication. Returns this request builder for method chaining.

Implementation

TestRequest auth(String username, String password) {
  final credentials = base64Encode(utf8.encode('$username:$password'));
  return header('authorization', 'Basic $credentials');
}