1
0
Fork 0
mirror of https://github.com/openstf/stf synced 2025-10-03 17:59:28 +02:00

Make app work with login.

This commit is contained in:
Simo Kinnunen 2014-01-27 15:38:40 +09:00
parent d8ca15d002
commit f2066b35fa
15 changed files with 237 additions and 26 deletions

View file

@ -1,3 +1,5 @@
var util = require('util')
var program = require('commander')
var pkg = require('../package')
@ -131,7 +133,7 @@ program
.option('-p, --port <port>'
, 'port (or $PORT)'
, Number
, 7100)
, 7120)
.option('-s, --secret <secret>'
, 'secret (or $SECRET)'
, String)
@ -189,6 +191,41 @@ program
program
.command('auth-mock')
.description('start mock auth client')
.option('-p, --port <port>'
, 'port (or $PORT)'
, Number
, 7120)
.option('-s, --secret <secret>'
, 'secret (or $SECRET)'
, String)
.option('-i, --ssid <ssid>'
, 'session SSID (or $SSID)'
, String
, 'ssid')
.option('-a, --app-url <url>'
, 'URL to app'
, String)
.action(function(options) {
var env = process.env
if (!options.secret) {
this.missingArgument('--secret')
}
if (!options.appUrl) {
this.missingArgument('--app-url')
}
require('./roles/auth/mock')({
port: env.PORT || options.port
, secret: options.secret || env.SECRET
, ssid: options.ssid || env.SSID
, appUrl: options.appUrl
})
})
program
.command('app')
.description('start app')
.option('-p, --port <port>'
, 'port (or $PORT)'
, Number
@ -200,12 +237,24 @@ program
, 'session SSID (or $SSID)'
, String
, 'ssid')
.option('-a, --auth-url <url>'
, 'URL to auth client'
, String)
.action(function(options) {
var env = process.env
require('./roles/auth/mock')({
if (!options.secret) {
this.missingArgument('--secret')
}
if (!options.authUrl) {
this.missingArgument('--auth-url')
}
require('./roles/app')({
port: env.PORT || options.port
, secret: options.secret || env.SECRET
, ssid: options.ssid || env.SSID
, authUrl: options.authUrl
})
})
@ -269,6 +318,10 @@ program
, 'auth secret'
, String
, 'kute kittykat')
.option('--app-port <port>'
, 'app port'
, Number
, 7100)
.action(function() {
var log = logger.createLogger('cli')
, options = cliutil.lastArg(arguments)
@ -330,10 +383,22 @@ program
'auth-mock'
, '--port', options.authPort
, '--secret', options.authSecret
, '--app-url', util.format('http://localhost:%d/', options.appPort)
])
.catch(function(err) {
log.error('auth-mock died', err.stack)
})
// app
procutil.fork(__filename, [
'app'
, '--port', options.appPort
, '--secret', options.authSecret
, '--auth-url', util.format('http://localhost:%d/', options.authPort)
])
.catch(function(err) {
log.error('app died', err.stack)
})
})
program.parse(process.argv)