<commit_before>_        = require 'underscore'
hat      = require 'hat'
JUser    = require './lib/social/models/user/index'
JAccount = require './lib/social/models/account'


# returns 20 characters by default
generateRandomString = (length = 20) -> hat().slice(32 - length)


generateRandomEmail = (domain = 'koding.com') ->

  return "kodingtestuser+#{generateRandomString()}@#{domain}"


generateRandomUsername = -> generateRandomString()


generateDummyClient = (context, callback) ->

  # sending null session token to generate a new client
  JUser.authenticateClient null, (err, res = {}) ->

    return callback err  if err

    { account, session } = res
    context ?= { group: session?.groupName ? 'koding' }

    if account instanceof JAccount
      { clientIP, clientId } = session

      # replace token with session.clientid
      sessionToken = clientId

      client =
        sessionToken : sessionToken
        context      : context
        clientIP     : '127.0.0.1'
        connection   :
          delegate   : account

      callback null, client

    else
      callback 'session error'


generateDummyUserFormData = ->

  dummyUserFormData =
    email                     : generateRandomEmail()
    agree                     : 'on'
    password                  : '<PASSWORD>'
    username                  : generateRandomUsername()
    passwordConfirm           : '<PASSWORD>'<commit_msg>improved generatedummyclient function<commit_after>_        = require 'underscore'
hat      = require 'hat'
JAccount = require './lib/social/models/account'
JSession = require './lib/social/models/session'


# returns 20 characters by default
generateRandomString = (length = 20) -> hat().slice(32 - length)


generateRandomEmail = (domain = 'koding.com') ->

  return "kodingtestuser+#{generateRandomString()}@#{domain}"


generateRandomUsername = -> generateRandomString()


generateDummyClient = (context, callback) ->

  # creating session and account
  JSession.createSession (err, data) ->
    callback err  if err

    { session, account } = data
    context ?= { group: session?.groupName ? 'koding' }

    if account instanceof JAccount
      { clientIP, clientId } = session

      # replace token with session.clientid
      sessionToken = clientId

      # setting client data
      client =
        sessionToken : sessionToken
        context      : context
        clientIP     : '127.0.0.1'
        connection   :
          delegate   : account

      callback null, client

    else
      callback 'session error'


generateDummyUserFormData = ->

  dummyUserFormData =
    email                     : generateRandomEmail()
    agree                     : 'on'
    password                  : '<PASSWORD>'
    username                  : generateRandomUsername()
    passwordConfirm           : '<PASSWORD>'
{'fraction_non_alphanumeric': 0.09721733004579076, 'fraction_numerical': 0.008453680873547023, 'mean_word_length': 2.313885647607935, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 19, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 2, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5542915', 'n_tokens_mistral': 774, 'n_tokens_neox': 725, 'n_words': 195}