@@ -34,8 +34,7 @@ describe('Auth token refresh', function() {
34
34
35
35
AuthTokenRefresh . use ( 'explicit_name' , strategy ) ;
36
36
37
- expect ( AuthTokenRefresh . _strategies . explicit_name ) . to . be . defined ;
38
- expect ( AuthTokenRefresh . _strategies . internal_name ) . to . be . undefined ;
37
+ expect ( AuthTokenRefresh . _strategies . explicit_name . strategy ) . to . equal ( strategy ) ; expect ( AuthTokenRefresh . _strategies . strategy ) . to . be . undefined ;
39
38
} ) ;
40
39
41
40
it ( 'should add a strategy without an explicitly defined name' , function ( ) {
@@ -46,7 +45,7 @@ describe('Auth token refresh', function() {
46
45
47
46
AuthTokenRefresh . use ( strategy ) ;
48
47
49
- expect ( AuthTokenRefresh . _strategies . internal_name ) . to . be . defined ;
48
+ expect ( AuthTokenRefresh . _strategies . internal_name . strategy ) . to . equal ( strategy ) ;
50
49
} ) ;
51
50
52
51
it ( 'should add a strategy with a refreshURL' , function ( ) {
@@ -57,6 +56,7 @@ describe('Auth token refresh', function() {
57
56
} ;
58
57
59
58
AuthTokenRefresh . use ( strategy ) ;
59
+ expect ( AuthTokenRefresh . _strategies . test_strategy . strategy ) . to . equal ( strategy ) ;
60
60
expect ( AuthTokenRefresh . _strategies . test_strategy . refreshOAuth2 . _accessTokenUrl ) . to . equal ( 'refreshURL' ) ;
61
61
} ) ;
62
62
@@ -67,6 +67,7 @@ describe('Auth token refresh', function() {
67
67
} ;
68
68
69
69
AuthTokenRefresh . use ( strategy ) ;
70
+ expect ( AuthTokenRefresh . _strategies . test_strategy . strategy ) . to . equal ( strategy ) ;
70
71
expect ( AuthTokenRefresh . _strategies . test_strategy . refreshOAuth2 . _accessTokenUrl ) . to . equal ( 'accessTokenUrl' ) ;
71
72
} ) ;
72
73
@@ -80,41 +81,7 @@ describe('Auth token refresh', function() {
80
81
AuthTokenRefresh . use ( strategy ) ;
81
82
expect ( AuthTokenRefresh . _strategies . test_strategy . refreshOAuth2 ) . to . not . equal ( strategyOAuth2 ) ;
82
83
expect ( AuthTokenRefresh . _strategies . test_strategy . refreshOAuth2 ) . to . be . instanceof ( OAuth2 ) ;
83
- } ) ;
84
-
85
- it ( 'should add a strategy with an explicit name and params' , function ( ) {
86
- var strategyOAuth2 = newOAuth2 ( ) ;
87
- var strategy = {
88
- name : 'test_strategy' ,
89
- _oauth2 : strategyOAuth2
90
- } ;
91
- var params = {
92
- some : 'extra_param'
93
- } ;
94
84
95
- AuthTokenRefresh . use ( 'explicit_strategy' , strategy , params ) ;
96
- expect ( AuthTokenRefresh . _strategies . explicit_strategy . params ) . to . eql ( {
97
- some : 'extra_param' ,
98
- grant_type : 'refresh_token'
99
- } ) ;
100
- expect ( AuthTokenRefresh . _strategies . test_strategy ) . to . be . undefined ;
101
- } ) ;
102
-
103
- it ( 'should add a strategy with explicit params' , function ( ) {
104
- var strategyOAuth2 = newOAuth2 ( ) ;
105
- var strategy = {
106
- name : 'test_strategy' ,
107
- _oauth2 : strategyOAuth2
108
- } ;
109
- var params = {
110
- some : 'extra_param'
111
- } ;
112
-
113
- AuthTokenRefresh . use ( strategy , params ) ;
114
- expect ( AuthTokenRefresh . _strategies . test_strategy . params ) . to . eql ( {
115
- some : 'extra_param' ,
116
- grant_type : 'refresh_token'
117
- } ) ;
118
85
} ) ;
119
86
120
87
it ( 'should not add a null strategy' , function ( ) {
@@ -176,9 +143,6 @@ describe('Auth token refresh', function() {
176
143
177
144
AuthTokenRefresh . _strategies = {
178
145
test_strategy : {
179
- params : {
180
- grant_type : 'refresh_token'
181
- } ,
182
146
refreshOAuth2 : {
183
147
getOAuthAccessToken : getOAuthAccessTokenSpy
184
148
}
@@ -190,6 +154,23 @@ describe('Auth token refresh', function() {
190
154
expect ( getOAuthAccessTokenSpy ) . to . have . been . calledWith ( 'refresh_token' , { grant_type : 'refresh_token' } , done ) ;
191
155
} ) ;
192
156
157
+ it ( 'should refresh a new access token with extra params' , function ( ) {
158
+ var getOAuthAccessTokenSpy = sinon . spy ( ) ;
159
+ var done = sinon . spy ( ) ;
160
+
161
+ AuthTokenRefresh . _strategies = {
162
+ test_strategy : {
163
+ refreshOAuth2 : {
164
+ getOAuthAccessToken : getOAuthAccessTokenSpy
165
+ }
166
+ }
167
+ } ;
168
+
169
+ AuthTokenRefresh . requestNewAccessToken ( 'test_strategy' , 'refresh_token' , { some : 'extra_param' } , done ) ;
170
+
171
+ expect ( getOAuthAccessTokenSpy ) . to . have . been . calledWith ( 'refresh_token' , { grant_type : 'refresh_token' , some : 'extra_param' } , done ) ;
172
+ } ) ;
173
+
193
174
it ( 'should not refresh if the strategy was not previously registered' , function ( ) {
194
175
var done = sinon . spy ( ) ;
195
176
var expectedErr = new Error ( 'Strategy was not registered to refresh a token' ) ;
0 commit comments