| 1 |
/* |
| 2 |
Copyright 2013-2014 Canonical Ltd. |
| 3 |
|
| 4 |
This program is free software: you can redistribute it and/or modify it |
| 5 |
under the terms of the GNU General Public License version 3, as published |
| 6 |
by the Free Software Foundation. |
| 7 |
|
| 8 |
This program is distributed in the hope that it will be useful, but |
| 9 |
WITHOUT ANY WARRANTY; without even the implied warranties of |
| 10 |
MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR |
| 11 |
PURPOSE. See the GNU General Public License for more details. |
| 12 |
|
| 13 |
You should have received a copy of the GNU General Public License along |
| 14 |
with this program. If not, see <http://www.gnu.org/licenses/>. |
| 15 |
*/ |
| 16 |
|
| 17 |
// acceptanceclient command for playing. |
| 18 |
package main |
| 19 |
|
| 20 |
import ( |
| 21 |
"log" |
| 22 |
"os/exec" |
| 23 |
"strings" |
| 24 |
|
| 25 |
"gitlab.com/ubports/development/core/lomiri-push-service/server/acceptance" |
| 26 |
"gitlab.com/ubports/development/core/lomiri-push-service/server/acceptance/kit" |
| 27 |
) |
| 28 |
|
| 29 |
type configuration struct { |
| 30 |
kit.Configuration |
| 31 |
AuthHelper string `json:"auth_helper"` |
| 32 |
WaitFor string `json:"wait_for"` |
| 33 |
} |
| 34 |
|
| 35 |
func main() { |
| 36 |
kit.Defaults["auth_helper"] = "" |
| 37 |
kit.Defaults["wait_for"] = "" |
| 38 |
cfg := &configuration{} |
| 39 |
kit.CliLoop(cfg, &cfg.Configuration, func(session *acceptance.ClientSession, apiCli *kit.APIClient, cfgDir string) { |
| 40 |
log.Printf("with: %#v", session) |
| 41 |
}, func(url string) string { |
| 42 |
if cfg.AuthHelper == "" { |
| 43 |
return "" |
| 44 |
} |
| 45 |
auth, err := exec.Command(cfg.AuthHelper, url).Output() |
| 46 |
if err != nil { |
| 47 |
log.Fatalf("auth helper: %v", err) |
| 48 |
} |
| 49 |
return strings.TrimSpace(string(auth)) |
| 50 |
}, func() string { |
| 51 |
return cfg.WaitFor |
| 52 |
}, func() { |
| 53 |
}) |
| 54 |
} |