-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(GODT-3122): server now support display name for addresses.
- Loading branch information
Showing
4 changed files
with
80 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,6 +9,50 @@ import ( | |
"github.com/stretchr/testify/require" | ||
) | ||
|
||
func TestAddress_DisplayName(t *testing.T) { | ||
s := server.New() | ||
defer s.Close() | ||
|
||
// Create a user on the server. | ||
userID, _, err := s.CreateUser("user", []byte("pass")) | ||
require.NoError(t, err) | ||
addr1, err := s.CreateAddress(userID, "[email protected]", []byte("pass")) | ||
require.NoError(t, err) | ||
require.NoError(t, s.ChangeAddressDisplayName(userID, addr1, "User 1")) | ||
|
||
addr2, err := s.CreateAddress(userID, "[email protected]", []byte("pass")) | ||
require.NoError(t, err) | ||
require.NoError(t, s.ChangeAddressDisplayName(userID, addr2, "User 2")) | ||
|
||
require.NoError(t, err) | ||
|
||
m := proton.New( | ||
proton.WithHostURL(s.GetHostURL()), | ||
proton.WithTransport(proton.InsecureTransport()), | ||
) | ||
defer m.Close() | ||
|
||
// Create one session for the user. | ||
c, auth, err := m.NewClientWithLogin(context.Background(), "user", []byte("pass")) | ||
require.NoError(t, err) | ||
require.Equal(t, userID, auth.UserID) | ||
|
||
// Get addresses for the user. | ||
addrs, err := c.GetAddresses(context.Background()) | ||
require.NoError(t, err) | ||
|
||
for _, addr := range addrs { | ||
switch addr.ID { | ||
case addr1: | ||
require.Equal(t, addr.Email, "[email protected]") | ||
require.Equal(t, addr.DisplayName, "User 1") | ||
case addr2: | ||
require.Equal(t, addr.Email, "[email protected]") | ||
require.Equal(t, addr.DisplayName, "User 2") | ||
} | ||
} | ||
} | ||
|
||
func TestAddress_Types(t *testing.T) { | ||
s := server.New() | ||
defer s.Close() | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters