thrustin 1.0.1

xperience epic adventures by THRUSTING some THRUSTERS into THRUSTEES https://THRUSTIN.rs. E
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
// database features

mod common;

#[test]
fn invalid_login() {
    let mut client = common::setup_with_db("invalid_login");
    client.send(1, ".l yowhat'sgood");
    client.read_all();
    assert_eq!(
        client.last(1),
        "You must provide USER and PASSWORD for your account."
    );
    client.send(1, ".l yowhat'sgood swagginout");
    client.read_all();
    assert_eq!(
        client.last(1),
        "Failed to login lol are you sure you know what you're doing?"
    );
}

#[test]
fn invalid_register() {
    let mut client = common::setup_with_db("invalid_register");
    client.send(1, ".r yowhat'sgood doggy");
    client.read_all();
    assert_eq!(
        client.last(1),
        "Ok you've got an invalid number of parameters for registration."
    );
    client.send(1, ".r yowhat'sgood swagginout swagginour");
    client.read_all();
    assert_eq!(
        client.last(1),
        "Registration failed. The given password confirmation does not match the given password."
    );
}

#[test]
fn register() {
    let mut client = common::setup_with_db("register");
    client.send(1, ".r yo what what");
    client.read_all();
    assert_eq!(client.last(1), "Lol ok nice you registered and good to go.<br/><br/>A current exploration of lobbies that are available to be joined into is as follows below. Simply `.join [ID]` to enter. Lobby 0 is an endless lobby. It's always gonna be there.<br/>ID: 0 | Password: ❌ | Players: 0/18446744073709551615 | Currently: Playing");
}

#[test]
fn existing_register() {
    let mut client = common::setup_with_db("existing_register");
    client.send(1, ".r yo what what");
    client.send(2, ".r yo what what");
    client.read_all();
    assert_eq!(
        client.last(2),
        "Registration has failed. Unable to add user to database. Maybe username isn't unique?"
    );
}

#[test]
fn register_and_login() {
    let mut client = common::setup_with_db("register_and_login");
    client.send(1, ".r yo what what");
    client.send(2, ".l yo what");
    client.read_all();
    assert_eq!(
        client.last(2),
        "Welcome back ([]>>>\"yo\"<<<[]) to THRUSTIN.<br/><br/>A current exploration of lobbies that are available to be joined into is as follows below. Simply `.join [ID]` to enter. Lobby 0 is an endless lobby. It's always gonna be there.<br/>ID: 0 | Password: ❌ | Players: 0/18446744073709551615 | Currently: Playing"
    );
}

#[test]
fn name_checks_database() {
    let mut client = common::setup_with_db("name_checks_database");
    client.send(1, ".r SWAGGINGi'mSWAGGINGOUT yo yo");
    client.send(2, ".n SWAGGINGi'mSWAGGINGOUT");
    client.read_all();
    assert_eq!(
        client.last(2),
        "yo that name exists ya gotta pick something else aight?"
    );
}

#[test]
fn thrust_database() {
    let mut client = common::setup_with_db("thrust_database");
    client.send(1, ".r 1 1 1");
    client.send(1, ".t \"Yo what's up\" \"Hey, it's _____.\"");
    client.send(2, ".l 1 1");
    client.send(2, ".t");
    client.read_all();
    assert_eq!(
        client.last(2),
        "You're THRUSTEES:<br/>1. Hey, it's _____.<br/><br/>You're THRUSTERS:<br/>1. Yo what's up",
    );
    client.send(2, ".u");
    client.send(3, ".l 1 1");
    client.send(3, ".t");
    client.read_all();
    assert_eq!(
        client.last(3),
        "You're THRUSTEES:<br/><br/>You're THRUSTERS:",
    );
}

#[test]
fn change_user_and_pass() {
    let mut client = common::setup_with_db("change_user_and_pass");
    client.send(1, ".r 1 1 1");
    client.send(2, ".l 1 1");
    client.send(2, ".un 1.5 1.5");
    client.send(2, ".pw 1.5 1.5");
    client.send(3, ".l 1.5 1");
    client.read_all();
    assert_eq!(
        client.last(3),
        "Failed to login lol are you sure you know what you're doing?"
    );
    client.send(3, ".l 1 1.5");
    client.read_all();
    assert_eq!(
        client.last(3),
        "Failed to login lol are you sure you know what you're doing?"
    );
    client.send(3, ".l 1.5 1.5");
    client.read_all();
    assert_eq!(
        client.last(3),
        "Welcome back ([]>>>\"1\"<<<[]) to THRUSTIN.<br/><br/>A current exploration of lobbies that are available to be joined into is as follows below. Simply `.join [ID]` to enter. Lobby 0 is an endless lobby. It's always gonna be there.<br/>ID: 0 | Password: ❌ | Players: 0/18446744073709551615 | Currently: Playing"
    );
}

