diff --git a/pkg/encrypt_decrypt_test.go b/pkg/encrypt_decrypt_test.go index a680531..44f5869 100644 --- a/pkg/encrypt_decrypt_test.go +++ b/pkg/encrypt_decrypt_test.go @@ -8,7 +8,6 @@ import ( "filippo.io/age" "git.burning.moe/celediel/agedit/pkg/decrypt" "git.burning.moe/celediel/agedit/pkg/encrypt" - "git.burning.moe/celediel/agedit/pkg/identity" "git.burning.moe/celediel/agedit/pkg/tmpfile" ) @@ -142,30 +141,3 @@ func TestMultipleIdentities(t *testing.T) { }) } } - -// TestNewIdentity creats a new identity, writes it to file, then re-reads it back from the file. -func TestNewIdentity(t *testing.T) { - for range 1000 { - outfile := generator.GenerateFullPath() - - id, err := identity.NewIdentity() - if err != nil { - t.Fatal(err) - } - - err = identity.WriteIdentityToFile(id, outfile) - if err != nil { - t.Fatal(err) - } - - other_identity, err := identity.ReadIdentityFromFile(outfile) - if err != nil { - t.Fatal(err) - } - - if id.Recipient().String() != other_identity.Recipient().String() && id.String() != other_identity.String() { - t.Fatal("Identities don't match!", id.Recipient(), "!=", id.Recipient()) - } - os.Remove(outfile) - } -} diff --git a/pkg/identity/identity.go b/pkg/identity/identity.go deleted file mode 100644 index 58b8c24..0000000 --- a/pkg/identity/identity.go +++ /dev/null @@ -1,43 +0,0 @@ -package identity - -import ( - "io/fs" - "os" - - "filippo.io/age" -) - -// NewIdentity generates a new Age identity -func NewIdentity() (*age.X25519Identity, error) { - id, err := age.GenerateX25519Identity() - if err != nil { - return nil, err - } - - return id, nil -} - -// ReadIdentityFromFile reads the identity from the supplied filename -func ReadIdentityFromFile(filename string) (*age.X25519Identity, error) { - bytes, err := os.ReadFile(filename) - if err != nil { - return nil, err - } - - id, err := age.ParseX25519Identity(string(bytes)) - if err != nil { - return nil, err - } - - return id, nil -} - -// WriteIdentityToFile writes the supplied identity to the supplied filename -func WriteIdentityToFile(id *age.X25519Identity, filename string) error { - err := os.WriteFile(filename, []byte(id.String()), fs.FileMode(0600)) - if err != nil { - return err - } - - return nil -}