@@ -139,7 +139,7 @@ describe('OAuthProvider', function() {
139139
140140 describe ( 'isAuthenticated()' , function ( ) {
141141 it ( 'should be true when there is a stored `token` cookie' , inject ( function ( OAuth , OAuthToken ) {
142- OAuthToken . token = { token_type : 'bearer' , access_token : 'foo' , expires_in : 3600 , refresh_token : 'bar' } ;
142+ OAuthToken . setToken ( { token_type : 'bearer' , access_token : 'foo' , expires_in : 3600 , refresh_token : 'bar' } ) ;
143143
144144 OAuth . isAuthenticated ( ) . should . be . true ;
145145 } ) ) ;
@@ -254,7 +254,7 @@ describe('OAuthProvider', function() {
254254 username : 'foo' ,
255255 password : 'bar'
256256 } ) . then ( function ( response ) {
257- OAuthToken . token . should . eql ( response . data ) ;
257+ OAuthToken . getToken ( ) . should . eql ( response . data ) ;
258258 } ) . catch ( function ( ) {
259259 should . fail ( ) ;
260260 } ) ;
@@ -277,7 +277,7 @@ describe('OAuthProvider', function() {
277277 it ( 'should call `queryString.stringify`' , inject ( function ( OAuth , OAuthToken ) {
278278 sinon . spy ( queryString , 'stringify' ) ;
279279
280- OAuthToken . token = { token_type : 'bearer' , access_token : 'foo' , expires_in : 3600 , refresh_token : 'bar' } ;
280+ OAuthToken . setToken ( { token_type : 'bearer' , access_token : 'foo' , expires_in : 3600 , refresh_token : 'bar' } ) ;
281281
282282 OAuth . getRefreshToken ( ) ;
283283
@@ -310,7 +310,7 @@ describe('OAuthProvider', function() {
310310 } ) ) ;
311311
312312 it ( 'should return an error if `refresh_token` is invalid' , inject ( function ( $httpBackend , OAuth , OAuthToken ) {
313- OAuthToken . token = { token_type : 'bearer' , access_token : 'foo' , expires_in : 3600 , refresh_token : 'bar' } ;
313+ OAuthToken . setToken ( { token_type : 'bearer' , access_token : 'foo' , expires_in : 3600 , refresh_token : 'bar' } ) ;
314314
315315 $httpBackend . expectPOST ( defaults . baseUrl + defaults . grantPath , queryString . stringify ( data ) )
316316 . respond ( 400 , { error : 'invalid_grant' } ) ;
@@ -329,7 +329,7 @@ describe('OAuthProvider', function() {
329329 } ) ) ;
330330
331331 it ( 'should retrieve and store `refresh_token` if request is successful' , inject ( function ( $httpBackend , OAuth , OAuthToken ) {
332- OAuthToken . token = { token_type : 'bearer' , access_token : 'foo' , expires_in : 3600 , refresh_token : 'bar' } ;
332+ OAuthToken . setToken ( { token_type : 'bearer' , access_token : 'foo' , expires_in : 3600 , refresh_token : 'bar' } ) ;
333333
334334 $httpBackend . expectPOST ( defaults . baseUrl + defaults . grantPath , queryString . stringify ( data ) )
335335 . respond ( { token_type : 'bearer' , access_token : 'qux' , expires_in : 3600 , refresh_token : 'biz' } ) ;
@@ -356,7 +356,7 @@ describe('OAuthProvider', function() {
356356 it ( 'should call `queryString.stringify`' , inject ( function ( OAuth , OAuthToken ) {
357357 sinon . spy ( queryString , 'stringify' ) ;
358358
359- OAuthToken . token = { token_type : 'bearer' , access_token : 'foo' , expires_in : 3600 , refresh_token : 'bar' } ;
359+ OAuthToken . setToken ( { token_type : 'bearer' , access_token : 'foo' , expires_in : 3600 , refresh_token : 'bar' } ) ;
360360
361361 OAuth . revokeToken ( ) ;
362362
@@ -371,7 +371,7 @@ describe('OAuthProvider', function() {
371371 it ( 'should call `queryString.stringify` with `access_token` if `refresh_token` is not available' , inject ( function ( OAuth , OAuthToken ) {
372372 sinon . spy ( queryString , 'stringify' ) ;
373373
374- OAuthToken . token = { token_type : 'bearer' , access_token : 'foo' , expires_in : 3600 } ;
374+ OAuthToken . setToken ( { token_type : 'bearer' , access_token : 'foo' , expires_in : 3600 } ) ;
375375
376376 OAuth . revokeToken ( ) ;
377377
@@ -404,7 +404,7 @@ describe('OAuthProvider', function() {
404404 } ) ) ;
405405
406406 it ( 'should revoke and remove `token` if request is successful' , inject ( function ( $httpBackend , OAuth , OAuthToken ) {
407- OAuthToken . token = { token_type : 'bearer' , access_token : 'foo' , expires_in : 3600 , refresh_token : 'bar' } ;
407+ OAuthToken . setToken ( { token_type : 'bearer' , access_token : 'foo' , expires_in : 3600 , refresh_token : 'bar' } ) ;
408408
409409 var data = queryString . stringify ( {
410410 token : 'bar'
@@ -414,7 +414,7 @@ describe('OAuthProvider', function() {
414414 . respond ( 200 ) ;
415415
416416 OAuth . revokeToken ( ) . then ( function ( ) {
417- ( undefined === OAuthToken . token ) . should . be . true ;
417+ ( undefined === OAuthToken . getToken ( ) ) . should . be . true ;
418418 } ) . catch ( function ( ) {
419419 should . fail ( ) ;
420420 } ) ;
0 commit comments