#[test]
fn view_account() {
    let mut client = common::setup_with_db("view_account");
    client.send(1, ".n 1");
    client.send(1, ".a");
    client.read_all();
    assert_eq!(client.last(1), "You cannot do this. You must be fully authenticated and logged in in order to get your account info with a registered account.");

    client.send(2, ".r user2 2 2");
    client.send(2, ".a");
    client.read_all();
    assert_eq!(client.last(2), "A display of your account information and statistical information. Please enjoy THRUSTIN!<br/>Username - user2<br/>Name - user2<br/>Password - [ENCRYPTED_CONTENT__UNVIEWABLE]<br/>Points Earned So Far - 0<br/>Games Played So Far - 0<br/>Games Won So Far - 0<br/>Level - 1<br/>Experience - 0/1");
}

#[test]
fn update_account_stats() {
    let mut client = common::setup_with_db("update_account_stats");
    client.send(1, ".r 1 1 1");
    client.send(1, ".m");
    client.send(1, ".po 1");
    client.send(1, ".s");
    client.send(1, ".a");
    client.read_all();
    assert_eq!(client.last(1), "A display of your account information and statistical information. Please enjoy THRUSTIN!<br/>Username - 1<br/>Name - 1<br/>Password - [ENCRYPTED_CONTENT__UNVIEWABLE]<br/>Points Earned So Far - 0<br/>Games Played So Far - 1<br/>Games Won So Far - 0<br/>Level - 1<br/>Experience - 0/1");
    client.send(2, ".r 2 2 2");
    client.send(2, ".j 1");
    client.send(2, ".a");
    client.read_all();
    assert_eq!(client.last(2), "A display of your account information and statistical information. Please enjoy THRUSTIN!<br/>Username - 2<br/>Name - 2<br/>Password - [ENCRYPTED_CONTENT__UNVIEWABLE]<br/>Points Earned So Far - 0<br/>Games Played So Far - 1<br/>Games Won So Far - 0<br/>Level - 1<br/>Experience - 0/1");
    client.send(1, ".t 1");
    client.thrust(2);
    client.send(1, ".t 1");
    client.read_all();
    client.send(1, ".a");
    client.send(2, ".a");
    client.read_all();
    assert_eq!(client.last(1), "A display of your account information and statistical information. Please enjoy THRUSTIN!<br/>Username - 1<br/>Name - 1<br/>Password - [ENCRYPTED_CONTENT__UNVIEWABLE]<br/>Points Earned So Far - 0<br/>Games Played So Far - 1<br/>Games Won So Far - 0<br/>Level - 2<br/>Experience - 1/4");
    assert_eq!(client.last(2), "A display of your account information and statistical information. Please enjoy THRUSTIN!<br/>Username - 2<br/>Name - 2<br/>Password - [ENCRYPTED_CONTENT__UNVIEWABLE]<br/>Points Earned So Far - 1<br/>Games Played So Far - 1<br/>Games Won So Far - 1<br/>Level - 2<br/>Experience - 2/4");
}

