Project

General

Profile

Task #7366 » test_game.sh

Den Ivanov, 12/03/2019 11:00 PM

 
1
#!/bin/bash
2
sleepdelay="5"                # Delay between commands
3
gameaddr="[::]:5002"          # Game server address
4
user="sxiii-$(date +%HH%MM)"  # User to register
5
network="2a0a:e5c0:101::/64"  # Network to register
6

    
7
cmd="http $gameaddr"
8
echo -e "Getting information about the game:\n $ $cmd"
9
sleep $sleepdelay && eval "$cmd"
10

    
11
cmd="http POST $gameaddr/register user=$user"
12
echo -e "Registering a new user called $user:\n $ $cmd"
13
sleep $sleepdelay && eval "$cmd"
14

    
15
cmd="http POST $gameaddr/register user=$user"
16
echo -e "Trying to register with the same user again:\n $ $cmd"
17
sleep $sleepdelay && eval "$cmd"
18

    
19
cmd="http $gameaddr/challenge"
20
echo -e "Looking which challenges are available:\n $ $cmd"
21
sleep $sleepdelay && eval "$cmd"
22

    
23
cmd="http $gameaddr/challenge/RegisterNet"
24
echo -e "Reading challenge #1 description:\n $ $cmd"
25
sleep $sleepdelay && eval "$cmd"
26

    
27
cmd="http POST $gameaddr/challenge/RegisterNet user=$user network=$network"
28
echo -e "Registering network (challenge 1):\n $ $cmd"
29
sleep $sleepdelay && eval "$cmd"
30

    
31
cmd="http POST $gameaddr/challenge/RegisterNet user=$user network=$network"
32
echo -e "Trying to register network again:\n $ $cmd"
33
sleep $sleepdelay && eval "$cmd"
34

    
35
cmd="http POST $gameaddr/points user=$user"
36
echo -e "Getting points for our player:\n $ $cmd"
37
sleep $sleepdelay && eval "$cmd"
38

    
39
cmd="http POST $gameaddr/challenge/IPv6Address user=sxiii"
40
echo -e "Checking if IP is pingable (challenge 2):\n $ $cmd"
41
sleep $sleepdelay && eval "$cmd"
42
sleep $sleepdelay
43
toilet --rainbow -t "Done! Thank you :)"
44

    
45
#1) Information about the game: ("curl ip/index")
46
#2) Registration of the new user with his IP and date: ("curl -X POST -d user=sxiii ip/register")
47
#3) Checking if user registered, it returns user IP (re-run previous command again)
48
#4) Challenges listing ("curl ip/challenge")
49
#5) RegisterNet challenge ("curl -X POST -d user=sxiii -d 'network=2a0a:e5c0:101::/64' ip/challenge/RegisterNet")
50
#6) Checking if challenge already done; it returns error (re-run prev. command)
51
#7) Getting points for user: ``` curl -X POST -d user=sxiii ip/points ```
52
#8) Challenge IPv6Address (checking if IP is pingable): ``` curl -X POST -d user=sxiii ip/challenge/IPv6Address ```
(3-3/3)