Asserts that the body of the response
 does not contain the supplied string or regepx
330256
def assert_have_no_selector(name, attributes = {}, &block)
      matcher = HaveSelector.new(name, attributes, &block)
      assert !matcher.matches?(response_body), matcher.negative_failure_message
    end
745545
public function assertResponseBodyContainsJson(PyStringNode $contains) {
        $this->requireResponse();

        // Decode the parameter to the step as an array and make sure it's valid JSON
        $contains = $this->jsonDecode((string) $contains);

        // Get the decoded response body and make sure it's decoded to an array
        $body = json_decode(json_encode($this->getResponseBody()), true);

        try {
            // Compare the arrays, on error this will throw an exception
            Assertion::true($this->arrayContainsComparator->compare($contains, $body));
        } catch (AssertionFailure $e) {
            throw new AssertionFailedException(
                'Comparator did not return in a correct manner. Marking assertion as failed.'
            );
        }
    }
286326
def response_indicates_valid?(response)
      REXML::Document.new(response.body).root.get_elements('//m:validity').first.text == 'true'
    end
366601
function checkResponse(actual, expected, bindings) {

    debug('Checking response, expecting:', expected)

    addTest('Status: ' + expected.title, function() {
      assert.equal(actual.statusCode, expected.code)
    })

    for (var key in expected.headers) {
      var val = expected.headers[key]
      addTest('Header: ' + key + ': ' + val, function() {
        assert.ok(actual.headers[key], "Header " + key + " expected, but not found")
        assert.ok(interpolate.match(actual.headers[key], val, bindings), "Expected headers to match")
      })
    }

    if (expected.body) {
      assertBodyMatches(actual.body, expected.body, bindings)
    } else {
      addTest('No body', function() {
        if (actual.body) assert.fail(actual.body, '', "Expected empty body")
      })
    }
  }
1075888
public function assertResponseBodyIsAnEmptyJsonObject() {
        $this->requireResponse();
        $body = $this->getResponseBody();

        try {
            Assertion::isInstanceOf($body, 'stdClass', 'Expected response body to be a JSON object.');
            Assertion::same('{}', $encoded = json_encode($body, JSON_PRETTY_PRINT), sprintf(
                'Expected response body to be an empty JSON object, got "%s".',
                $encoded
            ));
        } catch (AssertionFailure $e) {
            throw new AssertionFailedException($e->getMessage());
        }
    }
292212
def verify_is_not_none(self, expr, msg=None):
        
        try:
            self.assert_is_not_none(expr, msg)
        except AssertionError, e:
            if msg:
                m = "%s:\n%s" % (msg, str(e))
            else:
                m = str(e)
            self.verification_erorrs.append(m)
471895
function _setResponseBody(body) {
    verifyRequestSent(this);
    verifyHeadersReceived(this);
    verifyResponseBodyType(body);

    var chunkSize = this.chunkSize || 10;
    var index = 0;
    this.responseText = "";

    do {
      if (this.async) {
        this._readyStateChange(FakeXMLHttpRequest.LOADING);
      }

      this.responseText += body.substring(index, index + chunkSize);
      index += chunkSize;
    } while (index < body.length);

    var type = this.getResponseHeader("Content-Type");

    if (this.responseText && (!type || /(text\/xml)|(application\/xml)|(\+xml)/.test(type))) {
      try {
        this.responseXML = parseXML(this.responseText);
      } catch (e) {
        // Unable to parse XML - no biggie
      }
    }

    if (this.async) {
      this._readyStateChange(FakeXMLHttpRequest.DONE);
    } else {
      this.readyState = FakeXMLHttpRequest.DONE;
    }
  }
316891
function assertSubstrings(str, substrings) {
  substrings.forEach(function(substring) {
    assert(str.indexOf(substring) !== -1, str +
      ' - string does not contain: ' + substring);
  });
}
1056089
def validate_cmd_response_hex(name, got, expected):
    
    if got != expected:
        raise(pyhsm.exception.YHSM_Error("Bad %s in response (got 0x%x, expected 0x%x)" \
                                             % (name, got, expected)))
    return got