#[test]
fn chieftain() {
    let mut client = common::setup_with_db_and_logging("chieftain");
    client.send(1, ".l chieftain chieftain");
    client.send(1, ".ct");
    client.read_all();
    assert_eq!(client.last(1), "A LIST OF CHIEFTAINS RESPONSIBLE FOR MANAGEMENT OF THIS THRUSTIN SERVER IS AS FOLLOWS.<br/>chieftain");

    client.send(2, ".n 2");
    client.send(2, ".ct");
    client.read_all();
    assert_eq!(
        client.last(2),
        "Yo dawg, this command can only be used by chieftains of THRUSTIN."
    );

    client.send(1, ".ct 2 2");
    client.read_all();
    assert_eq!(
        client.last(1),
        "Hey Chieftain, you should know what you're doing. Invalid indexes bro."
    );

    // Can't appoint someone who doesn't exist
    client.send(1, ".ct 3");
    client.read_all();
    assert_eq!(client.last(1), "FAILED TO APPOINT CHIEFTAIN: 3");

    // Can't appoint someone who isn't in database
    client.send(1, ".ct 2");
    client.read_all();
    assert_eq!(client.last(1), "FAILED TO APPOINT CHIEFTAIN: 2");

    client.send(3, ".r 3 3 3");
    client.send(1, ".ct 3");
    client.read_all();
    assert_eq!(client.last(1), "A NEW CHIEFTAIN HAS BEEN APPOINTED: 3");

    client.send(3, ".ct");
    client.read_all();
    assert_eq!(client.last(3), "A LIST OF CHIEFTAINS RESPONSIBLE FOR MANAGEMENT OF THIS THRUSTIN SERVER IS AS FOLLOWS.<br/>3<br/>chieftain");

    client.send(4, ".n 4");
    client.send(4, ".uc");
    client.read_all();
    assert_eq!(
        client.last(4),
        "Yo dawg, this command can only be used by chieftains of THRUSTIN."
    );

    client.send(3, ".uc");
    client.read_all();
    assert_eq!(
        client.last(3),
        "Hey Chieftain, you should know what you're doing. Invalid indexes bro."
    );

    client.send(3, ".uc blah");
    client.read_all();
    assert_eq!(
        client.last(3),
        "It looks like something went wrong with unchieftaining. Maybe blah isn't real?"
    );

    client.send(3, ".uc chieftain");
    client.read_all();
    assert_eq!(
        client.last(3),
        "Congratulations, you have unchieftained chieftain."
    );

    client.send(1, ".ct");
    client.read_all();
    assert_eq!(
        client.last(1),
        "Yo dawg, this command can only be used by chieftains of THRUSTIN."
    );
}

#[test]
fn ban_update() {
    let mut client = common::setup_with_db("ban_update");
    client.send(1, ".n a");
    client.send(1, ".b");
    client.read_all();
    assert_eq!(
        client.last(1),
        "Yo dawg, this command can only be used by chieftains of THRUSTIN."
    );

    client.send(2, ".l chieftain chieftain");
    client.send(2, ".b yep yep");
    client.read_all();
    assert_eq!(
        client.last(2),
        "Hey Chieftain, you should know what you're doing. Invalid indexes bro."
    );

    client.send(2, ".b");
    client.read_all();
    assert_eq!(client.last(2), "Banned fellows from this server. Kill'em.");

    client.send(2, ".b 123.123.123.123");
    client.read_all();
    assert_eq!(
        client.last(2),
        "IP address 123.123.123.123 has been banned."
    );

    client.send(2, ".b");
    client.read_all();
    assert!(client
        .last(2)
        .contains("Banned fellows from this server. Kill'em."));
    assert!(client.last(2).contains("123.123.123.123"));

    client.send(1, ".ub");
    client.read_all();
    assert_eq!(
        client.last(1),
        "Yo dawg, this command can only be used by chieftains of THRUSTIN."
    );

    client.send(2, ".ub");
    client.read_all();
    assert_eq!(
        client.last(2),
        "Hey Chieftain, you should know what you're doing. Invalid indexes bro."
    );

    client.send(2, ".ub 1.1.1.1");
    client.read_all();
    assert_eq!(
        client.last(2),
        "Failed to unban 1.1.1.1. Something went wrong. Unexpected error."
    );

    client.send(2, ".ub 123.123.123.123");
    client.read_all();
    assert_eq!(
        client.last(2),
        "The target 123.123.123.123 has been unbanned."
    );
}

// Not really too reliable since this is only with ChannelCommunication
// WebSocketCommunication probably has many more possible closing cases that I hope will be fine
#[test]
fn ban() {
    let mut client = common::setup_with_db("ban");
    client.send(1, ".n 1");
    client.send(1, ".m");
    client.send(1, ".s");
    client.send(2, ".l chieftain chieftain");
    client.send(2, ".b 1");
    client.send(1, "What's up my dudes?");
    client.read_all();
    assert!(client
        .last(1)
        .contains("You cannot exist. You are banned until "));
}

