(t *testing.T)
| 272 | } |
| 273 | |
| 274 | func TestLabels(t *testing.T) { |
| 275 | scrypt, err := age.NewScryptRecipient("xxx") |
| 276 | if err != nil { |
| 277 | t.Fatal(err) |
| 278 | } |
| 279 | i, err := age.GenerateX25519Identity() |
| 280 | if err != nil { |
| 281 | t.Fatal(err) |
| 282 | } |
| 283 | x25519 := i.Recipient() |
| 284 | pqc := testRecipient{[]string{"postquantum"}} |
| 285 | pqcAndFoo := testRecipient{[]string{"postquantum", "foo"}} |
| 286 | fooAndPQC := testRecipient{[]string{"foo", "postquantum"}} |
| 287 | |
| 288 | if _, err := age.Encrypt(io.Discard, scrypt, scrypt); err == nil { |
| 289 | t.Error("expected two scrypt recipients to fail") |
| 290 | } |
| 291 | if _, err := age.Encrypt(io.Discard, scrypt, x25519); err == nil { |
| 292 | t.Error("expected x25519 mixed with scrypt to fail") |
| 293 | } |
| 294 | if _, err := age.Encrypt(io.Discard, x25519, scrypt); err == nil { |
| 295 | t.Error("expected x25519 mixed with scrypt to fail") |
| 296 | } |
| 297 | if _, err := age.Encrypt(io.Discard, pqc, x25519); err == nil { |
| 298 | t.Error("expected x25519 mixed with pqc to fail") |
| 299 | } |
| 300 | if _, err := age.Encrypt(io.Discard, x25519, pqc); err == nil { |
| 301 | t.Error("expected x25519 mixed with pqc to fail") |
| 302 | } |
| 303 | if _, err := age.Encrypt(io.Discard, pqc, pqc); err != nil { |
| 304 | t.Errorf("expected two pqc to work, got %v", err) |
| 305 | } |
| 306 | if _, err := age.Encrypt(io.Discard, pqc); err != nil { |
| 307 | t.Errorf("expected one pqc to work, got %v", err) |
| 308 | } |
| 309 | if _, err := age.Encrypt(io.Discard, pqcAndFoo, pqc); err == nil { |
| 310 | t.Error("expected pqc+foo mixed with pqc to fail") |
| 311 | } |
| 312 | if _, err := age.Encrypt(io.Discard, pqc, pqcAndFoo); err == nil { |
| 313 | t.Error("expected pqc+foo mixed with pqc to fail") |
| 314 | } |
| 315 | if _, err := age.Encrypt(io.Discard, pqc, pqc, pqcAndFoo); err == nil { |
| 316 | t.Error("expected pqc+foo mixed with pqc to fail") |
| 317 | } |
| 318 | if _, err := age.Encrypt(io.Discard, pqcAndFoo, pqcAndFoo); err != nil { |
| 319 | t.Errorf("expected two pqc+foo to work, got %v", err) |
| 320 | } |
| 321 | if _, err := age.Encrypt(io.Discard, pqcAndFoo, fooAndPQC); err != nil { |
| 322 | t.Errorf("expected pqc+foo mixed with foo+pqc to work, got %v", err) |
| 323 | } |
| 324 | } |
| 325 | |
| 326 | // testIdentity is a non-native identity that records if Unwrap is called. |
| 327 | type testIdentity struct { |
nothing calls this directly
no test coverage detected
searching dependent graphs…