Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

spec: Added test case file for File Service Encryption plugin #600

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
99 changes: 99 additions & 0 deletions plugins/azure/storageaccounts/fileServiceEncryption.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
var expect = require('chai').expect;
var fileServiceIEncryption = require('./fileServiceEncryption');

const storageAccounts = [
{
'id': '/subscriptions/123/resourceGroups/aqua-resource-group/providers/Microsoft.Storage/storageAccounts/acc',
'location': 'eastus',
'name': 'acc',
'encryption': {
'services': {
'file': {
'enabled': true
}
}
}
},
{
'id': '/subscriptions/123/resourceGroups/aqua-resource-group/providers/Microsoft.Storage/storageAccounts/acc',
'location': 'eastus',
'name': 'acc',
'encryption': {
'services': {
'blob': {
'enabled': false
}
}
}
}
];

const createCache = (storageAccounts) => {
return {
storageAccounts: {
list: {
'eastus': {
data: storageAccounts
}
}
}
};
};

const createErrorCache = () => {
return {
storageAccounts: {
list: {
'eastus': {}
}
}
};
};

describe('fileServiceIEncryption', function() {
describe('run', function() {
it('should give passing result if no storage accounts', function(done) {
const cache = createCache([]);
fileServiceIEncryption.run(cache, {}, (err, results) => {
expect(results.length).to.equal(1);
expect(results[0].status).to.equal(0);
expect(results[0].message).to.include('No storage accounts found');
expect(results[0].region).to.equal('eastus');
done();
});
});

it('should give unknown result if unable to query for storage accounts', function(done) {
const cache = createErrorCache();
fileServiceIEncryption.run(cache, {}, (err, results) => {
expect(results.length).to.equal(1);
expect(results[0].status).to.equal(3);
expect(results[0].message).to.include('Unable to query for storage accounts');
expect(results[0].region).to.equal('eastus');
done();
});
});

it('should give passing result if file encryption is enabled', function(done) {
const cache = createCache([storageAccounts[0]]);
fileServiceIEncryption.run(cache, {}, (err, results) => {
expect(results.length).to.equal(1);
expect(results[0].status).to.equal(0);
expect(results[0].message).to.include('Encryption is enabled on the File Service');
expect(results[0].region).to.equal('eastus');
done();
});
});

it('should give failing result if file encryption is not enabled', function(done) {
const cache = createCache([storageAccounts[1]]);
fileServiceIEncryption.run(cache, {}, (err, results) => {
expect(results.length).to.equal(1);
expect(results[0].status).to.equal(2);
expect(results[0].message).to.include('Encryption is disabled on the File Service');
expect(results[0].region).to.equal('eastus');
done();
});
});
});
});