feat: a share link that can't be decrypted says why in a popup
Where its offer was, instead of the footer: the first line of the reason, r for the whole message (Key Vault's refusals list what to check), g to go to the key's secret at the link's version, and x to dismiss. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
2 files changed
+75
-1
No files matched your search
@@ -1,6 +1,8 @@
|
||||
package app
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"net/url"
|
||||
"os"
|
||||
"os/exec"
|
||||
@@ -312,3 +314,42 @@ func TestPlainEnvNotPickableFromFavourites(t *testing.T) {
|
||||
}
|
||||
t.Fatalf("the starred key isn't among the favourites: %d", len(favs))
|
||||
}
|
||||
|
||||
// refusing is a provider whose values can't be read, like a disabled
|
||||
// version in Key Vault.
|
||||
type refusing struct{ provider.Provider }
|
||||
|
||||
func (refusing) Value(context.Context, provider.Object) (provider.SecretValue, error) {
|
||||
return provider.SecretValue{}, &provider.Denied{
|
||||
Err: errors.New("Operation get is not allowed on a disabled secret."),
|
||||
Checks: []string{"the secret's version is enabled"},
|
||||
}
|
||||
}
|
||||
|
||||
func TestOpenFailsInAPopup(t *testing.T) {
|
||||
key, _ := share.ParseKey("https://" + kv + "/secrets/db-password")
|
||||
link, err := share.Seal(share.Header{Key: key, Repo: "git.example.com/team/app"},
|
||||
[]byte("correct-horse-battery-staple"), []share.File{{Path: ".env", Data: []byte("A=1\n")}}, demoRules)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
d := newDriverOpts(t, Options{}, refusing{fake.Azure(0)})
|
||||
d.wait = scryptWait
|
||||
d.send(tea.PasteMsg{Content: link.String()})
|
||||
d.keys("o")
|
||||
p := d.m.prompt
|
||||
if p == nil || p.title != "Can't decrypt the shared files" || !strings.Contains(d.screen(), "Can't use db-password: Operation get is not allowed") {
|
||||
t.Fatalf("not in a popup:\n%s", d.screen())
|
||||
}
|
||||
if strings.Contains(d.screen(), "version is enabled") {
|
||||
t.Error("the whole message is shown before asking")
|
||||
}
|
||||
d.keys("r")
|
||||
if !strings.Contains(d.screen(), "version is enabled") {
|
||||
t.Errorf("r doesn't show the whole message:\n%s", d.screen())
|
||||
}
|
||||
d.keys("g")
|
||||
if _, _, sel := d.selected(); d.m.prompt != nil || (sel != "db-password" && (d.m.nav == nil || d.m.nav.ref.Name != "db-password")) {
|
||||
t.Errorf("g doesn't go to the key: %q, %q\n%s", sel, d.m.flash.text, d.screen())
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user