Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

put and get tests

  • Loading branch information...
commit 6faa2cc8fb2ff9620feba2e4142964723cc6dbd4 1 parent d08043f
Dmytro Yashkir authored
2  local_test.js
View
@@ -3,5 +3,5 @@ var s3 = require('./index');
var putUrl = s3.urlSigner(123, 'abc', {
host: 'localhost',
port: 1234
-}).getUrl('PUT', 'toto.json', 'my_bucket', 600);
+}).getUrl('GET', 'toto.json', 'my_bucket', 600);
console.log(putUrl);
7 package.json
View
@@ -17,5 +17,10 @@
"signing"
],
"author": "Dmytro Yashkir",
- "license": "BSD"
+ "license": "BSD",
+ "devDependencies": {
+ "mocha": "~1.17.1",
+ "should": "~3.1.3",
+ "request": "~2.34.0"
+ }
}
26 test/s3_files/my_bucket/toto.json/.fakes3_metadataFFF/content
View
@@ -0,0 +1,26 @@
+{
+ "name": "amazon-s3-url-signer",
+ "version": "0.0.7",
+ "description": "Module to sign urls to allow access to resources in the S3",
+ "main": "index.js",
+ "scripts": {
+ "test": "echo \"Error: no test specified\" && exit 1"
+ },
+ "repository": {
+ "type": "git",
+ "url": "https://github.com/dyashkir/amazon-s3-url-signer"
+ },
+ "keywords": [
+ "amazon",
+ "S3",
+ "url",
+ "signing"
+ ],
+ "author": "Dmytro Yashkir",
+ "license": "BSD",
+ "devDependencies": {
+ "mocha": "~1.17.1",
+ "should": "~3.1.3",
+ "request": "~2.34.0"
+ }
+}
3  test/s3_files/my_bucket/toto.json/.fakes3_metadataFFF/metadata
View
@@ -0,0 +1,3 @@
+---
+:md5: 53b133105f61a97344c207d9a393778d
+:content_type: application/json
74 test/test.js
View
@@ -0,0 +1,74 @@
+var should = require('should')
+ , request = require('request')
+ , fs = require('fs')
+ , spawn = require('child_process').spawn
+
+var local = 'localhost:1234';
+
+var s3 = require('../index');
+var signer = null;
+
+describe('amazon-s3-url-signer', function(){
+ var fakes = null;
+
+ before(function(done){
+ signer = s3.urlSigner(123, 'abc', {
+ host: 'localhost',
+ port: 1234,
+ protocol: 'http'
+ });
+
+ //start fake s3
+ /*console.dir('-r test/s3_files -p 1234'.split(' '))
+ fakes = spawn('fakes3', '-r test/s3_files -p 1234'.split(' '))
+
+ fakes.stdout.on('data', function (data) {
+ console.log('stdout: ' + data);
+ });
+ fakes.on('exit', function (code) {
+ console.log('child process exited with code ' + code);
+ });
+ */
+ done()
+ })
+
+ after(function(done){
+ //fakes.kill();
+ done();
+ })
+
+ it('amazon local test server should respond', function(done){
+ request('http://' + local + '/',
+ function(err, res, body){
+ res.statusCode.should.eql(200);
+ done();
+ });
+ });
+
+ it('should exist', function(done){
+ should.exist(signer);
+ done();
+ })
+ it('should generate a valid PUT url', function(done){
+ var purl = signer.getUrl('PUT', 'toto.json', 'my_bucket', 600);
+ purl.should.be.type('string');
+ console.log(purl);
+
+ fs.createReadStream('package.json').pipe(request.put(purl, function(err, res){
+ should.not.exist(err);
+ res.statusCode.should.eql(200);
+ done();
+ }))
+ })
+
+ it('should generate a valid GET url', function(done){
+ var purl = signer.getUrl('GET', 'toto.json', 'my_bucket', 600);
+ purl.should.be.type('string');
+ request.get(purl, function(err, res, body){
+ should.not.exist(err);
+ res.statusCode.should.eql(200);
+ should.exist(JSON.parse(body))
+ done();
+ })
+ })
+});
Please sign in to comment.
Something went wrong with that request. Please try again.