hard to do oauth units, possibly move to acceptance fully
This commit is contained in:
parent
a062721cc6
commit
92660caea4
@ -1,12 +1,16 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
|
||||||
# this script prepare database and redis instance to run accpetance test
|
# this script prepare database and redis instance to run accpetance test
|
||||||
|
|
||||||
echo "preparing redis..."
|
echo "preparing redis..."
|
||||||
echo "HSET rails:users:vizzuality id 1" | redis-cli -n 5
|
echo "HSET rails:users:vizzuality id 1" | redis-cli -n 5
|
||||||
echo "HSET rails:users:vizzuality database_name cartodb_test_user_1_db" | redis-cli -n 5
|
echo "HSET rails:users:vizzuality database_name cartodb_test_user_1_db" | redis-cli -n 5
|
||||||
echo "SADD rails:users:vizzuality:map_key 1234" | redis-cli -n 5
|
echo "SADD rails:users:vizzuality:map_key 1234" | redis-cli -n 5
|
||||||
|
echo "hset rails:oauth_access_tokens:l0lPbtP68ao8NfStCiA3V3neqfM03JKhToxhUQTR consumer_key fZeNGv5iYayvItgDYHUbot1Ukb5rVyX6QAg8GaY2" | redis-cli -n 5
|
||||||
|
echo "hset rails:oauth_access_tokens:l0lPbtP68ao8NfStCiA3V3neqfM03JKhToxhUQTR consumer_secret IBLCvPEefxbIiGZhGlakYV4eM8AbVSwsHxwEYpzx" | redis-cli -n 5
|
||||||
|
echo "hset rails:oauth_access_tokens:l0lPbtP68ao8NfStCiA3V3neqfM03JKhToxhUQTR access_token_token l0lPbtP68ao8NfStCiA3V3neqfM03JKhToxhUQTR" | redis-cli -n 5
|
||||||
|
echo "hset rails:oauth_access_tokens:l0lPbtP68ao8NfStCiA3V3neqfM03JKhToxhUQTR access_token_secret 22zBIek567fMDEebzfnSdGe8peMFVFqAreOENaDK" | redis-cli -n 5
|
||||||
|
echo "hset rails:oauth_access_tokens:l0lPbtP68ao8NfStCiA3V3neqfM03JKhToxhUQTR user_id 1" | redis-cli -n 5
|
||||||
|
echo "hset rails:oauth_access_tokens:l0lPbtP68ao8NfStCiA3V3neqfM03JKhToxhUQTR time sometime" | redis-cli -n 5
|
||||||
|
|
||||||
|
|
||||||
echo "preparing postgres..."
|
echo "preparing postgres..."
|
||||||
@ -14,6 +18,7 @@ dropdb -Upostgres -hlocalhost cartodb_test_user_1_db
|
|||||||
createdb -Upostgres -hlocalhost -Ttemplate_postgis -Opostgres -EUTF8 cartodb_test_user_1_db
|
createdb -Upostgres -hlocalhost -Ttemplate_postgis -Opostgres -EUTF8 cartodb_test_user_1_db
|
||||||
psql -Upostgres -hlocalhost cartodb_test_user_1_db < test.sql
|
psql -Upostgres -hlocalhost cartodb_test_user_1_db < test.sql
|
||||||
|
|
||||||
|
|
||||||
echo "ok, you can run test now"
|
echo "ok, you can run test now"
|
||||||
|
|
||||||
|
|
||||||
|
@ -48,18 +48,10 @@ tests['test headers take presedence over query parameters'] = function(){
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
// before this, you must embed the test OAUTH hash in redis so everything works.
|
//the headers for this are:
|
||||||
// Request url: http://vizzuality.testhost.lan/api/v1/tables
|
var real_oauth_header = 'OAuth realm="http://vizzuality.testhost.lan/",oauth_consumer_key="fZeNGv5iYayvItgDYHUbot1Ukb5rVyX6QAg8GaY2",oauth_token="l0lPbtP68ao8NfStCiA3V3neqfM03JKhToxhUQTR",oauth_signature_method="HMAC-SHA1", oauth_signature="o4hx4hWP6KtLyFwggnYB4yPK8xI%3D",oauth_timestamp="1313581372",oauth_nonce="W0zUmvyC4eVL8cBd4YwlH1nnPTbxW0QBYcWkXTwe4",oauth_version="1.0"';
|
||||||
// hset rails:oauth_access_tokens:l0lPbtP68ao8NfStCiA3V3neqfM03JKhToxhUQTR consumer_key fZeNGv5iYayvItgDYHUbot1Ukb5rVyX6QAg8GaY2
|
|
||||||
// hset rails:oauth_access_tokens:l0lPbtP68ao8NfStCiA3V3neqfM03JKhToxhUQTR consumer_secret IBLCvPEefxbIiGZhGlakYV4eM8AbVSwsHxwEYpzx
|
|
||||||
// hset rails:oauth_access_tokens:l0lPbtP68ao8NfStCiA3V3neqfM03JKhToxhUQTR access_token_token l0lPbtP68ao8NfStCiA3V3neqfM03JKhToxhUQTR
|
|
||||||
// hset rails:oauth_access_tokens:l0lPbtP68ao8NfStCiA3V3neqfM03JKhToxhUQTR access_token_secret 22zBIek567fMDEebzfnSdGe8peMFVFqAreOENaDK
|
|
||||||
// hset rails:oauth_access_tokens:l0lPbtP68ao8NfStCiA3V3neqfM03JKhToxhUQTR user_id 1
|
|
||||||
// hset rails:oauth_access_tokens:l0lPbtP68ao8NfStCiA3V3neqfM03JKhToxhUQTR time sometime
|
|
||||||
|
|
||||||
////the headers for this are:
|
//TODO FIX
|
||||||
//var real_oauth_header = 'OAuth realm="http://vizzuality.testhost.lan/",oauth_consumer_key="fZeNGv5iYayvItgDYHUbot1Ukb5rVyX6QAg8GaY2",oauth_token="l0lPbtP68ao8NfStCiA3V3neqfM03JKhToxhUQTR",oauth_signature_method="HMAC-SHA1", oauth_signature="o4hx4hWP6KtLyFwggnYB4yPK8xI%3D",oauth_timestamp="1313581372",oauth_nonce="W0zUmvyC4eVL8cBd4YwlH1nnPTbxW0QBYcWkXTwe4",oauth_version="1.0"';
|
|
||||||
//
|
|
||||||
//tests['test can access oauth hash for a user based on access token (oauth_token)'] = function(){
|
//tests['test can access oauth hash for a user based on access token (oauth_token)'] = function(){
|
||||||
// var req = {query:{}, headers:{authorization:real_oauth_header}};
|
// var req = {query:{}, headers:{authorization:real_oauth_header}};
|
||||||
// var tokens = oAuth.parseTokens(req);
|
// var tokens = oAuth.parseTokens(req);
|
||||||
@ -68,16 +60,17 @@ tests['test headers take presedence over query parameters'] = function(){
|
|||||||
// assert.equal(tokens.oauth_consumer_key, data.consumer_key)
|
// assert.equal(tokens.oauth_consumer_key, data.consumer_key)
|
||||||
// });
|
// });
|
||||||
//};
|
//};
|
||||||
//
|
|
||||||
//tests['test non existant oauth hash for a user based on oauth_token returns empty hash'] = function(){
|
tests['test non existant oauth hash for a user based on oauth_token returns empty hash'] = function(){
|
||||||
// var req = {query:{}, headers:{authorization:full_oauth_header}};
|
var req = {query:{}, headers:{authorization:full_oauth_header}};
|
||||||
// var tokens = oAuth.parseTokens(req);
|
var tokens = oAuth.parseTokens(req);
|
||||||
//
|
|
||||||
// oAuth.getOAuthHash(tokens.oauth_token, function(err, data){
|
oAuth.getOAuthHash(tokens.oauth_token, function(err, data){
|
||||||
// assert.eql(data, {})
|
assert.eql(data, {})
|
||||||
// });
|
});
|
||||||
//};
|
};
|
||||||
//
|
|
||||||
|
//TODO FIX
|
||||||
//tests['can return user for verified signature'] = function(){
|
//tests['can return user for verified signature'] = function(){
|
||||||
// var req = {query:{},
|
// var req = {query:{},
|
||||||
// headers:{authorization:real_oauth_header, host: 'vizzuality.testhost.lan' },
|
// headers:{authorization:real_oauth_header, host: 'vizzuality.testhost.lan' },
|
||||||
@ -86,32 +79,33 @@ tests['test headers take presedence over query parameters'] = function(){
|
|||||||
// };
|
// };
|
||||||
//
|
//
|
||||||
// oAuth.verifyRequest(req, function(err, data){
|
// oAuth.verifyRequest(req, function(err, data){
|
||||||
|
//
|
||||||
// assert.eql(data, 1);
|
// assert.eql(data, 1);
|
||||||
// }, true)
|
// }, true)
|
||||||
//};
|
//};
|
||||||
//
|
|
||||||
//tests['returns null user for unverified signatures'] = function(){
|
tests['returns null user for unverified signatures'] = function(){
|
||||||
// var req = {query:{},
|
var req = {query:{},
|
||||||
// headers:{authorization:real_oauth_header, host: 'vizzuality.testyhost.lan' },
|
headers:{authorization:real_oauth_header, host: 'vizzuality.testyhost.lan' },
|
||||||
// method: 'GET',
|
method: 'GET',
|
||||||
// route: {path: '/api/v1/tables'}
|
route: {path: '/api/v1/tables'}
|
||||||
// };
|
};
|
||||||
//
|
|
||||||
// oAuth.verifyRequest(req, function(err, data){
|
oAuth.verifyRequest(req, function(err, data){
|
||||||
// assert.eql(data, null);
|
assert.eql(data, null);
|
||||||
// }, true)
|
}, true)
|
||||||
//};
|
};
|
||||||
//
|
|
||||||
//tests['returns null user for no oauth'] = function(){
|
tests['returns null user for no oauth'] = function(){
|
||||||
// var req = {
|
var req = {
|
||||||
// query:{},
|
query:{},
|
||||||
// headers:{},
|
headers:{},
|
||||||
// method: 'GET',
|
method: 'GET',
|
||||||
// route: {path: '/api/v1/tables'}
|
route: {path: '/api/v1/tables'}
|
||||||
// };
|
};
|
||||||
//
|
|
||||||
// oAuth.verifyRequest(req,function(err,data){
|
oAuth.verifyRequest(req,function(err,data){
|
||||||
// assert.eql(data, null);
|
assert.eql(data, null);
|
||||||
// });
|
});
|
||||||
//};
|
};
|
||||||
//
|
|
||||||
|
Loading…
Reference in New Issue
Block a user