Navigation Menu

Skip to content

Commit

Permalink
Don't specify "Host" header when they are not required
Browse files Browse the repository at this point in the history
  • Loading branch information
piroor committed Aug 15, 2012
1 parent 48d7645 commit 93b7c94
Showing 1 changed file with 29 additions and 77 deletions.
106 changes: 29 additions & 77 deletions test/api-configuration.test.js
Expand Up @@ -320,11 +320,11 @@ suite('Configuration API', function() {
temporaryDatabase = undefined;
});

var defaultBaseHost = '127.0.0.1.xip.io:' + utils.testPort;

test('Get, Action=CreateDomain', function(done) {
utils
.get('/?DomainName=companies&Action=CreateDomain&Version=2011-02-01', {
'Host': utils.testConfigurationHost
})
.get('/?DomainName=companies&Action=CreateDomain&Version=2011-02-01')
.next(function(response) {
var domain = new Domain('companies', context);
assert.isTrue(domain.exists());
Expand All @@ -337,7 +337,7 @@ suite('Configuration API', function() {
Created: 'true',
Deleted: 'false',
DocService: {
Endpoint: domain.getDocumentsEndpoint('api.localhost')
Endpoint: domain.getDocumentsEndpoint(defaultBaseHost)
},
DomainId: domain.domainId,
DomainName: domain.name,
Expand All @@ -346,7 +346,7 @@ suite('Configuration API', function() {
SearchInstanceCount: String(domain.searchInstanceCount),
SearchPartitionCount: String(domain.searchPartitionCount),
SearchService: {
Endpoint: domain.getSearchEndpoint('api.localhost')
Endpoint: domain.getSearchEndpoint(defaultBaseHost)
}
};
var status = response.body.CreateDomainResponse.CreateDomainResult.DomainStatus;
Expand Down Expand Up @@ -536,15 +536,9 @@ suite('Configuration API', function() {
test('Get, Action=DescribeDomains (all domains)', function(done) {
var domain;
utils
.get('/?DomainName=domain3&Action=CreateDomain&Version=2011-02-01', {
'Host': utils.testConfigurationHost
})
.get('/?DomainName=domain1&Action=CreateDomain&Version=2011-02-01', {
'Host': utils.testConfigurationHost
})
.get('/?DomainName=domain2&Action=CreateDomain&Version=2011-02-01', {
'Host': utils.testConfigurationHost
})
.get('/?DomainName=domain3&Action=CreateDomain&Version=2011-02-01')
.get('/?DomainName=domain1&Action=CreateDomain&Version=2011-02-01')
.get('/?DomainName=domain2&Action=CreateDomain&Version=2011-02-01')
.get('/?Action=DescribeDomains&Version=2011-02-01')
.next(function(response) {
response = toParsedResponse(response);
Expand All @@ -565,15 +559,9 @@ suite('Configuration API', function() {

test('Get, Action=DescribeDomains (specified domains)', function(done) {
utils
.get('/?DomainName=domain3&Action=CreateDomain&Version=2011-02-01', {
'Host': utils.testConfigurationHost
})
.get('/?DomainName=domain1&Action=CreateDomain&Version=2011-02-01', {
'Host': utils.testConfigurationHost
})
.get('/?DomainName=domain2&Action=CreateDomain&Version=2011-02-01', {
'Host': utils.testConfigurationHost
})
.get('/?DomainName=domain3&Action=CreateDomain&Version=2011-02-01')
.get('/?DomainName=domain1&Action=CreateDomain&Version=2011-02-01')
.get('/?DomainName=domain2&Action=CreateDomain&Version=2011-02-01')
.get('/?Action=DescribeDomains&Version=2011-02-01' +
'&DomainNames.member.1=domain2' +
'&DomainNames.member.2=domain1')
Expand All @@ -596,9 +584,7 @@ suite('Configuration API', function() {

test('Get, Action=DefineIndexField (text, without options)', function(done) {
utils
.get('/?DomainName=companies&Action=CreateDomain&Version=2011-02-01', {
'Host': utils.testConfigurationHost
})
.get('/?DomainName=companies&Action=CreateDomain&Version=2011-02-01')
.get('/?DomainName=companies&IndexField.IndexFieldName=name&' +
'IndexField.IndexFieldType=text&' +
'Action=DefineIndexField&Version=2011-02-01')
Expand Down Expand Up @@ -632,9 +618,7 @@ suite('Configuration API', function() {

test('Get, Action=DefineIndexField (text, with options)', function(done) {
utils
.get('/?DomainName=companies&Action=CreateDomain&Version=2011-02-01', {
'Host': utils.testConfigurationHost
})
.get('/?DomainName=companies&Action=CreateDomain&Version=2011-02-01')
.get('/?DomainName=companies&IndexField.IndexFieldName=name&' +
'IndexField.IndexFieldType=text&' +
'TextOptions.FacetEnabled=true&TextOptions.ResultEnabled=true&' +
Expand Down Expand Up @@ -669,9 +653,7 @@ suite('Configuration API', function() {

test('Get, Action=DefineIndexField (uint)', function(done) {
utils
.get('/?DomainName=companies&Action=CreateDomain&Version=2011-02-01', {
'Host': utils.testConfigurationHost
})
.get('/?DomainName=companies&Action=CreateDomain&Version=2011-02-01')
.get('/?DomainName=companies&IndexField.IndexFieldName=age&' +
'IndexField.IndexFieldType=uint&' +
'Action=DefineIndexField&Version=2011-02-01')
Expand Down Expand Up @@ -703,9 +685,7 @@ suite('Configuration API', function() {

test('Get, Action=DefineIndexField (literal, without options)', function(done) {
utils
.get('/?DomainName=companies&Action=CreateDomain&Version=2011-02-01', {
'Host': utils.testConfigurationHost
})
.get('/?DomainName=companies&Action=CreateDomain&Version=2011-02-01')
.get('/?DomainName=companies&IndexField.IndexFieldName=product&' +
'IndexField.IndexFieldType=literal&' +
'Action=DefineIndexField&Version=2011-02-01')
Expand Down Expand Up @@ -740,9 +720,7 @@ suite('Configuration API', function() {

test('Get, Action=DefineIndexField (literal, with options)', function(done) {
utils
.get('/?DomainName=companies&Action=CreateDomain&Version=2011-02-01', {
'Host': utils.testConfigurationHost
})
.get('/?DomainName=companies&Action=CreateDomain&Version=2011-02-01')
.get('/?DomainName=companies&IndexField.IndexFieldName=product&' +
'IndexField.IndexFieldType=literal&' +
'LiteralOptions.SearchEnabled=true&' +
Expand Down Expand Up @@ -781,9 +759,7 @@ suite('Configuration API', function() {
test('Get, Action=DeleteIndexField (text)', function(done) {
var domain, field;
utils
.get('/?DomainName=companies&Action=CreateDomain&Version=2011-02-01', {
'Host': utils.testConfigurationHost
})
.get('/?DomainName=companies&Action=CreateDomain&Version=2011-02-01')
.get('/?DomainName=companies&IndexField.IndexFieldName=name&' +
'IndexField.IndexFieldType=text&' +
'Action=DefineIndexField&Version=2011-02-01')
Expand Down Expand Up @@ -814,9 +790,7 @@ suite('Configuration API', function() {
test('Get, Action=DeleteIndexField (uint)', function(done) {
var domain, field;
utils
.get('/?DomainName=companies&Action=CreateDomain&Version=2011-02-01', {
'Host': utils.testConfigurationHost
})
.get('/?DomainName=companies&Action=CreateDomain&Version=2011-02-01')
.get('/?DomainName=companies&IndexField.IndexFieldName=age&' +
'IndexField.IndexFieldType=uint&' +
'Action=DefineIndexField&Version=2011-02-01')
Expand Down Expand Up @@ -847,9 +821,7 @@ suite('Configuration API', function() {
test('Get, Action=DeleteIndexField (literal)', function(done) {
var domain, field;
utils
.get('/?DomainName=companies&Action=CreateDomain&Version=2011-02-01', {
'Host': utils.testConfigurationHost
})
.get('/?DomainName=companies&Action=CreateDomain&Version=2011-02-01')
.get('/?DomainName=companies&IndexField.IndexFieldName=product&' +
'IndexField.IndexFieldType=literal&' +
'Action=DefineIndexField&Version=2011-02-01')
Expand Down Expand Up @@ -893,9 +865,7 @@ suite('Configuration API', function() {
test('Get, Action=DescribeIndexFields (all fields)', function(done) {
var domain;
utils
.get('/?DomainName=companies&Action=CreateDomain&Version=2011-02-01', {
'Host': utils.testConfigurationHost
})
.get('/?DomainName=companies&Action=CreateDomain&Version=2011-02-01')
.get('/?DomainName=companies&IndexField.IndexFieldName=name&' +
'IndexField.IndexFieldType=text&' +
'Action=DefineIndexField&Version=2011-02-01')
Expand Down Expand Up @@ -930,9 +900,7 @@ suite('Configuration API', function() {

test('Get, Action=DescribeIndexFields (specified fields)', function(done) {
utils
.get('/?DomainName=companies&Action=CreateDomain&Version=2011-02-01', {
'Host': utils.testConfigurationHost
})
.get('/?DomainName=companies&Action=CreateDomain&Version=2011-02-01')
.get('/?DomainName=companies&IndexField.IndexFieldName=name&' +
'IndexField.IndexFieldType=text&' +
'Action=DefineIndexField&Version=2011-02-01')
Expand Down Expand Up @@ -968,9 +936,7 @@ suite('Configuration API', function() {

test('Get, Action=IndexDocuments', function(done) {
utils
.get('/?DomainName=companies&Action=CreateDomain&Version=2011-02-01', {
'Host': utils.testConfigurationHost
})
.get('/?DomainName=companies&Action=CreateDomain&Version=2011-02-01')
.get('/?DomainName=companies&IndexField.IndexFieldName=name&' +
'Action=DefineIndexField&Version=2011-02-01')
.get('/?DomainName=companies&IndexField.IndexFieldName=age&' +
Expand Down Expand Up @@ -1021,17 +987,13 @@ suite('Configuration API', function() {
var json = JSON.stringify(synonymsObject);
var synonyms = encodeURIComponent(json);
utils
.get('/?DomainName=companies&Action=CreateDomain&Version=2011-02-01', {
'Host': utils.testConfigurationHost
})
.get('/?DomainName=companies&Action=CreateDomain&Version=2011-02-01')
.next(function() {
domain = new Domain('companies', context);
assert.isFalse(domain.hasSynonymsTableSync());
})
.get('/?Version=2011-02-01&Action=UpdateSynonymOptions&' +
'DomainName=companies&Synonyms='+synonyms, {
'Host': utils.testConfigurationHost
})
'DomainName=companies&Synonyms='+synonyms)
.next(function(response) {
assert.isTrue(domain.hasSynonymsTableSync());

Expand Down Expand Up @@ -1070,9 +1032,7 @@ suite('Configuration API', function() {
var json = JSON.stringify(synonymsObject);
var synonyms = encodeURIComponent(json);
utils
.get('/?DomainName=companies&Action=CreateDomain&Version=2011-02-01', {
'Host': utils.testConfigurationHost
})
.get('/?DomainName=companies&Action=CreateDomain&Version=2011-02-01')
.get('/?Version=2011-02-01&Action=DescribeSynonymOptions&' +
'DomainName=companies')
.next(function(response) {
Expand Down Expand Up @@ -1122,9 +1082,7 @@ suite('Configuration API', function() {
test('Get, Action=UpdateDefaultSearchField', function(done) {
var domain;
utils
.get('/?DomainName=companies&Action=CreateDomain&Version=2011-02-01', {
'Host': utils.testConfigurationHost
})
.get('/?DomainName=companies&Action=CreateDomain&Version=2011-02-01')
.get('/?DomainName=companies&IndexField.IndexFieldName=name&' +
'Action=DefineIndexField&Version=2011-02-01')
.next(function() {
Expand Down Expand Up @@ -1175,9 +1133,7 @@ suite('Configuration API', function() {
test('Get, Action=DescribeDefaultSearchField', function(done) {
var domain;
utils
.get('/?DomainName=companies&Action=CreateDomain&Version=2011-02-01', {
'Host': utils.testConfigurationHost
})
.get('/?DomainName=companies&Action=CreateDomain&Version=2011-02-01')
.get('/?DomainName=companies&IndexField.IndexFieldName=name&' +
'Action=DefineIndexField&Version=2011-02-01')
.get('/?Version=2011-02-01&Action=DescribeDefaultSearchField&' +
Expand Down Expand Up @@ -1218,9 +1174,7 @@ suite('Configuration API', function() {

test('Get, no version', function(done) {
utils
.get('/?Action=unknown', {
'Host': utils.testConfigurationHost
})
.get('/?Action=unknown')
.next(function(response) {
response = toParsedResponse(response);
assert.deepEqual(response.pattern,
Expand All @@ -1243,9 +1197,7 @@ suite('Configuration API', function() {

test('Get, invalid version', function(done) {
utils
.get('/?Version=2011-02-02&Action=unknown', {
'Host': utils.testConfigurationHost
})
.get('/?Version=2011-02-02&Action=unknown')
.next(function(response) {
response = toParsedResponse(response);
assert.deepEqual(response.pattern,
Expand Down

0 comments on commit 93b7c94

Please sign in to comment.