Skip to content

Commit d33378c

Browse files
committed
Added tests for transfers over Service Net
1 parent 6e49b35 commit d33378c

1 file changed

Lines changed: 63 additions & 0 deletions

File tree

test/servicenet-test.js

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
/*
2+
* servicenet-test.js: Tests for Rackspace Cloudfiles Service Net transfer
3+
*
4+
* MIT LICENSE
5+
*
6+
*/
7+
8+
var path = require('path'),
9+
vows = require('vows'),
10+
assert = require('assert'),
11+
helpers = require('./helpers'),
12+
cloudfiles = require('../lib/cloudfiles');
13+
14+
// Create a config that has servicenet = true
15+
var testConfig = helpers.loadConfig(),
16+
snConfig = {};
17+
for (var key in testConfig) {
18+
if (testConfig.hasOwnProperty(key)) snConfig[key] = testConfig[key];
19+
}
20+
snConfig.servicenet = true;
21+
22+
var client = helpers.createClient(),
23+
snClient = cloudfiles.createClient(snConfig);
24+
25+
vows.describe('node-cloudfiles/servicenet').addBatch({
26+
"The node-cloudfiles client": {
27+
"with valid credentials and not specifying Service Net transfer": {
28+
topic: function () {
29+
client.setAuth(this.callback);
30+
},
31+
"should respond with 204 and appropriate headers": function (err, res) {
32+
assert.equal(res.statusCode, 204);
33+
assert.isObject(res.headers);
34+
assert.include(res.headers, 'x-server-management-url');
35+
assert.include(res.headers, 'x-storage-url');
36+
assert.include(res.headers, 'x-cdn-management-url');
37+
assert.include(res.headers, 'x-auth-token');
38+
},
39+
"should update the config with non-Service Net storage url": function (err, res) {
40+
assert.equal(res.headers['x-storage-url'], client.config.storageUrl);
41+
assert.ok(client.config.storageUrl.substring(0, 13) != 'https://snet-');
42+
}
43+
},
44+
"with valid credentials and specifying Service Net transfer": {
45+
topic: function () {
46+
snClient.setAuth(this.callback);
47+
},
48+
"should respond with 204 and appropriate headers": function (err, res) {
49+
assert.equal(res.statusCode, 204);
50+
assert.isObject(res.headers);
51+
assert.include(res.headers, 'x-server-management-url');
52+
assert.include(res.headers, 'x-storage-url');
53+
assert.include(res.headers, 'x-cdn-management-url');
54+
assert.include(res.headers, 'x-auth-token');
55+
},
56+
"should update the config with non-Service Net storage url": function (err, res) {
57+
assert.notEqual(res.headers['x-storage-url'], snClient.config.storageUrl);
58+
assert.ok(snClient.config.storageUrl.substring(0, 13) == 'https://snet-');
59+
}
60+
},
61+
}
62+
}).export(module);
63+

0 commit comments

Comments
 (0)