mirror of
https://git.mills.io/saltyim/saltyim.git
synced 2024-06-16 03:48:24 +00:00
![mlctrez](/assets/img/avatar_default.png)
Fixes two issues cli.me.key.Private() was always nil, outbox hash was the same for everyone 👎 client.Outbox() modified Path variable on endpoint url Co-authored-by: mlctrez <mlctrez@gmail.com> Reviewed-on: https://git.mills.io/saltyim/saltyim/pulls/160 Reviewed-by: xuu <xuu@noreply@mills.io> Reviewed-by: James Mills <james@mills.io> Co-authored-by: mlctrez <mlctrez@noreply@mills.io> Co-committed-by: mlctrez <mlctrez@noreply@mills.io>
31 lines
778 B
Go
31 lines
778 B
Go
package saltyim
|
|
|
|
import (
|
|
"crypto/sha256"
|
|
"fmt"
|
|
"net/url"
|
|
"testing"
|
|
|
|
"github.com/keys-pub/keys"
|
|
"github.com/stretchr/testify/require"
|
|
)
|
|
|
|
func TestClient_Outbox(t *testing.T) {
|
|
test := require.New(t)
|
|
|
|
endpoint := &url.URL{Host: "example.com", Path: "/path", Scheme: "https"}
|
|
key := keys.GenerateEdX25519Key()
|
|
|
|
client := &Client{me: &Addr{endpoint: endpoint}, id: &Identity{key: key}}
|
|
outbox := client.Outbox()
|
|
|
|
test.True(endpoint.Path == "/path",
|
|
"endpoint.Path should not be modified after call to client.Outbox()")
|
|
test.False(*endpoint == *outbox,
|
|
"endpoint and outbox should not point to the same *url.URL")
|
|
|
|
expected := fmt.Sprintf("/%x", sha256.Sum256(key.Private()))
|
|
test.True(outbox.Path == expected, "expected %s but got %s", expected, outbox.Path)
|
|
|
|
}
|