410067
function checkRegExp(test) {
  if (typeof test === 'string' && test[0] === '/') {
    var matchs = test.match(/^\/(.+)\/([igm]*)$/);
    if (matchs) {
      test = new RegExp(matchs[1], matchs[2]);
    }
  }
  return test;
}
10221
def validate_body!(response)
      return unless media_type
      return if media_type.kind_of? SimpleMediaType

      errors = self.media_type.validate(self.media_type.load(response.body))
      if errors.any?
        message = "Invalid response body for #{media_type.identifier}." +
          "Errors: #{errors.inspect}"
          raise Exceptions::Validation.new(message, errors: errors)
      end

    end
1033242
void validate(ServerResponse serverResponse) throws GeneralSecurityException {
    byte[] response = validateChallenge(authNonce, serverResponse.response);

    byte[] expected = rawResponse(challenge);
    Preconditions.checkArgument(Arrays.equals(expected, response));

    byte[] nonce = decrypt(serverResponse.nonce);
    byte[] inputIv = decrypt(serverResponse.inputIv);
    byte[] outputIv = decrypt(serverResponse.outputIv);

    SecretKeySpec sessionKey = generateKey(conf.keyFactoryAlgorithm(), conf.keyFactoryIterations(),
      nonce, conf.encryptionKeyLength());
    this.sessionCipher = new TransportCipher(cryptoConf, conf.cipherTransformation(), sessionKey,
      inputIv, outputIv);
  }
440196
function () {
                // Read response state from the memoized partial data.
                var _a = partialFromXhr(), headers = _a.headers, status = _a.status, statusText = _a.statusText, url = _a.url;
                // The body will be read out if present.
                var body = null;
                if (status !== 204) {
                    // Use XMLHttpRequest.response if set, responseText otherwise.
                    body = (typeof xhr.response === 'undefined') ? xhr.responseText : xhr.response;
                }
                // Normalize another potential bug (this one comes from CORS).
                if (status === 0) {
                    status = !!body ? 200 : 0;
                }
                // ok determines whether the response will be transmitted on the event or
                // error channel. Unsuccessful status codes (not 2xx) will always be errors,
                // but a successful status code can still result in an error if the user
                // asked for JSON data and the body cannot be parsed as such.
                var ok = status >= 200 && status < 300;
                // Check whether the body needs to be parsed as JSON (in many cases the browser
                // will have done that already).
                if (req.responseType === 'json' && typeof body === 'string') {
                    // Save the original body, before attempting XSSI prefix stripping.
                    var originalBody = body;
                    body = body.replace(XSSI_PREFIX, '');
                    try {
                        // Attempt the parse. If it fails, a parse error should be delivered to the user.
                        body = body !== '' ? JSON.parse(body) : null;
                    }
                    catch (error) {
                        // Since the JSON.parse failed, it's reasonable to assume this might not have been a
                        // JSON response. Restore the original body (including any XSSI prefix) to deliver
                        // a better error response.
                        body = originalBody;
                        // If this was an error request to begin with, leave it as a string, it probably
                        // just isn't JSON. Otherwise, deliver the parsing error to the user.
                        if (ok) {
                            // Even though the response status was 2xx, this is still an error.
                            ok = false;
                            // The parse error contains the text of the body that failed to parse.
                            body = { error: error, text: body };
                        }
                    }
                }
                if (ok) {
                    // A successful response is delivered on the event stream.
                    observer.next(new HttpResponse({
                        body: body,
                        headers: headers,
                        status: status,
                        statusText: statusText,
                        url: url || undefined,
                    }));
                    // The full body has been received and delivered, no further events
                    // are possible. This request is complete.
                    observer.complete();
                }
                else {
                    // An unsuccessful request is delivered on the error channel.
                    observer.error(new HttpErrorResponse({
                        // The error in this case is the response body (error from the server).
                        error: body,
                        headers: headers,
                        status: status,
                        statusText: statusText,
                        url: url || undefined,
                    }));
                }
            }
