MCPcopy
hub / github.com/FiloSottile/age / TestLabels

Function TestLabels

plugin/client_test.go:70–123  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

68}
69
70func TestLabels(t *testing.T) {
71 if runtime.GOOS == "windows" {
72 t.Skip("Windows support is TODO")
73 }
74 temp := t.TempDir()
75 testOnlyPluginPath = temp
76 t.Cleanup(func() { testOnlyPluginPath = "" })
77 ex, err := os.Executable()
78 if err != nil {
79 t.Fatal(err)
80 }
81 if err := os.Link(ex, filepath.Join(temp, "age-plugin-test")); err != nil {
82 t.Fatal(err)
83 }
84 if err := os.Chmod(filepath.Join(temp, "age-plugin-test"), 0755); err != nil {
85 t.Fatal(err)
86 }
87 if err := os.Link(ex, filepath.Join(temp, "age-plugin-testpqc")); err != nil {
88 t.Fatal(err)
89 }
90 if err := os.Chmod(filepath.Join(temp, "age-plugin-testpqc"), 0755); err != nil {
91 t.Fatal(err)
92 }
93
94 name, err := bech32.Encode("age1test", nil)
95 if err != nil {
96 t.Fatal(err)
97 }
98 testPlugin, err := NewRecipient(name, &ClientUI{})
99 if err != nil {
100 t.Fatal(err)
101 }
102 namePQC, err := bech32.Encode("age1testpqc", nil)
103 if err != nil {
104 t.Fatal(err)
105 }
106 testPluginPQC, err := NewRecipient(namePQC, &ClientUI{})
107 if err != nil {
108 t.Fatal(err)
109 }
110
111 if _, err := age.Encrypt(io.Discard, testPluginPQC); err != nil {
112 t.Errorf("expected one pqc to work, got %v", err)
113 }
114 if _, err := age.Encrypt(io.Discard, testPluginPQC, testPluginPQC); err != nil {
115 t.Errorf("expected two pqc to work, got %v", err)
116 }
117 if _, err := age.Encrypt(io.Discard, testPluginPQC, testPlugin); err == nil {
118 t.Errorf("expected one pqc and one normal to fail")
119 }
120 if _, err := age.Encrypt(io.Discard, testPlugin, testPluginPQC); err == nil {
121 t.Errorf("expected one pqc and one normal to fail")
122 }
123}
124
125func TestNotFound(t *testing.T) {
126 if runtime.GOOS == "windows" {

Callers

nothing calls this directly

Calls 3

EncodeFunction · 0.92
EncryptFunction · 0.92
NewRecipientFunction · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…