MCPcopy Create free account
hub / github.com/gavv/httpexpect / WithBasicAuth

Method WithBasicAuth

request.go:1646–1664  ·  view source on GitHub ↗

WithBasicAuth sets the request's Authorization header to use HTTP Basic Authentication with the provided username and password. With HTTP Basic Authentication the provided username and password are not encrypted. Example: req := NewRequestC(config, "PUT", "http://example.com/path") req.WithBasi

(username, password string)

Source from the content-addressed store, hash-verified

1644// req := NewRequestC(config, "PUT", "http://example.com/path")
1645// req.WithBasicAuth("john", "secret")
1646func (r *Request) WithBasicAuth(username, password string) *Request {
1647 opChain := r.chain.enter("WithBasicAuth()")
1648 defer opChain.leave()
1649
1650 r.mu.Lock()
1651 defer r.mu.Unlock()
1652
1653 if opChain.failed() {
1654 return r
1655 }
1656
1657 if !r.checkOrder(opChain, "WithBasicAuth()") {
1658 return r
1659 }
1660
1661 r.httpReq.SetBasicAuth(username, password)
1662
1663 return r
1664}
1665
1666// WithHost sets request host to given string.
1667//

Callers 5

TestRequest_FailedChainFunction · 0.80
TestRequest_BasicAuthFunction · 0.80
TestRequest_OrderFunction · 0.80
TestIrisAuthFunction · 0.80
testBasicHandlerFunction · 0.80

Calls 6

checkOrderMethod · 0.95
enterMethod · 0.80
leaveMethod · 0.80
LockMethod · 0.80
UnlockMethod · 0.80
failedMethod · 0.80

Tested by 5

TestRequest_FailedChainFunction · 0.64
TestRequest_BasicAuthFunction · 0.64
TestRequest_OrderFunction · 0.64
TestIrisAuthFunction · 0.64
testBasicHandlerFunction · 0.64