-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ENG-648 add error if sharing with user that has no keys setup (#255)
* add error if sharing with user that has no keys setup * fixes after code review
- Loading branch information
Showing
4 changed files
with
52 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -114,6 +114,29 @@ func TestShare(t *testing.T) { | |
{ | ||
name: `test "crypto share"`, | ||
args: []string{plural.ApplicationName, "crypto", "share", "--email", "[email protected]"}, | ||
keys: []*api.PublicKey{ | ||
{ | ||
Id: "abc", | ||
Content: "age1wqc2hk954ukemelys5gxdwlqve8ev0e88hvl3cjhfcvq65gwgvsqkmq9dn", | ||
User: &api.User{ | ||
Email: "[email protected]", | ||
}, | ||
}, | ||
}, | ||
}, | ||
{ | ||
name: `test "crypto share" where test user has no key setup`, | ||
args: []string{plural.ApplicationName, "crypto", "share", "--email", "[email protected]"}, | ||
keys: []*api.PublicKey{ | ||
{ | ||
Id: "abc", | ||
Content: "age1wqc2hk954ukemelys5gxdwlqve8ev0e88hvl3cjhfcvq65gwgvsqkmq9dn", | ||
User: &api.User{ | ||
Email: "[email protected]", | ||
}, | ||
}, | ||
}, | ||
expectedError: "Some of the users [[email protected]] have no keys setup", | ||
}, | ||
} | ||
for _, test := range tests { | ||
|
@@ -126,13 +149,15 @@ func TestShare(t *testing.T) { | |
}(dir) | ||
err = os.Chdir(dir) | ||
assert.NoError(t, err) | ||
os.Setenv("HOME", dir) | ||
defer os.Unsetenv("HOME") | ||
defaultConfig := pluraltest.GenDefaultConfig() | ||
err = defaultConfig.Save(config.ConfigName) | ||
assert.NoError(t, err) | ||
|
||
client := mocks.NewClient(t) | ||
if test.expectedError == "" { | ||
client.On("ListKeys", mock.Anything).Return(nil, nil) | ||
if test.keys != nil { | ||
client.On("ListKeys", mock.Anything).Return(test.keys, nil) | ||
} | ||
app := plural.CreateNewApp(&plural.Plural{Client: client}) | ||
app.HelpName = plural.ApplicationName | ||
|
@@ -182,7 +207,9 @@ func TestRecover(t *testing.T) { | |
// create temp environment | ||
dir, err := os.MkdirTemp("", "config") | ||
assert.NoError(t, err) | ||
defer os.RemoveAll(dir) | ||
defer func(path string) { | ||
_ = os.RemoveAll(path) | ||
}(dir) | ||
|
||
os.Setenv("HOME", dir) | ||
defer os.Unsetenv("HOME") | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters