Repository: nats-io/nsc
Pull request #430 (2021-10-13 13:37:48)

DOCS: conn-type flag description
The flag "--conn-type" defines the allowed connections. If you define --conn-type MQTT, the user will **exclusively** have access via MQTT.
This bahaviour is not properly stated / documented. Therefore I suggest to adjust the flag description.
The feature description and behaviour was introduced here: https://github.com/nats-io/jwt/pull/97


Patch:
diff --git a/cmd/editscopedsk.go b/cmd/editscopedsk.go
index 51af784..e775297 100644
--- a/cmd/editscopedsk.go
+++ b/cmd/editscopedsk.go
@@ -65,7 +65,7 @@ func (p *EditScopedSkParams) SetDefaults(ctx ActionCtx) error {
 	if err := p.AccountContextParams.SetDefaults(ctx); err != nil {
 		return err
 	}
-	p.SignerParams.SetDefaults(nkeys.PrefixByteAccount, true, ctx)
+	p.SignerParams.SetDefaults(nkeys.PrefixByteOperator, true, ctx)
 	return nil
 }
 
diff --git a/cmd/edituser.go b/cmd/edituser.go
index b6ae030..682eba9 100644
--- a/cmd/edituser.go
+++ b/cmd/edituser.go
@@ -350,7 +350,7 @@ func (p *UserPermissionLimits) BindFlags(cmd *cobra.Command) {
 	cmd.Flags().VarP(&p.locale, "locale", "", "set the locale with which time values are interpreted")
 	cmd.Flags().StringSliceVarP(&p.src, "source-network", "", nil, "add source network for connection - comma separated list or option can be specified multiple times")
 	cmd.Flags().StringSliceVarP(&p.rmSrc, "rm-source-network", "", nil, "remove source network for connection - comma separated list or option can be specified multiple times")
-	cmd.Flags().StringSliceVarP(&p.connTypes, "conn-type", "", nil, fmt.Sprintf("add connection types: %s %s %s %s - comma separated list or option can be specified multiple times",
+	cmd.Flags().StringSliceVarP(&p.connTypes, "conn-type", "", nil, fmt.Sprintf("define allowed connection types: %s %s %s %s - comma separated list or option can be specified multiple times",
 		jwt.ConnectionTypeLeafnode, jwt.ConnectionTypeMqtt, jwt.ConnectionTypeStandard, jwt.ConnectionTypeWebsocket))
 	cmd.Flags().StringSliceVarP(&p.rmConnTypes, "rm-conn-type", "", nil, "remove connection types - comma separated list or option can be specified multiple times")
 	cmd.Flags().Int64VarP(&p.maxSubs, "subs", "", -1, "set maximum number of subscriptions (-1 is unlimited)")


Test patch:
diff --git a/cmd/editscopedsk_test.go b/cmd/editscopedsk_test.go
index 56ab78e..e521eb1 100644
--- a/cmd/editscopedsk_test.go
+++ b/cmd/editscopedsk_test.go
@@ -41,22 +41,27 @@ func Test_EditScopedSk_Subs(t *testing.T) {
 	ts := NewTestStore(t, "edit scope")
 	defer ts.Done(t)
 
+	oc, err := ts.Store.ReadOperatorClaim()
+	require.NoError(t, err)
+
 	ts.AddAccount(t, "A")
 	_, pk, _ := CreateAccountKey(t)
 	s, pk2, kp := CreateAccountKey(t)
 
-	_, _, err := ExecuteCmd(createEditAccount(), "--sk", pk, "--sk", pk2)
+	_, _, err = ExecuteCmd(createEditAccount(), "--sk", pk, "--sk", pk2)
 	require.NoError(t, err)
 
 	ac, err := ts.Store.ReadAccountClaim("A")
 	require.NoError(t, err)
 	require.Contains(t, ac.SigningKeys, pk)
 	require.Contains(t, ac.SigningKeys, pk2)
+	require.Equal(t, ac.Issuer, oc.Subject)
 
 	checkAcc := func(subs int64) {
 		ac, err = ts.Store.ReadAccountClaim("A")
 		require.NoError(t, err)
 		require.Contains(t, ac.SigningKeys, pk)
+		require.Equal(t, ac.Issuer, oc.Subject)
 		s, ok := ac.SigningKeys.GetScope(pk)
 		require.True(t, ok)
 		require.Nil(t, s)