package edgeencrypt import ( "testing" "github.com/google/uuid" ) func TestEncryption(t *testing.T) { e := &EncryptedData{ BannerEdgeID: "my-banner", Channel: "my-channel", ChannelID: uuid.NewString(), KeyVersion: "1", Data: []byte("encrypted data"), } encResp, err := e.ToEncryptionResponse() if err != nil { t.Fatalf("failed to marshal EncryptedData: %v", err) } // Note: encryption response data will be used as decryption request data encryptedData, err := DecryptionRequest(encResp).ToEncryptedData() if err != nil { t.Fatalf("failed to unmarshal EncryptedData: %v", err) } if encryptedData.BannerEdgeID != e.BannerEdgeID { t.Fatalf("expected BannerEdgeID %s, got %s", e.BannerEdgeID, encryptedData.BannerEdgeID) } if encryptedData.Channel != e.Channel { t.Fatalf("expected Channel %s, got %s", e.Channel, encryptedData.Channel) } if encryptedData.ChannelID != e.ChannelID { t.Fatalf("expected ChannelID %s, got %s", e.ChannelID, encryptedData.ChannelID) } if encryptedData.KeyVersion != e.KeyVersion { t.Fatalf("expected KeyVersion %s, got %s", e.KeyVersion, encryptedData.KeyVersion) } if string(encryptedData.Data) != string(e.Data) { t.Fatalf("expected Data %s, got %s", string(e.Data), string(encryptedData.Data)) } }