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 HTTP 2.0 Enabled plugin #607

Closed
wants to merge 1 commit 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
125 changes: 125 additions & 0 deletions plugins/azure/appservice/http20Enabled.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,125 @@
var expect = require('chai').expect;
var http20Enabled = require('./http20Enabled');

const webApps = [
{
'id': '/subscriptions/123/resourceGroups/aqua-resource-group/providers/Microsoft.Web/sites/app1',
'name': 'app1'
}
];

const configurations = [
{
'id': '/subscriptions/123/resourceGroups/aqua-resource-group/providers/Microsoft.Web/sites/app1/config/web',
'http20Enabled': true
},
{
'id': '/subscriptions/123/resourceGroups/aqua-resource-group/providers/Microsoft.Web/sites/app1/config/web',
'http20Enabled': false
}
];

const createCache = (webApps, configurations) => {
let configs = {};
if (webApps.length > 0) {
configs[webApps[0].id] = {
data: configurations
};
}
return {
webApps: {
list: {
'eastus': {
data: webApps
}
},
listConfigurations: {
'eastus': configs
}
}
};
};

const createErrorCache = (key) => {
if (key === 'webApp') {
return {
webApps: {
list: {
'eastus': {}
}
}
};
} else {
return {
webApps: {
list: {
'eastus': {
data: [webApps[0]]
}
},
listConfigurations: {
'eastus': {}
}
}
};
}
};

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

it('should give unknown result if unable to query for app service', function(done) {
const cache = createErrorCache('webApp');
http20Enabled.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 App Services');
expect(results[0].region).to.equal('eastus');
done();
});
});

it('should give unknown result if unable to query app service', function(done) {
const cache = createErrorCache('configs');
http20Enabled.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 App Service');
expect(results[0].region).to.equal('eastus');
done();
});
});

it('should give passing result if app service has http 2.0 enabled', function(done) {
const cache = createCache([webApps[0]], [configurations[0]]);
http20Enabled.run(cache, {}, (err, results) => {
expect(results.length).to.equal(1);
expect(results[0].status).to.equal(0);
expect(results[0].message).to.include('App Service has HTTP 2.0 enabled');
expect(results[0].region).to.equal('eastus');
done();
});
});

it('should give failing result if app service does not have http 2.0 enabled', function(done) {
const cache = createCache([webApps[0]], [configurations[1]]);
http20Enabled.run(cache, {}, (err, results) => {
expect(results.length).to.equal(1);
expect(results[0].status).to.equal(2);
expect(results[0].message).to.include('App Service does not have HTTP 2.0 enabled');
expect(results[0].region).to.equal('eastus');
done();
});
});
});
});