# app load times
# auth activity
# middleware execution
# json reponses
# GET text/html
# validation error output
# unauthorized requests
# all wrappers out
# wrapper initialize calls
# gitpublisher calls
# gitpublisher network fail / retries
# gitpublisher serialization of complex

MAServer                     = require('meanair-server')
appRoot                      = __dirname + '/server'   #'/ex1-airpair'
config                       = MAServer.Config(appRoot, 'test', true)
config.auth.test =
  loginFnName: 'oauth'
  oauthFnName: 'oauth'

OPTS =
  login:
    clearSessions: true
    testUrl: '/auth/test/login'
    testHandler: (req, res, cb) ->
      profile = FIXTURE.clone("users.#{req.body.key}").auth.gh
      profile.emails = FIXTURE.wrappers[req.body.oaEmails] if req.body.oaEmails
      token = _.get(profile,"tokens.#{config.auth.appKey}.token") || "test"
      config.auth.test.loginFn.call req, 'github', profile, {token}, cb
  oauth:
    testUrl: '/auth/test/oauth'
    testHandler: (req, res, cb) ->
      {_json,provider} = req.body
      token = "test" # _.get(profile,"tokens.#{config.auth.appKey}.token") || "test"
      config.auth.test.oauthFns[provider].call req, provider, _json, {token}, cb


SCREAM = require('meanair-scream')(__dirname, OPTS)
SCREAM.run({config,MAServer})
