Move token as an auth submodule

This commit is contained in:
Juan Cruz Viotti 2014-12-22 14:43:38 -04:00
parent 46ebb7b1fd
commit be08a83765
6 changed files with 16 additions and 13 deletions

View File

@ -1,7 +1,7 @@
async = require('async')
_ = require('lodash-contrib')
token = require('../token/token')
token = require('./token/token')
server = require('../server/server')
data = require('../data/data')
errors = require('../errors/errors')

View File

@ -1,4 +1,4 @@
data = require('../data/data')
data = require('../../data/data')
# @nodoc
# TODO: Move to settings

View File

@ -1,12 +1,12 @@
expect = require('chai').expect
async = require('async')
token = require('./token')
settings = require('../settings')
data = require('../data/data')
mock = require('../../../tests/utils/mock')
settings = require('../../settings')
data = require('../../data/data')
mock = require('../../../../tests/utils/mock')
johnDoeFixture = require('../../../tests/fixtures/johndoe.json')
janeDoeFixture = require('../../../tests/fixtures/janedoe.json')
johnDoeFixture = require('../../../../tests/fixtures/johndoe.json')
janeDoeFixture = require('../../../../tests/fixtures/janedoe.json')
describe 'Token:', ->

View File

@ -2,7 +2,6 @@ module.exports =
server: require('./server/server')
models: require('./models')
errors: require('./errors/errors')
token: require('./token/token')
data: require('./data/data')
auth: require('./auth/auth')
device: require('./device/device')

View File

@ -4,7 +4,7 @@ progress = require('request-progress')
async = require('async')
connection = require('../../connection/connection')
settings = require('../settings')
token = require('../token/token')
auth = require('../auth/auth')
# @nodoc
urlResolve = require('url').resolve
@ -72,7 +72,7 @@ exports.request = (options = {}, outerCallback, onProgress) ->
if not isOnline
return callback(new Error('You need internet connection to perform this task'))
token.getToken(callback)
auth.getToken(callback)
(savedToken, callback) ->
options.url = urlResolve(settings.get('remoteUrl'), options.url)

View File

@ -5,7 +5,7 @@ url = require('url')
sinon = require('sinon')
server = require('./server')
settings = require('../settings')
token = require('../token/token')
auth = require('../auth/auth')
data = require('../data/data')
mock = require('../../../tests/utils/mock')
johnDoeFixture = require('../../../tests/fixtures/johndoe.json')
@ -200,7 +200,11 @@ describe 'Server:', ->
describe 'given there is a token', ->
beforeEach (done) ->
token.saveToken(johnDoeFixture.token, done)
nock(settings.get('remoteUrl'))
.post('/login_', johnDoeFixture.credentials)
.reply(200, johnDoeFixture.token)
auth.login(johnDoeFixture.credentials, done)
describe '#request()', ->
@ -220,7 +224,7 @@ describe 'Server:', ->
describe 'given there is not a token', ->
beforeEach (done) ->
token.clearToken(done)
auth.logout(done)
describe '#request()', ->