Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Added tests for transfers over Service Net

  • Loading branch information...
commit d33378c1e1ae77014ec8a4e3f5a5760ba464593d 1 parent 6e49b35
@davidwood davidwood authored
Showing with 63 additions and 0 deletions.
  1. +63 −0 test/servicenet-test.js
View
63 test/servicenet-test.js
@@ -0,0 +1,63 @@
+/*
+ * servicenet-test.js: Tests for Rackspace Cloudfiles Service Net transfer
+ *
+ * MIT LICENSE
+ *
+ */
+
+var path = require('path'),
+ vows = require('vows'),
+ assert = require('assert'),
+ helpers = require('./helpers'),
+ cloudfiles = require('../lib/cloudfiles');
+
+// Create a config that has servicenet = true
+var testConfig = helpers.loadConfig(),
+ snConfig = {};
+for (var key in testConfig) {
+ if (testConfig.hasOwnProperty(key)) snConfig[key] = testConfig[key];
+}
+snConfig.servicenet = true;
+
+var client = helpers.createClient(),
+ snClient = cloudfiles.createClient(snConfig);
+
+vows.describe('node-cloudfiles/servicenet').addBatch({
+ "The node-cloudfiles client": {
+ "with valid credentials and not specifying Service Net transfer": {
+ topic: function () {
+ client.setAuth(this.callback);
+ },
+ "should respond with 204 and appropriate headers": function (err, res) {
+ assert.equal(res.statusCode, 204);
+ assert.isObject(res.headers);
+ assert.include(res.headers, 'x-server-management-url');
+ assert.include(res.headers, 'x-storage-url');
+ assert.include(res.headers, 'x-cdn-management-url');
+ assert.include(res.headers, 'x-auth-token');
+ },
+ "should update the config with non-Service Net storage url": function (err, res) {
+ assert.equal(res.headers['x-storage-url'], client.config.storageUrl);
+ assert.ok(client.config.storageUrl.substring(0, 13) != 'https://snet-');
+ }
+ },
+ "with valid credentials and specifying Service Net transfer": {
+ topic: function () {
+ snClient.setAuth(this.callback);
+ },
+ "should respond with 204 and appropriate headers": function (err, res) {
+ assert.equal(res.statusCode, 204);
+ assert.isObject(res.headers);
+ assert.include(res.headers, 'x-server-management-url');
+ assert.include(res.headers, 'x-storage-url');
+ assert.include(res.headers, 'x-cdn-management-url');
+ assert.include(res.headers, 'x-auth-token');
+ },
+ "should update the config with non-Service Net storage url": function (err, res) {
+ assert.notEqual(res.headers['x-storage-url'], snClient.config.storageUrl);
+ assert.ok(snClient.config.storageUrl.substring(0, 13) == 'https://snet-');
+ }
+ },
+ }
+}).export(module);
+
Please sign in to comment.
Something went wrong with that request. Please try again.