#[test]
fn color() {
    let mut client = common::setup_with_db("color");
    client.send(1, ".l chieftain chieftain");
    client.send(1, ".c 000");
    client.read_all();
    assert_eq!(client.last(1), "Invalid parameters to color.");

    client.send(1, ".c 000 111 222");
    client.read_all();
    assert_eq!(client.last(1), "Invalid parameters to color.");

    client.send(1, ".c 000 000");
    client.read_all();
    assert_eq!(
        client.last(1),
        "Excuse me, you can't assign your colors to the same one, that makes it too hard to see."
    );

    client.send(1, ".c 000 b7410e");
    client.read_all();
    assert_eq!(client.last(1), "Um, I'm gonna disallow you from choosing this color combination. It's mine, and I feel my identity being threatened if you choose this.");

    client.send(1, ".c 000 111");
    client.read_all();
    assert_eq!(
        client.last(1),
        "Awesome, we successfully set your chat colors to 000 (bg) and 111 (fg)."
    );

    client.send(2, ".r 2 2 2");
    client.send(2, ".c 000 111");
    client.read_all();
    assert_eq!(
        client.last(2),
        "Awesome, we successfully set your chat colors to 000 (bg) and 111 (fg)."
    );

    client.send(3, ".l 2 2");
    client.send(3, "hey what is up my studs");
    client.read_all();
    assert_eq!(
        client.last_bg(1),
        "000",
    );
    assert_eq!(
        client.last_fg(1),
        "111",
    );
}

#[test]
fn multiplayer_color() {
    let mut client = common::setup_with_db("color");
    client.send(1, ".l chieftain chieftain");
    client.send(1, ".c 000 111");
    client.send(2, ".r testerboy 69 69");
    client.send(2, ".c 111 000");
    client.send(1, "yo");
    client.read_all();
    assert_eq!(
        client.last_bg(1),
        "000"
    );
    assert_eq!(
        client.last_fg(2),
        "111"
    );

    client.send(2, "yo");
    client.read_all();
    assert_eq!(
        client.last_bg(1),
        "111"
    );
    assert_eq!(
        client.last_fg(2),
        "000"
    );
}

#[test]
fn login_after_rename() {
    let mut client = common::setup_with_db("login_after_rename");
    client.send(1, ".l chieftain chieftain");
    client.send(2, ".n 2");
    client.send(1, "hola at yo boi");
    client.read_all();
    assert_eq!(client.last_from(2), "chieftain");

    client.send(1, ".n chieftain2");
    client.send(1, "holla at yo boi");
    client.read_all();
    assert_eq!(client.last_from(2), "chieftain2");

    client.send(3, ".l chieftain chieftain");
    client.send(3, "Holler at your male.");
    client.read_all();
    assert_eq!(client.last_from(2), "chieftain2");
}

#[test]
fn unauthenticated_color() {
	let mut client = common::setup_with_db("unathenticated_color");
	client.send(1, ".n 1");
	client.send(1, ".color ffffff 000000");
	client.read_all();
	assert_eq!(client.last(1), "Bro. You need a registered account to set color. You can't just be doin that man.");	
}

#[test]
fn authenticated_color() {
	let mut client = common::setup_with_db("authenticated_color");
	client.send(1, ".l chieftain chieftain");
	client.send(1, ".color ffffff 000000");
	client.read_all();
	assert_eq!(client.last(1), "Awesome, we successfully set your chat colors to ffffff (bg) and 000000 (fg).");
}

#[test]
fn color_arguments() {
    let mut client = common::setup_with_db("color_arguments");
    client.send(1, ".l chieftain chieftain");
	client.send(1, ".c #000 #fff");
    client.read_all();
    assert_eq!(client.last(1), "Yo, I have identified error with color. You must submit a hex color argument as either 3 or 6 characters.");

    client.send(1, ".c 000 ffff");
    client.read_all();
    assert_eq!(client.last(1), "Yo, I have identified error with color. You must submit a hex color argument as either 3 or 6 characters.");

    client.send(1, ".c 000 fff");
    client.read_all();
	assert_eq!(client.last(1), "Awesome, we successfully set your chat colors to 000 (bg) and fff (fg).");
}

