@@ -7,26 +7,26 @@ const nock = require('nock')
77
88const utils = require ( '../lib/utils' )
99
10- describe ( 'utils' , function ( ) {
11- describe ( 'call' , function ( ) {
10+ describe ( 'utils' , ( ) => {
11+ describe ( 'call' , ( ) => {
1212 const google = 'https://google.com'
1313 const uscope = nock ( google )
1414
15- it ( 'should work when given valid data' , function ( done ) {
15+ it ( 'should work when given valid data' , done => {
1616 const bsdata = {
1717 cake : true ,
1818 username : 'someone'
1919 }
2020
2121 uscope . post ( '/test' , { } ) . reply ( 200 , bsdata )
22- utils . call ( google , 'test' , { } , undefined , function ( err , data ) {
22+ utils . call ( google , 'test' , { } , undefined , ( err , data ) => {
2323 assert . ifError ( err )
2424 assert . deepStrictEqual ( data , bsdata )
2525 done ( )
2626 } )
2727 } )
2828
29- it ( 'should work when given valid data (promise)' , async function ( ) {
29+ it ( 'should work when given valid data (promise)' , async ( ) => {
3030 const bsdata = {
3131 cake : true ,
3232 username : 'someone'
@@ -37,19 +37,19 @@ describe('utils', function () {
3737 assert . deepStrictEqual ( data , bsdata )
3838 } )
3939
40- it ( 'should error on an error' , function ( done ) {
40+ it ( 'should error on an error' , done => {
4141 uscope . post ( '/test2' , { } ) . reply ( 200 , {
4242 error : 'ThisBeAError' ,
4343 errorMessage : 'Yep, you failed.'
4444 } )
45- utils . call ( google , 'test2' , { } , undefined , function ( err , data ) {
45+ utils . call ( google , 'test2' , { } , undefined , ( err , data ) => {
4646 assert . strictEqual ( data , undefined )
4747 assert . ok ( err instanceof Error )
4848 assert . strictEqual ( err . message , 'Yep, you failed.' )
4949 done ( )
5050 } )
5151 } )
52- it ( 'should error on an error (promise)' , async function ( ) {
52+ it ( 'should error on an error (promise)' , async ( ) => {
5353 uscope . post ( '/test2' , { } ) . reply ( 200 , {
5454 error : 'ThisBeAError' ,
5555 errorMessage : 'Yep, you failed.'
@@ -62,14 +62,14 @@ describe('utils', function () {
6262 }
6363 } )
6464
65- afterEach ( function ( ) {
65+ afterEach ( ( ) => {
6666 uscope . done ( )
6767 } )
6868 } )
6969
7070 // mcHexDigest(sha1('catcatcat')) => -af59e5b1d5d92e5c2c2776ed0e65e90be181f2a
71- describe ( 'mcHexDigest' , function ( ) {
72- it ( 'should work against test data' , function ( ) {
71+ describe ( 'mcHexDigest' , ( ) => {
72+ it ( 'should work against test data' , ( ) => {
7373 // circa http://wiki.vg/Protocol_Encryption#Client
7474 const testdata = {
7575 Notch : '4ed1f46bbe04bc756bcb17c0c7ce3e4632f06a48' ,
@@ -78,13 +78,13 @@ describe('utils', function () {
7878 dummy697 : '-aa2358520428804697026992cf6035d7f096a00' // triggers 2's complement bug
7979 }
8080
81- Object . keys ( testdata ) . forEach ( function ( name ) {
81+ Object . keys ( testdata ) . forEach ( name => {
8282 const hash = crypto . createHash ( 'sha1' ) . update ( name ) . digest ( )
8383 assert . strictEqual ( utils . mcHexDigest ( hash ) , testdata [ name ] )
8484 } )
8585 } )
8686
87- it ( 'should handle negative hashes ending with a zero byte without crashing' , function ( ) {
87+ it ( 'should handle negative hashes ending with a zero byte without crashing' , ( ) => {
8888 assert . strictEqual ( utils . mcHexDigest ( Buffer . from ( [ - 1 , 0 ] ) ) , '-100' )
8989 } )
9090 } )
@@ -93,9 +93,9 @@ describe('utils', function () {
9393const cscope = nock ( 'https://authserver.mojang.com' )
9494const ygg = require ( '../lib/index' ) ( { } )
9595
96- describe ( 'Yggdrasil' , function ( ) {
97- describe ( 'auth' , function ( ) {
98- it ( 'should work correctly' , function ( done ) {
96+ describe ( 'Yggdrasil' , ( ) => {
97+ describe ( 'auth' , ( ) => {
98+ it ( 'should work correctly' , done => {
9999 cscope . post ( '/authenticate' , {
100100 agent : {
101101 version : 1 ,
@@ -112,7 +112,7 @@ describe('Yggdrasil', function () {
112112 user : 'cake' ,
113113 pass : 'hunter2' ,
114114 token : 'bacon'
115- } , function ( err , data ) { // eslint-disable-line handle-callback-err
115+ } , ( err , data ) => { // eslint-disable-line handle-callback-err
116116 if ( err ) {
117117 done ( err )
118118 return
@@ -123,7 +123,7 @@ describe('Yggdrasil', function () {
123123 done ( )
124124 } )
125125 } )
126- it ( 'should work correctly (promise)' , async function ( ) {
126+ it ( 'should work correctly (promise)' , async ( ) => {
127127 cscope . post ( '/authenticate' , {
128128 agent : {
129129 version : 1 ,
@@ -139,7 +139,7 @@ describe('Yggdrasil', function () {
139139 const data = await ygg . auth ( { user : 'cake' , pass : 'hunter2' , token : 'bacon' } )
140140 assert . deepStrictEqual ( data , { worked : true } )
141141 } )
142- it ( 'should work correctly with requestUser true' , function ( done ) {
142+ it ( 'should work correctly with requestUser true' , done => {
143143 cscope . post ( '/authenticate' , {
144144 agent : {
145145 version : 1 ,
@@ -157,7 +157,7 @@ describe('Yggdrasil', function () {
157157 pass : 'hunter2' ,
158158 token : 'bacon' ,
159159 requestUser : true
160- } , function ( err , data ) { // eslint-disable-line handle-callback-err
160+ } , ( err , data ) => { // eslint-disable-line handle-callback-err
161161 if ( err ) {
162162 done ( err )
163163 return
@@ -168,7 +168,7 @@ describe('Yggdrasil', function () {
168168 done ( )
169169 } )
170170 } )
171- it ( 'should work correctly with requestUser true (promise)' , async function ( ) {
171+ it ( 'should work correctly with requestUser true (promise)' , async ( ) => {
172172 cscope . post ( '/authenticate' , {
173173 agent : {
174174 version : 1 ,
@@ -185,8 +185,8 @@ describe('Yggdrasil', function () {
185185 assert . deepStrictEqual ( data , { worked : true } )
186186 } )
187187 } )
188- describe ( 'refresh' , function ( ) {
189- it ( 'should work correctly' , function ( done ) {
188+ describe ( 'refresh' , ( ) => {
189+ it ( 'should work correctly' , done => {
190190 cscope . post ( '/refresh' , {
191191 accessToken : 'bacon' ,
192192 clientToken : 'not bacon' ,
@@ -195,13 +195,13 @@ describe('Yggdrasil', function () {
195195 accessToken : 'different bacon' ,
196196 clientToken : 'not bacon'
197197 } )
198- ygg . refresh ( 'bacon' , 'not bacon' , function ( err , token ) {
198+ ygg . refresh ( 'bacon' , 'not bacon' , ( err , token ) => {
199199 assert . ifError ( err )
200200 assert . strictEqual ( token , 'different bacon' )
201201 done ( )
202202 } )
203203 } )
204- it ( 'should work correctly (promise)' , async function ( ) {
204+ it ( 'should work correctly (promise)' , async ( ) => {
205205 cscope . post ( '/refresh' , {
206206 accessToken : 'bacon' ,
207207 clientToken : 'not bacon' ,
@@ -213,7 +213,7 @@ describe('Yggdrasil', function () {
213213 const { accessToken } = await ygg . refresh ( 'bacon' , 'not bacon' )
214214 assert . strictEqual ( accessToken , 'different bacon' )
215215 } )
216- it ( 'should work correctly with requestUser true' , function ( done ) {
216+ it ( 'should work correctly with requestUser true' , done => {
217217 cscope . post ( '/refresh' , {
218218 accessToken : 'bacon' ,
219219 clientToken : 'not bacon' ,
@@ -226,7 +226,7 @@ describe('Yggdrasil', function () {
226226 properties : [ ]
227227 }
228228 } )
229- ygg . refresh ( 'bacon' , 'not bacon' , true , function ( err , token , data ) {
229+ ygg . refresh ( 'bacon' , 'not bacon' , true , ( err , token , data ) => {
230230 assert . ifError ( err )
231231 assert . strictEqual ( token , 'different bacon' )
232232 assert . ok ( data . user )
@@ -235,7 +235,7 @@ describe('Yggdrasil', function () {
235235 done ( )
236236 } )
237237 } )
238- it ( 'should work correctly with requestUser true (promise)' , async function ( ) {
238+ it ( 'should work correctly with requestUser true (promise)' , async ( ) => {
239239 cscope . post ( '/refresh' , {
240240 accessToken : 'bacon' ,
241241 clientToken : 'not bacon' ,
@@ -254,7 +254,7 @@ describe('Yggdrasil', function () {
254254 assert . ok ( data . user . properties )
255255 assert . strictEqual ( data . user . id , '4ed1f46bbe04bc756bcb17c0c7ce3e4632f06a48' )
256256 } )
257- it ( 'should error on invalid clientToken' , function ( done ) {
257+ it ( 'should error on invalid clientToken' , done => {
258258 cscope . post ( '/refresh' , {
259259 accessToken : 'bacon' ,
260260 clientToken : 'not bacon' ,
@@ -263,14 +263,14 @@ describe('Yggdrasil', function () {
263263 accessToken : 'different bacon' ,
264264 clientToken : 'bacon'
265265 } )
266- ygg . refresh ( 'bacon' , 'not bacon' , function ( err , token ) {
266+ ygg . refresh ( 'bacon' , 'not bacon' , ( err , token ) => {
267267 assert . notStrictEqual ( err , null )
268268 assert . ok ( err instanceof Error )
269269 assert . strictEqual ( err . message , 'clientToken assertion failed' )
270270 done ( )
271271 } )
272272 } )
273- it ( 'should error on invalid clientToken (promise)' , async function ( ) {
273+ it ( 'should error on invalid clientToken (promise)' , async ( ) => {
274274 cscope . post ( '/refresh' , {
275275 accessToken : 'bacon' ,
276276 clientToken : 'not bacon' ,
@@ -288,36 +288,36 @@ describe('Yggdrasil', function () {
288288 }
289289 } )
290290 } )
291- describe ( 'validate' , function ( ) {
292- it ( 'should return undefined on valid response' , function ( done ) {
291+ describe ( 'validate' , ( ) => {
292+ it ( 'should return undefined on valid response' , done => {
293293 cscope . post ( '/validate' , {
294294 accessToken : 'a magical key'
295295 } ) . reply ( 200 )
296- ygg . validate ( 'a magical key' , function ( err ) {
296+ ygg . validate ( 'a magical key' , err => {
297297 assert . ifError ( err )
298298 done ( )
299299 } )
300300 } )
301- it ( 'should return undefined on valid response (promise)' , async function ( ) {
301+ it ( 'should return undefined on valid response (promise)' , async ( ) => {
302302 cscope . post ( '/validate' , {
303303 accessToken : 'a magical key'
304304 } ) . reply ( 200 )
305305 await ygg . validate ( 'a magical key' )
306306 } )
307- it ( 'should return Error on error' , function ( done ) {
307+ it ( 'should return Error on error' , done => {
308308 cscope . post ( '/validate' , {
309309 accessToken : 'a magical key'
310310 } ) . reply ( 403 , {
311311 error : 'UserEggError' ,
312312 errorMessage : 'User is an egg'
313313 } )
314- ygg . validate ( 'a magical key' , function ( err ) {
314+ ygg . validate ( 'a magical key' , err => {
315315 assert . ok ( err instanceof Error )
316316 assert . strictEqual ( err . message , 'User is an egg' )
317317 done ( )
318318 } )
319319 } )
320- it ( 'should return Error on error (promise)' , async function ( ) {
320+ it ( 'should return Error on error (promise)' , async ( ) => {
321321 cscope . post ( '/validate' , {
322322 accessToken : 'a magical key'
323323 } ) . reply ( 403 , {
@@ -332,17 +332,17 @@ describe('Yggdrasil', function () {
332332 }
333333 } )
334334 } )
335- afterEach ( function ( ) {
335+ afterEach ( ( ) => {
336336 cscope . done ( )
337337 } )
338338} )
339339
340340const sscope = nock ( 'https://sessionserver.mojang.com' )
341341const yggserver = require ( '../lib/index' ) . server ( { } )
342342
343- describe ( 'Yggdrasil.server' , function ( ) {
344- describe ( 'join' , function ( ) {
345- it ( 'should work correctly' , function ( done ) {
343+ describe ( 'Yggdrasil.server' , ( ) => {
344+ describe ( 'join' , ( ) => {
345+ it ( 'should work correctly' , done => {
346346 sscope . post ( '/session/minecraft/join' , {
347347 accessToken : 'anAccessToken' ,
348348 selectedProfile : 'aSelectedProfile' ,
@@ -351,7 +351,7 @@ describe('Yggdrasil.server', function () {
351351 worked : true
352352 } )
353353
354- yggserver . join ( 'anAccessToken' , 'aSelectedProfile' , 'cat' , 'cat' , 'cat' , function ( err , data ) { // eslint-disable-line handle-callback-err
354+ yggserver . join ( 'anAccessToken' , 'aSelectedProfile' , 'cat' , 'cat' , 'cat' , ( err , data ) => { // eslint-disable-line handle-callback-err
355355 if ( err ) {
356356 done ( err )
357357 return
@@ -362,7 +362,7 @@ describe('Yggdrasil.server', function () {
362362 done ( )
363363 } )
364364 } )
365- it ( 'should work correctly (promise)' , async function ( ) {
365+ it ( 'should work correctly (promise)' , async ( ) => {
366366 sscope . post ( '/session/minecraft/join' , {
367367 accessToken : 'anAccessToken' ,
368368 selectedProfile : 'aSelectedProfile' ,
@@ -375,14 +375,14 @@ describe('Yggdrasil.server', function () {
375375 } )
376376 } )
377377
378- describe ( 'hasJoined' , function ( ) {
379- it ( 'should work correctly' , function ( done ) {
378+ describe ( 'hasJoined' , ( ) => {
379+ it ( 'should work correctly' , done => {
380380 sscope . get ( '/session/minecraft/hasJoined?username=ausername&serverId=-af59e5b1d5d92e5c2c2776ed0e65e90be181f2a' ) . reply ( 200 , {
381381 id : 'cat' ,
382382 worked : true
383383 } )
384384
385- yggserver . hasJoined ( 'ausername' , 'cat' , 'cat' , 'cat' , function ( err , data ) {
385+ yggserver . hasJoined ( 'ausername' , 'cat' , 'cat' , 'cat' , ( err , data ) => {
386386 if ( err ) return done ( err )
387387 assert . deepStrictEqual ( data , {
388388 id : 'cat' ,
@@ -391,7 +391,7 @@ describe('Yggdrasil.server', function () {
391391 done ( )
392392 } )
393393 } )
394- it ( 'should work correctly (promise)' , async function ( ) {
394+ it ( 'should work correctly (promise)' , async ( ) => {
395395 sscope . get ( '/session/minecraft/hasJoined?username=ausername&serverId=-af59e5b1d5d92e5c2c2776ed0e65e90be181f2a' ) . reply ( 200 , {
396396 id : 'cat' ,
397397 worked : true
@@ -403,15 +403,15 @@ describe('Yggdrasil.server', function () {
403403 worked : true
404404 } )
405405 } )
406- it ( 'should fail on a 200 empty response' , function ( done ) {
406+ it ( 'should fail on a 200 empty response' , done => {
407407 sscope . get ( '/session/minecraft/hasJoined?username=ausername&serverId=-af59e5b1d5d92e5c2c2776ed0e65e90be181f2a' ) . reply ( 200 )
408408
409- yggserver . hasJoined ( 'ausername' , 'cat' , 'cat' , 'cat' , function ( err , data ) {
409+ yggserver . hasJoined ( 'ausername' , 'cat' , 'cat' , 'cat' , ( err , data ) => {
410410 assert . ok ( err instanceof Error )
411411 done ( )
412412 } )
413413 } )
414- it ( 'should fail on a 200 empty response (promise)' , async function ( ) {
414+ it ( 'should fail on a 200 empty response (promise)' , async ( ) => {
415415 sscope . get ( '/session/minecraft/hasJoined?username=ausername&serverId=-af59e5b1d5d92e5c2c2776ed0e65e90be181f2a' ) . reply ( 200 )
416416 try {
417417 await yggserver . hasJoined ( 'ausername' , 'cat' , 'cat' , 'cat' )
@@ -420,7 +420,7 @@ describe('Yggdrasil.server', function () {
420420 }
421421 } )
422422 } )
423- afterEach ( function ( ) {
423+ afterEach ( ( ) => {
424424 sscope . done ( )
425425 } )
426426} )
0 commit comments