1356243
function assertThrows(test) {
    var error = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : Error;
    var contains = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : [];


    if (!Array.isArray(contains)) contains = [contains];

    var shouldErrorName = typeof error === 'string' ? error : error.name;

    var nonThrown = new Error('util.assertThrowsAsync(): Missing rejection' + (error ? ' with ' + error.name : ''));
    var ensureErrorMatches = function ensureErrorMatches(error) {
        // wrong type
        if (error.constructor.name != shouldErrorName) {
            return new Error('\n             util.assertThrowsAsync(): Wrong Error-type\n             - is    : ' + error.constructor.name + '\n             - should: ' + shouldErrorName + '\n             - error: ' + error.toString() + '\n             ');
        }
        // check if contains
        var errorString = error.toString();
        if (contains.length > 0 && (0, _utils.oneOfArrayNotInString)(contains, errorString)) {
            return new Error('\n               util.assertThrowsAsync(): Error does not contain\n               - should contain: ' + contains + '\n               - is string: ' + error.toString() + '\n             ');
        }
        return false;
    };

    return new Promise(function (res, rej) {
        var val = void 0;
        try {
            val = test();
        } catch (err) {
            var wrong = ensureErrorMatches(err);
            if (wrong) rej(wrong);else res(err);
            return;
        }
        if ((0, _isPromise2['default'])(val)) {
            val.then(function () {
                // has not thrown
                rej(nonThrown);
            })['catch'](function (err) {
                var wrong = ensureErrorMatches(err);
                if (wrong) rej(wrong);else res(err);
            });
        } else rej(nonThrown);
    });
}
1069451
def assert_match(actual_string, expected_re, message="")
      _wrap_assertion {
        full_message = build_message(message, "Expected <?> to match <?>", actual_string, expected_re)
        assert_block(full_message) {
          expected_re =~ actual_string
        }
        Regexp.last_match
      }
    end
1038796
def validate_response(response, validator_map):
    
    validator = validator_map.response

    # Short circuit if we are supposed to not validate anything.
    returns_nothing = validator.schema.get('type') == 'void'
    body_empty = response.body in (None, b'', b'{}', b'null')
    if returns_nothing and body_empty:
        return

    # Don't attempt to validate non-success responses in v1.2
    if not 200 <= response.status_code <= 203:
        return

    validator.validate(prepare_body(response))
893532
def _check_response(response, items, default, indexed, stream, insensitive, fuzzy):
    ''''''
    # Set selection
    selection = None
    # if indexed, check for index
    if indexed:
        if response.isdigit():
            index_response = int(response)
            if index_response < len(items):
                selection = items[index_response]
    # if not matched by an index, match by text
    if selection is None:
        # insensivitize, if necessary
        original_items = items[:]
        original_response = response
        if insensitive:
            response = response.lower()
            items = [i.lower() for i in items]
        # Check for text matches
        if fuzzy:
            matches = _get_fuzzy_matches(response, items)
        # if insensitive, lowercase the comparison
        else:
            matches = [i for i in items if i.startswith(response)]
        # re-sensivitize if necessary
        if insensitive:
            matches = [
                i for i in original_items
                if i.lower() in matches
            ]
            response = original_response
        num_matches = len(matches)
        # Empty response, no default
        if response == '' and default is None:
            stream.write("[!] an empty response is not valid.\n")
        elif response == '':
            selection = default
        # Bad response
        elif num_matches == 0:
            stream.write("[!] \"{response}\" does not match any of the valid choices.\n".format(
                response=response
            ))
        # One match
        elif num_matches == 1:
            selection = matches[0]
        # Multiple matches
        else:
            # look for an exact match
            selection = _exact_match(response, matches, insensitive, fuzzy)
            # Multiple matches left
            if selection is None:
                stream.write("[!] \"{response}\" matches multiple choices:\n".format(
                    response=response
                ))
                for match in matches:
                    stream.write("[!]   {}\n".format(match))
                stream.write("[!] Please specify your choice further.\n")
    return selection