Change port in test-api.sh back to 8080

This commit is contained in:
Elias Schriefer 2021-12-13 14:34:10 +01:00
parent f3b9e91040
commit be372352a4

View File

@ -1,20 +1,20 @@
#!/usr/bin/env bash #!/usr/bin/env bash
echo Create users @a, @b, and @c: echo Create users @a, @b, and @c:
userIDs=$(curl "localhost:8081/graphql" -X POST -H "content-type: application/json" --data '{"query":"mutation addUsers($a: NewUser!, $b: NewUser!, $c: NewUser!) {\n a: newUser(newUser: $a)\n b: newUser(newUser: $b)\n c: newUser(newUser: $c)\n}","variables":{"a":{"userName":"@a","passwordHash":"1234567890"},"b":{"userName":"@b","passwordHash":"1234567890"},"c":{"userName":"@c","passwordHash":"1234567890"}},"operationName":"addUsers"}' | jq .data) userIDs=$(curl "localhost:8080/graphql" -X POST -H "content-type: application/json" --data '{"query":"mutation addUsers($a: NewUser!, $b: NewUser!, $c: NewUser!) {\n a: newUser(newUser: $a)\n b: newUser(newUser: $b)\n c: newUser(newUser: $c)\n}","variables":{"a":{"userName":"@a","passwordHash":"1234567890"},"b":{"userName":"@b","passwordHash":"1234567890"},"c":{"userName":"@c","passwordHash":"1234567890"}},"operationName":"addUsers"}' | jq .data)
echo "$userIDs" | jq . echo "$userIDs" | jq .
a=$(echo "$userIDs" | jq -r .a) a=$(echo "$userIDs" | jq -r .a)
b=$(echo "$userIDs" | jq -r .b) b=$(echo "$userIDs" | jq -r .b)
c=$(echo "$userIDs" | jq -r .c) c=$(echo "$userIDs" | jq -r .c)
echo -e \nCreate chats between @a and @b, @a and @c, and group chats between @a, @b, and @c: echo -e \nCreate chats between @a and @b, @a and @c, and group chats between @a, @b, and @c:
curl "localhost:8081/graphql" -X POST -H "content-type: application/json" --data "{\"query\":\"mutation createChat(\$a: ID!, \$b: ID!, \$c: ID!, \$pwHash: String!) {\n ab: newChat(user: \$a, passwordHash: \$pwHash, with: \$b)\n ac: newChat(user: \$a, passwordHash: \$pwHash, with: \$c)\n abc: newGroupChat(user: \$a, passwordHash: \$pwHash, with: [\$b, \$c], title: \\\"ABC\\\")\n}\",\"variables\":{\"pwHash\":\"1234567890\",\"a\":\"$a\",\"b\":\"$b\",\"c\":\"$c\"},\"operationName\":\"createChat\"}" | jq .data curl "localhost:8080/graphql" -X POST -H "content-type: application/json" --data "{\"query\":\"mutation createChat(\$a: ID!, \$b: ID!, \$c: ID!, \$pwHash: String!) {\n ab: newChat(user: \$a, passwordHash: \$pwHash, with: \$b)\n ac: newChat(user: \$a, passwordHash: \$pwHash, with: \$c)\n abc: newGroupChat(user: \$a, passwordHash: \$pwHash, with: [\$b, \$c], title: \\\"ABC\\\")\n}\",\"variables\":{\"pwHash\":\"1234567890\",\"a\":\"$a\",\"b\":\"$b\",\"c\":\"$c\"},\"operationName\":\"createChat\"}" | jq .data
echo -e \nList all users\' chats: echo -e \nList all users\' chats:
chatIDs=$(curl "localhost:8081/graphql" -X POST -H "content-type: application/json" --data "{\"query\":\"query listChats(\$a: ID!, \$b: ID!, \$c: ID!, \$pwHash: String!) {\n aChats: chats(user: \$a, passwordHash: \$pwHash) {\n id\n users\n }\n aGroupChats: groupChats(user: \$a, passwordHash: \$pwHash) {\n id\n title\n description\n users\n }\n bChats: chats(user: \$b, passwordHash: \$pwHash) {\n id\n users\n }\n bGroupChats: groupChats(user: \$b, passwordHash: \$pwHash) {\n id\n title\n description\n users\n }\n cChats: chats(user: \$c, passwordHash: \$pwHash) {\n id\n users\n }\n cGroupChats: groupChats(user: \$c, passwordHash: \$pwHash) {\n id\n title\n description\n users\n }\n}\",\"variables\":{\"pwHash\":\"1234567890\",\"a\":\"$a\",\"b\":\"$b\",\"c\":\"$c\"},\"operationName\":\"listChats\"}" | jq .data) chatIDs=$(curl "localhost:8080/graphql" -X POST -H "content-type: application/json" --data "{\"query\":\"query listChats(\$a: ID!, \$b: ID!, \$c: ID!, \$pwHash: String!) {\n aChats: chats(user: \$a, passwordHash: \$pwHash) {\n id\n users\n }\n aGroupChats: groupChats(user: \$a, passwordHash: \$pwHash) {\n id\n title\n description\n users\n }\n bChats: chats(user: \$b, passwordHash: \$pwHash) {\n id\n users\n }\n bGroupChats: groupChats(user: \$b, passwordHash: \$pwHash) {\n id\n title\n description\n users\n }\n cChats: chats(user: \$c, passwordHash: \$pwHash) {\n id\n users\n }\n cGroupChats: groupChats(user: \$c, passwordHash: \$pwHash) {\n id\n title\n description\n users\n }\n}\",\"variables\":{\"pwHash\":\"1234567890\",\"a\":\"$a\",\"b\":\"$b\",\"c\":\"$c\"},\"operationName\":\"listChats\"}" | jq .data)
echo "$chatIDs" | jq . echo "$chatIDs" | jq .
ab=$(echo "$chatIDs" | jq -r .aChats[0].id) ab=$(echo "$chatIDs" | jq -r .aChats[0].id)
abc=$(echo "$chatIDs" | jq -r .aGroupChats[0].id) abc=$(echo "$chatIDs" | jq -r .aGroupChats[0].id)
echo -e \nSend a private/group message: echo -e \nSend a private/group message:
#echo "{\"pwHash\":\"1234567890\",\"a\":\"$a\",\"bChat\":\"$ab\",\"abc\":\"$abc\",\"msg\":{\"msgType\":\"TEXT\",\"content\":\"Test\"}}" | jq . #echo "{\"pwHash\":\"1234567890\",\"a\":\"$a\",\"bChat\":\"$ab\",\"abc\":\"$abc\",\"msg\":{\"msgType\":\"TEXT\",\"content\":\"Test\"}}" | jq .
curl "localhost:8081/graphql" -X POST -H "content-type: application/json" --data "{\"query\":\"mutation sendMessages(\$a: ID!, \$pwHash: String!, \$bChat: ID!, \$abc: ID!, \$msg: MessageInput!) {\n chat: sendMessage(user: \$a, passwordHash: \$pwHash, chat: \$bChat, msg: \$msg)\n group: sendMessage(user: \$a, passwordHash: \$pwHash, chat: \$abc, msg: \$msg)\n}\",\"variables\":{\"pwHash\":\"1234567890\",\"a\":\"$a\",\"bChat\":\"$ab\",\"abc\":\"$abc\",\"msg\":{\"msgType\":\"TEXT\",\"content\":\"Test\"}},\"operationName\":\"sendMessages\"}" | jq . curl "localhost:8080/graphql" -X POST -H "content-type: application/json" --data "{\"query\":\"mutation sendMessages(\$a: ID!, \$pwHash: String!, \$bChat: ID!, \$abc: ID!, \$msg: MessageInput!) {\n chat: sendMessage(user: \$a, passwordHash: \$pwHash, chat: \$bChat, msg: \$msg)\n group: sendMessage(user: \$a, passwordHash: \$pwHash, chat: \$abc, msg: \$msg)\n}\",\"variables\":{\"pwHash\":\"1234567890\",\"a\":\"$a\",\"bChat\":\"$ab\",\"abc\":\"$abc\",\"msg\":{\"msgType\":\"TEXT\",\"content\":\"Test\"}},\"operationName\":\"sendMessages\"}" | jq .