Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save adam-phillipps/5637991 to your computer and use it in GitHub Desktop.
Save adam-phillipps/5637991 to your computer and use it in GitHub Desktop.
1 PORTAL_TOKEN = "1~R6LQJOPqzOWXQfLYDTnWXXC8rBnzlfcD9yatg004A7kQlkpEKSk8GtDGERhAJ86K"
2 PORTAL_AT_TOKEN = "1~4HqG8O8JN1f8H94IkhMYgjxD8LlEcNosQ0AJ7ET3Wh78X54fS6Be3mFHHnMiuiJs"
3 LOCAL_TOKEN = "1~KtP1voLOAsUkIgqum0qfMZl7N9PaQQhsI9vAhii0UgASIUDW40belLlk0Bhm8Mmi"
4 BETA_TOKEN = "1~gBl5tEyJ1jcCe8onAgO7rOhp8lo9fm2omVbYISciCa8BrKFJndmTqkUtNdWrJQoF"
5 PORTAL_URL = "54.243.66.130"
6 LOCAL_URL = "http://localhost:3000"
7 BETA_URL = "http://adam.beta.instructure.com"
8 RECIPIENT = "2"
9 @selection = ''
10 @account = ''
11 @counter = ''
12 @token - ''
13 @url = ''
14 @recipient = ''
15
16 def account
17 print "The account you're testing against: "
18 @account = gets.to_s
19 end
20
21 def tester_selection
22 print "Number of users and conversatoins generated: "
23 @selection = gets.to_i
24 end
25
26 def recipient_selection
27 print "Who you want the conversations to go to: "
28 @recipient = gets.to_i
29 end
30
31 def login_password_creator
32 @counter = " 0...@selection".to_i
33 end
34
35 def create_users (token, url, account, name, login)
36 post = "curl -H 'Authorization: Bearer #{token}' \'#{url}/api/v1/accounts/#{@account}/users' \-F 'user[name]=#{@counter}'
37 \-F 'pseudonym[unique_id]=#{@counter}' \-F 'pseudonym[password]=password' \-X POST"
38 result = %x[#{post}]
39 result.to_s
40 end
41
42 def body
43 Random.new.rand(1..99999999).to_s
44 end
45
46 def create_conversations (token, url, recipients)
47 post = "curl -H 'Authorization: Bearer #{token}' \'#{url}/api/v1/conversations' \-F 'recipients[]=#{recipients}' \-F 'body=#{body}' \-X POST"
48
49 result = %x[#{post}]
50 result.to_s
51 end
52
53 @selection.times do |f|
54 create_users(PORTAL_TOKEN, PORTAL_URL, @account, @counter, @counter)
55 create_conversations(PORTAL_TOKEN, PORTAL_URL, RECIPIENT)
56 puts f.to_i
57 end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment