@@ -63,27 +63,24 @@ describe("generateToken test", function() {
63
63
} ) . catch ( err => done ( err ) ) ;
64
64
} ) ;
65
65
66
- it ( "Should be able to create new local token" , function ( done ) {
66
+ it ( "Should be able to create new local token" , ( ) =>
67
67
createAndSaveToken ( TokenType . local ) . then ( ( licenseKey ) => {
68
68
assert . ok ( validateLicenseKeyRegex ( licenseKey [ 0 ] ) ) ;
69
69
localLicense = licenseKey [ 0 ] ;
70
- done ( ) ;
71
- } ) . catch ( err => done ( err ) ) ;
72
- } ) ;
70
+ } )
71
+ ) ;
73
72
74
- it ( "Should return 400 if missing code parameter" , function ( done ) {
73
+ it ( "Should return 400 if missing code parameter" , ( ) =>
75
74
getGenerateToken ( "patreon" , null , "" ) . then ( res => {
76
75
assert . strictEqual ( res . status , 400 ) ;
77
- done ( ) ;
78
- } ) . catch ( err => done ( err ) ) ;
79
- } ) ;
76
+ } )
77
+ ) ;
80
78
81
- it ( "Should return 403 if missing adminuserID parameter" , function ( done ) {
79
+ it ( "Should return 403 if missing adminuserID parameter" , ( ) =>
82
80
getGenerateToken ( "local" , "fake-code" , null ) . then ( res => {
83
81
assert . strictEqual ( res . status , 403 ) ;
84
- done ( ) ;
85
- } ) . catch ( err => done ( err ) ) ;
86
- } ) ;
82
+ } )
83
+ ) ;
87
84
88
85
it ( "Should return 403 for invalid adminuserID parameter" , function ( done ) {
89
86
getGenerateToken ( "local" , "fake-code" , "fakeAdminID" ) . then ( res => {
@@ -94,20 +91,18 @@ describe("generateToken test", function() {
94
91
} ) ;
95
92
96
93
describe ( "verifyToken static tests" , function ( ) {
97
- it ( "Should fast reject invalid token" , function ( done ) {
94
+ it ( "Should fast reject invalid token" , ( ) =>
98
95
getVerifyToken ( "00000" ) . then ( res => {
99
96
assert . strictEqual ( res . status , 200 ) ;
100
97
assert . ok ( ! res . data . allowed ) ;
101
- done ( ) ;
102
- } ) . catch ( err => done ( err ) ) ;
103
- } ) ;
104
-
105
- it ( "Should return 400 if missing code token" , function ( done ) {
106
- getVerifyToken ( null ) . then ( res => {
107
- assert . strictEqual ( res . status , 400 ) ;
108
- done ( ) ;
109
- } ) . catch ( err => done ( err ) ) ;
110
- } ) ;
98
+ } )
99
+ ) ;
100
+
101
+ it ( "Should return 400 if missing code token" , ( ) =>
102
+ getVerifyToken ( null ) . then ( res =>
103
+ assert . strictEqual ( res . status , 400 )
104
+ )
105
+ ) ;
111
106
} ) ;
112
107
113
108
describe ( "verifyToken mock tests" , function ( ) {
@@ -121,69 +116,62 @@ describe("verifyToken mock tests", function() {
121
116
mock . restore ( ) ;
122
117
} ) ;
123
118
124
- it ( "Should accept current patron" , function ( done ) {
119
+ it ( "Should accept current patron" , function ( ) {
125
120
if ( ! config ?. patreon ) this . skip ( ) ;
126
121
mock . onGet ( / i d e n t i t y / ) . reply ( 200 , patreon . activeIdentity ) ;
127
- getVerifyToken ( patreonLicense ) . then ( res => {
122
+ return getVerifyToken ( patreonLicense ) . then ( res => {
128
123
assert . strictEqual ( res . status , 200 ) ;
129
124
assert . ok ( res . data . allowed ) ;
130
- done ( ) ;
131
- } ) . catch ( err => done ( err ) ) ;
125
+ } ) ;
132
126
} ) ;
133
127
134
- it ( "Should reject nonexistent patron" , function ( done ) {
128
+ it ( "Should reject nonexistent patron" , function ( ) {
135
129
if ( ! config ?. patreon ) this . skip ( ) ;
136
130
mock . onGet ( / i d e n t i t y / ) . reply ( 200 , patreon . invalidIdentity ) ;
137
- getVerifyToken ( patreonLicense ) . then ( res => {
131
+ return getVerifyToken ( patreonLicense ) . then ( res => {
138
132
assert . strictEqual ( res . status , 200 ) ;
139
133
assert . ok ( ! res . data . allowed ) ;
140
- done ( ) ;
141
- } ) . catch ( err => done ( err ) ) ;
134
+ } ) ;
142
135
} ) ;
143
136
144
- it ( "Should accept qualitying former patron" , function ( done ) {
137
+ it ( "Should accept qualitying former patron" , function ( ) {
145
138
if ( ! config ?. patreon ) this . skip ( ) ;
146
139
mock . onGet ( / i d e n t i t y / ) . reply ( 200 , patreon . formerIdentitySucceed ) ;
147
- getVerifyToken ( patreonLicense ) . then ( res => {
140
+ return getVerifyToken ( patreonLicense ) . then ( res => {
148
141
assert . strictEqual ( res . status , 200 ) ;
149
142
assert . ok ( res . data . allowed ) ;
150
- done ( ) ;
151
- } ) . catch ( err => done ( err ) ) ;
143
+ } ) ;
152
144
} ) ;
153
145
154
- it ( "Should reject unqualitifed former patron" , function ( done ) {
146
+ it ( "Should reject unqualitifed former patron" , function ( ) {
155
147
if ( ! config ?. patreon ) this . skip ( ) ;
156
148
mock . onGet ( / i d e n t i t y / ) . reply ( 200 , patreon . formerIdentityFail ) ;
157
- getVerifyToken ( patreonLicense ) . then ( res => {
149
+ return getVerifyToken ( patreonLicense ) . then ( res => {
158
150
assert . strictEqual ( res . status , 200 ) ;
159
151
assert . ok ( ! res . data . allowed ) ;
160
- done ( ) ;
161
- } ) . catch ( err => done ( err ) ) ;
152
+ } ) ;
162
153
} ) ;
163
154
164
- it ( "Should accept real gumroad key" , function ( done ) {
155
+ it ( "Should accept real gumroad key" , ( ) => {
165
156
mock . onPost ( "https://api.gumroad.com/v2/licenses/verify" ) . reply ( 200 , gumroad . licenseSuccess ) ;
166
- getVerifyToken ( gumroadLicense ) . then ( res => {
157
+ return getVerifyToken ( gumroadLicense ) . then ( res => {
167
158
assert . strictEqual ( res . status , 200 ) ;
168
159
assert . ok ( res . data . allowed ) ;
169
- done ( ) ;
170
- } ) . catch ( err => done ( err ) ) ;
160
+ } ) ;
171
161
} ) ;
172
162
173
- it ( "Should reject fake gumroad key" , function ( done ) {
163
+ it ( "Should reject fake gumroad key" , ( ) => {
174
164
mock . onPost ( "https://api.gumroad.com/v2/licenses/verify" ) . reply ( 200 , gumroad . licenseFail ) ;
175
- getVerifyToken ( gumroadLicense ) . then ( res => {
165
+ return getVerifyToken ( gumroadLicense ) . then ( res => {
176
166
assert . strictEqual ( res . status , 200 ) ;
177
167
assert . ok ( ! res . data . allowed ) ;
178
- done ( ) ;
179
- } ) . catch ( err => done ( err ) ) ;
168
+ } ) ;
180
169
} ) ;
181
170
182
- it ( "Should validate local license" , function ( done ) {
171
+ it ( "Should validate local license" , ( ) =>
183
172
getVerifyToken ( localLicense ) . then ( res => {
184
173
assert . strictEqual ( res . status , 200 ) ;
185
174
assert . ok ( res . data . allowed ) ;
186
- done ( ) ;
187
- } ) . catch ( err => done ( err ) ) ;
188
- } ) ;
175
+ } )
176
+ ) ;
189
177
} ) ;
0 commit comments