Skip to content

Commit a07bf14

Browse files
committed
Skip authentication for binance-cli v2 profile and completion commands
binance-cli v2 adds the profile and completion subcommands, which only manage local configuration and shell completion. They don't call the Binance API.
1 parent 93ec494 commit a07bf14

2 files changed

Lines changed: 50 additions & 0 deletions

File tree

‎plugins/binance/binance_cli.go‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ func BinanceCLI() schema.Executable {
1515
NeedsAuth: needsauth.IfAll(
1616
needsauth.NotForHelpOrVersion(),
1717
needsauth.NotWithoutArgs(),
18+
needsauth.NotForCommand("profile"),
19+
needsauth.NotForCommand("completion"),
1820
needsauth.NotWhenContainsArgs("t"),
1921
needsauth.NotWhenContainsArgs("i"),
2022
needsauth.NotWhenContainsArgs("book"),
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
package binance
2+
3+
import (
4+
"testing"
5+
6+
"github.com/1Password/shell-plugins/sdk/plugintest"
7+
)
8+
9+
func TestBinanceCLINeedsAuth(t *testing.T) {
10+
plugintest.TestNeedsAuth(t, BinanceCLI().NeedsAuth, map[string]plugintest.NeedsAuthCase{
11+
"no without args": {
12+
Args: []string{},
13+
ExpectedNeedsAuth: false,
14+
},
15+
"no for --help": {
16+
Args: []string{"--help"},
17+
ExpectedNeedsAuth: false,
18+
},
19+
"no for --version": {
20+
Args: []string{"--version"},
21+
ExpectedNeedsAuth: false,
22+
},
23+
"no for v1 public market data command": {
24+
Args: []string{"book", "bnbusdt"},
25+
ExpectedNeedsAuth: false,
26+
},
27+
"yes for v1 order command": {
28+
Args: []string{"buy", "-s", "BNBUSDT", "-t", "LIMIT", "-q", "0.05", "-p", "350", "-f", "GTC"},
29+
ExpectedNeedsAuth: true,
30+
},
31+
"no for v2 profile command": {
32+
Args: []string{"profile", "list"},
33+
ExpectedNeedsAuth: false,
34+
},
35+
"no for v2 completion command": {
36+
Args: []string{"completion", "zsh"},
37+
ExpectedNeedsAuth: false,
38+
},
39+
"yes for v2 signed command": {
40+
Args: []string{"spot", "get-account"},
41+
ExpectedNeedsAuth: true,
42+
},
43+
"yes for a profile named after an exempt command": {
44+
Args: []string{"spot", "get-account", "--profile", "profile"},
45+
ExpectedNeedsAuth: true,
46+
},
47+
})
48+
}

0 commit comments

Comments
 (0)