Lines 22-57javascript
22 if (!decoded.includes(':')) {
23 return (0, case_plugin_base_1.makeResults)((0, case_plugin_base_1.matchingError)(matcher, `Basic auth value decoded to ${decoded}, which doesn't contain a ':'`, actual, matchContext));
25 const pivot = decoded.indexOf(':');
26 const actualUsername = decoded.substring(0, pivot);
27 const actualPassword = decoded.substring(pivot + 1);
28 return (0, case_plugin_base_1.combineResultPromises)(matchContext.descendAndCheck(matcher['_case:matcher:username'], (0, case_plugin_base_1.addLocation)('username', matchContext), actualUsername), matchContext.descendAndCheck(matcher['_case:matcher:password'], (0, case_plugin_base_1.addLocation)('password', matchContext), actualPassword));
30const strip = (matcher, matchContext) => {
31 const username = matchContext.descendAndStrip(matcher['_case:matcher:username'], matchContext);
32 const password = matchContext.descendAndStrip(matcher['_case:matcher:password'], matchContext);
33 if (typeof username !== 'string') {
34 throw new case_plugin_base_1.CaseConfigurationError("The username for basic auth didn't resolve to a string, please check the definition", matchContext, 'BAD_INTERACTION_DEFINITION');
36 if (typeof password !== 'string') {
37 throw new case_plugin_base_1.CaseConfigurationError("The password for basic auth didn't resolve to a string, please check the definition", matchContext, 'BAD_INTERACTION_DEFINITION');
39 return encode(username, password, matchContext);
41exports.HttpBasicAuthMatcher = {
42 describe: (matcher, matchContext) => (0, case_plugin_base_1.concatenateDescribe)((0, case_plugin_base_1.describeMessage)("http basic auth with username='"), matchContext.descendAndDescribe(matcher['_case:matcher:username'], (0, case_plugin_base_1.addLocation)('username', matchContext)), (0, case_plugin_base_1.describeMessage)("' and password="), matchContext.descendAndDescribe(matcher['_case:matcher:password'], (0, case_plugin_base_1.addLocation)('password', matchContext))),
MediumSecret Pattern
Package contains a possible secret pattern.
dist/src/matchers/HttpBasicAuthMatcher.jsView on unpkg · L42 45 validate: (matcher, matchContext) => Promise.resolve()
47 if (!('_case:matcher:password' in matcher)) {
48 throw new case_plugin_base_1.CaseConfigurationError('The HttpBasicAuthMatcher must be given a password', matchContext);
50 if (!('_case:matcher:username' in matcher)) {
51 throw new case_plugin_base_1.CaseConfigurationError('The HttpBasicAuthMatcher must be given a username', matchContext);
54 .then(() => matchContext.descendAndValidate(matcher['_case:matcher:username'], (0, case_plugin_base_1.addLocation)('username', matchContext)))
55 .then(() => matchContext.descendAndValidate(matcher['_case:matcher:password'], (0, case_plugin_base_1.addLocation)('password', matchContext))),
57//# sourceMappingURL=HttpBasicAuthMatcher.js.map