Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
test('IdentityService: Test delete() function', (t) => {
const client = new FabricCAClient({ protocol: 'http', hostname: '127.0.0.1', port: 7054 });
const identity = new IdentityService(client);
t.throws(() => {
identity.delete();
},
/Missing required argument "enrollmentID", or argument "enrollmentID" is not a valid string/,
'Must fail if missing or invalid enrollmentID argument');
t.throws(() => {
identity.delete('enrollmentID');
},
/Missing required argument "registrar"/,
'Must fail if missing registrar argument');
t.throws(() => {
identity.delete('enrollmentID', {});
},
test('IdentityService: Test getOne() function', (t) => {
const client = new FabricCAClient({ protocol: 'http', hostname: '127.0.0.1', port: 7054 });
const identity = new IdentityService(client);
t.throws(() => {
identity.getOne();
},
/Missing required argument "enrollmentID", or argument "enrollmentID" is not a valid string/,
'Must fail if missing or invalid enrollmentID argument');
t.throws(() => {
identity.getOne('enrollmentID');
},
/Missing required argument "registrar"/,
'Must fail if missing registrar argument');
t.throws(() => {
identity.getOne('enrollmentID', {});
},
test('IdentityService: Test getAll() function', (t) => {
const client = new FabricCAClient({ protocol: 'http', hostname: '127.0.0.1', port: 7054 });
const identity = new IdentityService(client);
t.throws(() => {
identity.getAll();
},
/Missing required argument "registrar"/,
'Must fail if missing registrar argument');
t.throws(() => {
identity.getAll({});
},
/Argument "registrar" must be an instance of the class "User"/,
'Must fail if registrar argument is not a User object');
t.throws(() => {
const registrar = new User('bob');
identity.getAll(registrar);
test('IdentityService: Test create() function', (t) => {
const client = new FabricCAClient({ protocol: 'http', hostname: '127.0.0.1', port: 7054 });
const identity = new IdentityService(client);
t.throws(() => {
identity.create();
},
/Missing required argument "req"/,
'Must fail if missing request argument');
t.throws(() => {
identity.create({ enrollmentID: null });
},
/Missing required parameters. "req.enrollmentID", "req.affiliation" are all required./,
'Must fail if missing req.enrollmentID and req.affiliation argument');
t.throws(() => {
identity.create({ enrollmentID: 'dummy', affiliation: 'dummy' });
},
test('IdentityService: Test update() function', (t) => {
const client = new FabricCAClient({ protocol: 'http', hostname: '127.0.0.1', port: 7054 });
const identity = new IdentityService(client);
t.throws(() => {
identity.update();
},
/Missing required argument "enrollmentID", or argument "enrollmentID" is not a valid string/,
'Must fail if missing or invalid enrollmentID argument');
t.throws(() => {
identity.update('enrollmentID', {});
},
/Missing required argument "registrar"/,
'Must fail if missing registrar argument');
t.throws(() => {
identity.update('enrollmentID', {}, {});
},