Last active
          July 20, 2017 16:52 
        
      - 
      
- 
        Save retendo/92cb4e709e1a85c1dc656d3e6d321552 to your computer and use it in GitHub Desktop. 
    Script: Create iTunes Connect sandbox test user
  
        
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | #!/usr/bin/ruby | |
| require 'spaceship' | |
| def create_password | |
| 'Gist1234' | |
| # ('A'..'Z').to_a[rand(26)] + rnd_str6 + ('0'..'9').to_a[rand(10)] | |
| end | |
| def rnd_str6 | |
| (0...6).map { ('a'..'z').to_a[rand(26)] }.join | |
| end | |
| def create_email (src_email) | |
| rnd_str = rnd_str6 | |
| emailFront, emailBack = src_email.split('@', 2) | |
| emailFront + '+' + rnd_str + '@' +emailBack | |
| end | |
| src_email = [(print 'iTunesConnect Login Email: '), gets.rstrip][1] | |
| Spaceship::Tunes.login src_email | |
| Spaceship::Tunes.select_team | |
| existing_emails = Spaceship::Tunes::SandboxTester.all | |
| .map { |u| u.email } | |
| new_email = create_email src_email | |
| new_password = create_password | |
| if existing_emails.include? new_email | |
| puts 'Sorry, something went wrong...please try again.' | |
| else | |
| tester = Spaceship::Tunes::SandboxTester.create!( | |
| email: new_email, | |
| password: new_password, # required. Must contain >=8 characters, >=1 uppercase, >=1 lowercase, >=1 numeric. | |
| country: 'DE', # optional, defaults to 'US' | |
| ) | |
| puts 'New Sandbox Tester Email: ' + tester.email | |
| puts 'Password: ' + new_password | |
| end | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment
  
            
Usage:
sudo gem install spaceship
ruby itc_create_sandbox_user.rb