Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
it("Accessing container without permission fails", async function() {
const clientNoPermission = new CosmosClient({ endpoint, auth: null });
try {
await clientNoPermission
.database(database.id)
.container(container.id)
.read();
assert.fail("accessing container did not throw");
} catch (err) {
assert(err !== undefined); // TODO: should check that we get the right error message
}
});
it("MalformedCertificate", function() {
// Copy the default certificate.
var malformedCertificate = new Data
(this.fixture_.subIdentity_.getDefaultKey().getDefaultCertificate());
malformedCertificate.getMetaInfo().setType(ContentType.BLOB);
this.fixture_.keyChain_.sign
(malformedCertificate, new SigningInfo(this.fixture_.identity_));
// It has the wrong content type and a missing ValidityPeriod.
try {
new CertificateV2(malformedCertificate).wireEncode();
assert.fail('', '', "Did not throw the expected exception");
} catch (ex) {
if (!(ex instanceof CertificateV2.Error))
assert.fail('', '', "Did not throw the expected exception");
}
var originalProcessInterest = this.fixture_.face_.processInterest_;
this.fixture_.face_.processInterest_ = function
(interest, onData, onTimeout, onNetworkNack) {
if (interest.getName().isPrefixOf(malformedCertificate.getName()))
onData(interest, malformedCertificate);
else
originalProcessInterest.processInterest
(interest, onData, onTimeout, onNetworkNack);
};
var data = new Data(new Name("/Security/V2/ValidatorFixture/Sub1/Sub2/Data"));
this.fixture_.keyChain_.sign(data, new SigningInfo(this.fixture_.subIdentity_));
this.validateExpectFailure(data, "Signed by a malformed certificate");
}
catch ( e )
{
assert.ok( e.message.search( mb_common.name ) !== -1,
"Method override getter failure should contain method name"
);
// ensure we have the correct error
assert.ok( e.message.search( 'getter' ) !== -1,
"Proper error is thrown for getter override failure"
);
return;
}
assert.fail(
"Should not be permitted to override getters with methods"
);
} )();
( function testNamedClassDefinitionRequiresThatDefinitionBeAnObject()
{
var name = 'Foo';
try
{
Class( name, 'Bar' );
// if all goes well, we'll never get to this point
assert.fail( "Second argument to named class must be the definition" );
}
catch ( e )
{
assert.notEqual(
e.message.match( name ),
null,
"Class definition argument count error string contains class name"
);
}
} )();
const storager = new StorageProvider({
extensionsFolder: { path: TEST_PATH_EXTENSIONS },
cacheFolder: new Location(
`${TEST_PATH_EXTENSIONS}-cache`
),
});
storager.unzipCrx = () => Promise.reject('Cannot unzip archive');
// todo: someday, use assert.rejects (availabe in node 10)
try {
await storager.installExtension(FAKE_DL_DESCRIPTOR);
} catch (err) {
assert.equal('Cannot unzip archive', err);
return;
}
assert.fail('Install should fail if archive cannot be unzipped');
});
it('data too short error.', async() => {
try {
tp.pickUpRevertReason(Buffer.from('hoge'))
assert.fail('must be error')
} catch (e) {
assert.equal('returndata.length is MUST 100+.', e.message)
}
})
})
function asserEqual(expected, actual) {
if (!actual.Equals(expected)) {
var msg = String.Format('{0} was expected, but got {1} instead.', expected, actual);
assert.fail(actual, expected, msg, 'Object.Equals(Object)');
}
}
//# sourceMappingURL=index.js.map
return evaluate(this.subject_, function (actual) {
if (!isNumber(actual) || actual > expected) {
assert.fail(actual, expected, opt_message, '<=');
}
});
}
function listener() {
assert.fail('received unexpected warning');
}
assert.isEmpty = function (actual, message) {
assertMissingArguments(arguments, assert.isEmpty);
if ((isObject(actual) && Object.keys(actual).length > 0) || actual.length > 0) {
assert.fail(actual, 0, message || "expected {actual} to be empty", "length", assert.isEmpty);
}
};
assert.isNotEmpty = function (actual, message) {