#[test]
fn level() {
	let mut client = common::setup_with_db("level");
	client.send(1, ".r boy 1 1");
	client.send(1, ".m");
	client.send(1, ".po 3");
	client.send(1, ".s");
	client.send(1, ".a");
	client.read_all();
	assert_eq!(client.last(1), "A display of your account information and statistical information. Please enjoy THRUSTIN!<br/>Username - boy<br/>Name - boy<br/>Password - [ENCRYPTED_CONTENT__UNVIEWABLE]<br/>Points Earned So Far - 0<br/>Games Played So Far - 1<br/>Games Won So Far - 0<br/>Level - 1<br/>Experience - 0/1");

	client.send(2, ".r boy2 2 2");
	client.send(2, ".j 1");
	client.send(2, ".a");
	client.read_all();
	assert_eq!(client.last(2), "A display of your account information and statistical information. Please enjoy THRUSTIN!<br/>Username - boy2<br/>Name - boy2<br/>Password - [ENCRYPTED_CONTENT__UNVIEWABLE]<br/>Points Earned So Far - 0<br/>Games Played So Far - 1<br/>Games Won So Far - 0<br/>Level - 1<br/>Experience - 0/1");

	client.send(1, ".t 1");
	client.thrust(2);
	client.send(1, ".t 1");
	// boy2 - 1
	client.send(2, ".t 1");
	client.thrust(1);
	client.send(2, ".t 1");
	// boy - 1
	client.send(1, ".t 1");
	client.thrust(2);
	client.send(1, ".t 1");
	// boy2 - 2
	client.send(2, ".t 1");
	client.thrust(1);
	client.send(2, ".t 1");
	// boy - 2
	client.send(1, ".t 1");
	client.thrust(2);
	client.send(1, ".t 1");
	// boy2 - 3 WIN
	// boy gains 4 EXP, boy2 gains 7 EXP
	client.send(1, ".a");
	client.read_all();
	assert_eq!(client.last(1), "A display of your account information and statistical information. Please enjoy THRUSTIN!<br/>Username - boy<br/>Name - boy<br/>Password - [ENCRYPTED_CONTENT__UNVIEWABLE]<br/>Points Earned So Far - 2<br/>Games Played So Far - 1<br/>Games Won So Far - 0<br/>Level - 2<br/>Experience - 3/4");

	client.send(2, ".a");
	client.read_all();
	assert_eq!(client.last(2), "A display of your account information and statistical information. Please enjoy THRUSTIN!<br/>Username - boy2<br/>Name - boy2<br/>Password - [ENCRYPTED_CONTENT__UNVIEWABLE]<br/>Points Earned So Far - 3<br/>Games Played So Far - 1<br/>Games Won So Far - 1<br/>Level - 3<br/>Experience - 2/11");
}

#[test]
fn level_messages() {
	let mut client = common::setup_with_db("level_message");
	client.send(1, ".r gamer gamer gamer");
	client.send(1, ".m");
	client.send(1, ".po 1");
	client.send(1 ,".s");
	client.send(2, ".r gamer2 gamer2 gamer2");
	client.send(2, ".j 1");
	client.send(3, ".r gamer3 gamer3 gamer3");
	client.send(3, ".j 1");

	client.send(1, ".t 1");
	client.thrust(2);
	client.thrust(3);
	client.send(1, ".t 1");
	client.read_all();

	assert!(client.last(1).contains("Bro congratulation! You have receive 3 experience points, congratulation!<br/>gamer has LEVELED UP!!!! Congratulation, gamer, you are now level 2!!<br/>gamer2 has LEVELED UP!!!! Congratulation, gamer2, you are now level 2!!<br/>gamer3 has LEVELED UP!!!! Congratulation, gamer3, you are now level 2!!"));
	assert!(client.last(2).contains("Bro congratulation! You have receive 4 experience points, congratulation!<br/>gamer has LEVELED UP!!!! Congratulation, gamer, you are now level 2!!<br/>gamer2 has LEVELED UP!!!! Congratulation, gamer2, you are now level 2!!<br/>gamer3 has LEVELED UP!!!! Congratulation, gamer3, you are now level 2!!"));
	assert!(client.last(3).contains("Bro congratulation! You have receive 3 experience points, congratulation!<br/>gamer has LEVELED UP!!!! Congratulation, gamer, you are now level 2!!<br/>gamer2 has LEVELED UP!!!! Congratulation, gamer2, you are now level 2!!<br/>gamer3 has LEVELED UP!!!! Congratulation, gamer3, you are now level 2!!"));
}