示例#1
0
TEST(function test_resolveSoa(done) {
  var req = dns.resolveSoa('nodejs.org', function(err, result) {
    if (err) throw err;

    assert.ok(result);
    assert.ok(typeof result === 'object');

    assert.ok(typeof result.nsname === 'string');
    assert.ok(result.nsname.length > 0);

    assert.ok(typeof result.hostmaster === 'string');
    assert.ok(result.hostmaster.length > 0);

    assert.ok(typeof result.serial === 'number');
    assert.ok((result.serial > 0) && (result.serial < 4294967295));

    assert.ok(typeof result.refresh === 'number');
    assert.ok((result.refresh > 0) && (result.refresh < 2147483647));

    assert.ok(typeof result.retry === 'number');
    assert.ok((result.retry > 0) && (result.retry < 2147483647));

    assert.ok(typeof result.expire === 'number');
    assert.ok((result.expire > 0) && (result.expire < 2147483647));

    assert.ok(typeof result.minttl === 'number');
    assert.ok((result.minttl >= 0) && (result.minttl < 2147483647));

    done();
  });

  checkWrap(req);
});
示例#2
0
TEST(function test_resolveSoa(done) {
  const req = dns.resolveSoa('nodejs.org', function(err, result) {
    assert.ifError(err);
    assert.ok(result);
    assert.strictEqual(typeof result, 'object');

    assert.strictEqual(typeof result.nsname, 'string');
    assert.ok(result.nsname.length > 0);

    assert.strictEqual(typeof result.hostmaster, 'string');
    assert.ok(result.hostmaster.length > 0);

    assert.strictEqual(typeof result.serial, 'number');
    assert.ok((result.serial > 0) && (result.serial < 4294967295));

    assert.strictEqual(typeof result.refresh, 'number');
    assert.ok((result.refresh > 0) && (result.refresh < 2147483647));

    assert.strictEqual(typeof result.retry, 'number');
    assert.ok((result.retry > 0) && (result.retry < 2147483647));

    assert.strictEqual(typeof result.expire, 'number');
    assert.ok((result.expire > 0) && (result.expire < 2147483647));

    assert.strictEqual(typeof result.minttl, 'number');
    assert.ok((result.minttl >= 0) && (result.minttl < 2147483647));

    done();
  });

  checkWrap(req);
});
示例#3
0
TEST(async function test_resolveSoa(done) {
  function validateResult(result) {
    assert.strictEqual(typeof result, 'object');
    assert.strictEqual(typeof result.nsname, 'string');
    assert.ok(result.nsname.length > 0);
    assert.strictEqual(typeof result.hostmaster, 'string');
    assert.ok(result.hostmaster.length > 0);
    assert.strictEqual(typeof result.serial, 'number');
    assert.ok((result.serial > 0) && (result.serial < 4294967295));
    assert.strictEqual(typeof result.refresh, 'number');
    assert.ok((result.refresh > 0) && (result.refresh < 2147483647));
    assert.strictEqual(typeof result.retry, 'number');
    assert.ok((result.retry > 0) && (result.retry < 2147483647));
    assert.strictEqual(typeof result.expire, 'number');
    assert.ok((result.expire > 0) && (result.expire < 2147483647));
    assert.strictEqual(typeof result.minttl, 'number');
    assert.ok((result.minttl >= 0) && (result.minttl < 2147483647));
  }

  validateResult(await dnsPromises.resolveSoa(addresses.SOA_HOST));

  const req = dns.resolveSoa(addresses.SOA_HOST, function(err, result) {
    assert.ifError(err);
    validateResult(result);
    done();
  });

  checkWrap(req);
});
示例#4
0
TEST(function test_resolveSoa_failure(done) {
  var req = dns.resolveSoa('something.invalid', function(err, result) {
    assert.ok(err instanceof Error);
    assert.strictEqual(err.errno, 'ENOTFOUND');

    assert.strictEqual(result, undefined);

    done();
  });

  checkWrap(req);
});
示例#5
0
TEST(function test_resolveSoa_failure(done) {
  dnsPromises.resolveSoa(addresses.INVALID_HOST)
    .then(common.mustNotCall())
    .catch(common.expectsError({ errno: 'ENOTFOUND' }));

  const req = dns.resolveSoa(addresses.INVALID_HOST, function(err, result) {
    assert.ok(err instanceof Error);
    assert.strictEqual(err.errno, 'ENOTFOUND');

    assert.strictEqual(result, undefined);

    done();
  });

  checkWrap(req);
});