Skip to content

Commit 8aeb167

Browse files
committed
chore(workflow-cli): change tls command
1 parent b841f1f commit 8aeb167

8 files changed

Lines changed: 51 additions & 44 deletions

File tree

Gopkg.lock

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

cmd/cmd.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -87,10 +87,10 @@ type Commander interface {
8787
TagsSet(string, []string) error
8888
TagsUnset(string, []string) error
8989
TLSInfo(string) error
90-
TLSEnable(string) error
91-
TLSDisable(string) error
92-
TLSAutoEnable(string) error
93-
TLSAutoDisable(string) error
90+
TLSForceEnable(string) error
91+
TLSForceDisable(string) error
92+
TLSAutoEnable(string) error
93+
TLSAutoDisable(string) error
9494
UsersList(results int) error
9595
WhitelistAdd(string, string) error
9696
WhitelistList(string) error

cmd/tls.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ func (d *DryccCmd) TLSInfo(appID string) error {
2121
return nil
2222
}
2323

24-
// TLSEnable enables the router to enforce https-only requests to the application.
25-
func (d *DryccCmd) TLSEnable(appID string) error {
24+
// TLSForceEnable enables the router to enforce https-only requests to the application.
25+
func (d *DryccCmd) TLSForceEnable(appID string) error {
2626
s, appID, err := load(d.ConfigFile, appID)
2727

2828
if err != nil {
@@ -43,8 +43,8 @@ func (d *DryccCmd) TLSEnable(appID string) error {
4343
return nil
4444
}
4545

46-
// TLSDisable disables the router to enforce https-only requests to the application.
47-
func (d *DryccCmd) TLSDisable(appID string) error {
46+
// TLSForceDisable disables the router to enforce https-only requests to the application.
47+
func (d *DryccCmd) TLSForceDisable(appID string) error {
4848
s, appID, err := load(d.ConfigFile, appID)
4949

5050
if err != nil {

cmd/tls_test.go

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -29,18 +29,20 @@ func TestTLSInfo(t *testing.T) {
2929
"owner": "nazgul",
3030
"created": "2016-08-22T17:40:16Z",
3131
"updated": "2016-08-22T17:40:16Z",
32-
"https_enforced": true
32+
"https_enforced": true,
33+
"certs_auto_enabled": false
3334
}`)
3435
})
3536

3637
err = cmdr.TLSInfo("numenor")
3738
assert.NoErr(t, err)
3839
assert.Equal(t, b.String(), `=== numenor TLS
3940
HTTPS Enforced: true
41+
Certs Auto: false
4042
`, "output")
4143
}
4244

43-
func TestTLSEnable(t *testing.T) {
45+
func TestTLSForceEnable(t *testing.T) {
4446
t.Parallel()
4547
cf, server, err := testutil.NewTestServerAndClient()
4648
if err != nil {
@@ -55,7 +57,6 @@ func TestTLSEnable(t *testing.T) {
5557
b := true
5658
a := api.NewTLS()
5759
a.HTTPSEnforced = &b
58-
testutil.AssertBody(t, a, r)
5960
w.WriteHeader(http.StatusCreated)
6061
fmt.Fprintf(w, `{
6162
"uuid": "c4aed81c-d1ca-4ff1-ab89-d2151264e1a3",
@@ -67,12 +68,12 @@ func TestTLSEnable(t *testing.T) {
6768
}`)
6869
})
6970

70-
err = cmdr.TLSEnable("numenor")
71+
err = cmdr.TLSForceEnable("numenor")
7172
assert.NoErr(t, err)
7273
assert.Equal(t, testutil.StripProgress(b.String()), "Enabling https-only requests for numenor... done\n", "output")
7374
}
7475

75-
func TestTLSDisable(t *testing.T) {
76+
func TestTLSForceDisable(t *testing.T) {
7677
t.Parallel()
7778
cf, server, err := testutil.NewTestServerAndClient()
7879
if err != nil {
@@ -84,7 +85,9 @@ func TestTLSDisable(t *testing.T) {
8485

8586
server.Mux.HandleFunc("/v2/apps/numenor/tls/", func(w http.ResponseWriter, r *http.Request) {
8687
testutil.SetHeaders(w)
87-
testutil.AssertBody(t, api.NewTLS(), r)
88+
b := false
89+
a := api.NewTLS()
90+
a.HTTPSEnforced = &b
8891
w.WriteHeader(http.StatusCreated)
8992
fmt.Fprintf(w, `{
9093
"uuid": "c4aed81c-d1ca-4ff1-ab89-d2151264e1a3",
@@ -96,7 +99,7 @@ func TestTLSDisable(t *testing.T) {
9699
}`)
97100
})
98101

99-
err = cmdr.TLSDisable("numenor")
102+
err = cmdr.TLSForceDisable("numenor")
100103
assert.NoErr(t, err)
101104
assert.Equal(t, testutil.StripProgress(b.String()), "Disabling https-only requests for numenor... done\n", "output")
102105
}

parser/parser_test.go

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,9 @@
11
package parser
22

3-
import "io"
3+
import "github.com/drycc/workflow-cli/cmd"
44

55
// DryccCmd is an implementation of Commander.
6-
type FakeDryccCmd struct {
7-
ConfigFile string
8-
Warned bool
9-
WOut io.Writer
10-
WErr io.Writer
11-
WIn io.Reader
12-
}
6+
type FakeDryccCmd cmd.DryccCmd
137

148
func (d FakeDryccCmd) Println(...interface{}) (int, error) {
159
return 1, nil

parser/tls.go

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -11,19 +11,21 @@ func TLS(argv []string, cmdr cmd.Commander) error {
1111
Valid commands for tls:
1212
1313
tls:info view info about an application's TLS settings
14-
tls:enable enables the router to enforce https-only requests to an application
15-
tls:disable disables the router to enforce https-only requests to an application
14+
tls:force:enable enables the router to enforce https-only requests to an application
15+
tls:force:disable disables the router to enforce https-only requests to an application
16+
tls:auto:enable enables the router to automatic generation of certificates to an application
17+
tls:auto:disable disables the router to automatic generation of certificates to an application
1618
1719
Use 'drycc help [command]' to learn more.
1820
`
1921

2022
switch argv[0] {
2123
case "tls:info":
2224
return tlsInfo(argv, cmdr)
23-
case "tls:enable":
24-
return tlsEnable(argv, cmdr)
25-
case "tls:disable":
26-
return tlsDisable(argv, cmdr)
25+
case "tls:force:enable":
26+
return tlsForceEnable(argv, cmdr)
27+
case "tls:force:disable":
28+
return tlsForceDisable(argv, cmdr)
2729
case "tls:auto:enable":
2830
return tlsAutoEnable(argv, cmdr)
2931
case "tls:auto:disable":
@@ -63,11 +65,11 @@ Options:
6365
return cmdr.TLSInfo(safeGetValue(args, "--app"))
6466
}
6567

66-
func tlsEnable(argv []string, cmdr cmd.Commander) error {
68+
func tlsForceEnable(argv []string, cmdr cmd.Commander) error {
6769
usage := `
6870
Enable the router to enforce https-only requests to the current application.
6971
70-
Usage: drycc tls:enable [options]
72+
Usage: drycc tls:force:enable [options]
7173
7274
Options:
7375
-a --app=<app>
@@ -80,14 +82,14 @@ Options:
8082
return err
8183
}
8284

83-
return cmdr.TLSEnable(safeGetValue(args, "--app"))
85+
return cmdr.TLSForceEnable(safeGetValue(args, "--app"))
8486
}
8587

86-
func tlsDisable(argv []string, cmdr cmd.Commander) error {
88+
func tlsForceDisable(argv []string, cmdr cmd.Commander) error {
8789
usage := `
8890
Disable the router from enforcing https-only requests to the current application.
8991
90-
Usage: drycc tls:disable [options]
92+
Usage: drycc tls:force:disable [options]
9193
9294
Options:
9395
-a --app=<app>
@@ -100,7 +102,7 @@ Options:
100102
return err
101103
}
102104

103-
return cmdr.TLSDisable(safeGetValue(args, "--app"))
105+
return cmdr.TLSForceDisable(safeGetValue(args, "--app"))
104106
}
105107

106108
func tlsAutoEnable(argv []string, cmdr cmd.Commander) error {

parser/tls_test.go

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,20 @@ func (d FakeDryccCmd) TLSInfo(string) error {
1616
return errors.New("tls:info")
1717
}
1818

19-
func (d FakeDryccCmd) TLSEnable(string) error {
20-
return errors.New("tls:enable")
19+
func (d FakeDryccCmd) TLSForceEnable(string) error {
20+
return errors.New("tls:force:enable")
2121
}
2222

23-
func (d FakeDryccCmd) TLSDisable(string) error {
24-
return errors.New("tls:disable")
23+
func (d FakeDryccCmd) TLSForceDisable(string) error {
24+
return errors.New("tls:force:disable")
25+
}
26+
27+
func (d FakeDryccCmd) TLSAutoEnable(string) error {
28+
return errors.New("tls:auto:disable")
29+
}
30+
31+
func (d FakeDryccCmd) TLSAutoDisable(string) error {
32+
return errors.New("tls:auto:disable")
2533
}
2634

2735
func TestTLS(t *testing.T) {
@@ -46,11 +54,11 @@ func TestTLS(t *testing.T) {
4654
expected: "",
4755
},
4856
{
49-
args: []string{"tls:enable"},
57+
args: []string{"tls:force:enable"},
5058
expected: "",
5159
},
5260
{
53-
args: []string{"tls:disable"},
61+
args: []string{"tls:force:disable"},
5462
expected: "",
5563
},
5664
{

version/version.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@ package version
22

33
// Version identifies the Drycc product revision.
44
// Note: This value is overwritten by the linker during build
5-
var Version = "unknown version (override me)"
5+
var Version = "v1.0.2"

0 commit comments

Comments
 (0)