Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fix tests
  • Loading branch information
lunny committed Jun 8, 2021
commit 1b39dc74f7bfd2ebb85e1e5df348eb399ffb2f99
8 changes: 4 additions & 4 deletions integrations/api_gpg_keys_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ type makeRequestFunc func(testing.TB, *http.Request, int) *httptest.ResponseReco

func TestGPGKeys(t *testing.T) {
defer prepareTestEnv(t)()
session := loginUser(t, "user2")
session := loginUser(t, "user21")
token := getTokenForLoggedInUser(t, session)

tt := []struct {
Expand Down Expand Up @@ -89,7 +89,7 @@ func TestGPGKeys(t *testing.T) {
primaryKey2 := keys[1] //Primary key 2
assert.EqualValues(t, "FABF39739FE1E927", primaryKey2.KeyID)
assert.Len(t, primaryKey2.Emails, 1)
assert.EqualValues(t, "user21@example.com", primaryKey2.Emails[0].Email)
assert.EqualValues(t, "user2-2@example.com", primaryKey2.Emails[0].Email)
assert.False(t, primaryKey2.Emails[0].Verified)

var key api.GPGKey
Expand All @@ -112,7 +112,7 @@ func TestGPGKeys(t *testing.T) {
DecodeJSON(t, resp, &key)
assert.EqualValues(t, "FABF39739FE1E927", key.KeyID)
assert.Len(t, key.Emails, 1)
assert.EqualValues(t, "user21@example.com", key.Emails[0].Email)
assert.EqualValues(t, "user2-2@example.com", key.Emails[0].Email)
assert.False(t, key.Emails[0].Verified)

})
Expand Down Expand Up @@ -231,7 +231,7 @@ uy6MA3VSB99SK9ducGmE1Jv8mcziREroz2TEGr0zPs6h
}

func testCreateValidSecondaryEmailGPGKey(t *testing.T, makeRequest makeRequestFunc, token string, expected int) {
//User2 <user21@example.com> //secondary and not activated
//User2 <user2-2@example.com> //secondary and not activated
testCreateGPGKey(t, makeRequest, token, expected, `-----BEGIN PGP PUBLIC KEY BLOCK-----

mQENBFmGWN4BCAC18V4tVGO65VLCV7p14FuXJlUtZ5CuYMvgEkcOqrvRaBSW9ao4
Expand Down
10 changes: 5 additions & 5 deletions integrations/api_user_email_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ func TestAPIListEmails(t *testing.T) {
Primary: true,
},
{
Email: "user21@example.com",
Email: "user2-2@example.com",
Verified: false,
Primary: false,
},
Expand All @@ -55,7 +55,7 @@ func TestAPIAddEmail(t *testing.T) {
session.MakeRequest(t, req, http.StatusUnprocessableEntity)

opts = api.CreateEmailOption{
Emails: []string{"user22@example.com"},
Emails: []string{"user2-3@example.com"},
}
req = NewRequestWithJSON(t, "POST", "/api/v1/user/emails?token="+token, &opts)
resp := session.MakeRequest(t, req, http.StatusCreated)
Expand All @@ -64,7 +64,7 @@ func TestAPIAddEmail(t *testing.T) {
DecodeJSON(t, resp, &emails)
assert.EqualValues(t, []*api.Email{
{
Email: "user22@example.com",
Email: "user2-3@example.com",
Verified: true,
Primary: false,
},
Expand All @@ -79,13 +79,13 @@ func TestAPIDeleteEmail(t *testing.T) {
token := getTokenForLoggedInUser(t, session)

opts := api.DeleteEmailOption{
Emails: []string{"user22@example.com"},
Emails: []string{"user2-3@example.com"},
}
req := NewRequestWithJSON(t, "DELETE", "/api/v1/user/emails?token="+token, &opts)
session.MakeRequest(t, req, http.StatusNotFound)

opts = api.DeleteEmailOption{
Emails: []string{"user21@example.com"},
Emails: []string{"user2-2@example.com"},
}
req = NewRequestWithJSON(t, "DELETE", "/api/v1/user/emails?token="+token, &opts)
session.MakeRequest(t, req, http.StatusNoContent)
Expand Down
2 changes: 1 addition & 1 deletion models/gpg_key.go
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,7 @@ func parseGPGKey(ownerID int64, e *openpgp.Entity) (*GPGKey, error) {
}
email := strings.ToLower(strings.TrimSpace(ident.UserId.Email))
for _, e := range userEmails {
if e.Email == email {
if e.LowerEmail == email {
emails = append(emails, e)
break
}
Expand Down