Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change "password" term with "passphrase" to unify naming #109

Merged
merged 1 commit into from Jan 22, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 3 additions & 3 deletions cmd/mysterium_client/cli/command.go
Expand Up @@ -33,7 +33,7 @@ type Command struct {
}

const redColor = "\033[31m%s\033[0m"
const identityDefaultPassword = ""
const identityDefaultPassphrase = ""

// Run starts CLI interface
func (c *Command) Run() (err error) {
Expand Down Expand Up @@ -126,7 +126,7 @@ func (c *Command) connect(line string) {
consumerId, providerId := identities[0], identities[1]

if consumerId == "new" {
id, err := c.tequilapi.NewIdentity(identityDefaultPassword)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But unlock passphrase should be taken from Options.IdentityPassphrase.
And Golang will default this option to "", You dont need constant for that

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is no Options here - it's CLI. It should be passed in a command identity new mypassphrase - I've already created a subtask for that https://mysteriumnetwork.atlassian.net/browse/MYST-265. This subtask is only about renaming.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

clear

id, err := c.tequilapi.NewIdentity(identityDefaultPassphrase)
if err != nil {
warn(err)
return
Expand Down Expand Up @@ -232,7 +232,7 @@ func (c *Command) identities(line string) {
}

if action == "new" {
id, err := c.tequilapi.NewIdentity(identityDefaultPassword)
id, err := c.tequilapi.NewIdentity(identityDefaultPassphrase)
if err != nil {
warn(err)
return
Expand Down
2 changes: 1 addition & 1 deletion identity/manager.go
@@ -1,5 +1,5 @@
// Maps Ethereum account to dto.Identity.
// Currently creates a new eth account with password on CreateNewIdentity().
// Currently creates a new eth account with passphrase on CreateNewIdentity().

package identity

Expand Down
6 changes: 3 additions & 3 deletions tequilapi/client/client.go
Expand Up @@ -36,11 +36,11 @@ func (client *Client) GetIdentities() (ids []IdentityDto, err error) {
}

// NewIdentity creates a new client identity
func (client *Client) NewIdentity(password string) (id IdentityDto, err error) {
func (client *Client) NewIdentity(passphrase string) (id IdentityDto, err error) {
payload := struct {
Password string `json:"password"`
Passphrase string `json:"passphrase"`
}{
password,
passphrase,
}
response, err := client.http.Post("identities", payload)
if err != nil {
Expand Down
8 changes: 4 additions & 4 deletions tequilapi/endpoints/identities.go
Expand Up @@ -21,7 +21,7 @@ type identityList struct {
}

type identityCreationDto struct {
Password *string `json:"password"`
Passphrase *string `json:"passphrase"`
}

type identityRegistrationDto struct {
Expand Down Expand Up @@ -73,7 +73,7 @@ func (endpoint *identitiesApi) Create(resp http.ResponseWriter, request *http.Re
utils.SendValidationErrorMessage(resp, errorMap)
return
}
id, err := endpoint.idm.CreateNewIdentity(*createReq.Password)
id, err := endpoint.idm.CreateNewIdentity(*createReq.Passphrase)
if err != nil {
utils.SendError(resp, err, http.StatusInternalServerError)
return
Expand Down Expand Up @@ -151,8 +151,8 @@ func validateRegistrationRequest(regReq identityRegistrationDto) (err error) {

func validateCreationRequest(createReq *identityCreationDto) (errors *validation.FieldErrorMap) {
errors = validation.NewErrorMap()
if createReq.Password == nil {
errors.ForField("password").AddError("required", "Field is required")
if createReq.Passphrase == nil {
errors.ForField("passphrase").AddError("required", "Field is required")
}
return
}
Expand Down
10 changes: 5 additions & 5 deletions tequilapi/endpoints/identities_test.go
Expand Up @@ -122,12 +122,12 @@ func TestUnlockFailure(t *testing.T) {
assert.Equal(t, "mypassphrase", mockIdm.LastUnlockPassphrase)
}

func TestCreateNewIdentityEmptyPassword(t *testing.T) {
func TestCreateNewIdentityEmptyPassphrase(t *testing.T) {
mockIdm := identity.NewIdentityManagerFake(existingIdentities, newIdentity)
req, err := http.NewRequest(
http.MethodPost,
"/identities",
bytes.NewBufferString(`{"password": ""}`),
bytes.NewBufferString(`{"passphrase": ""}`),
)

assert.Nil(t, err)
Expand All @@ -139,7 +139,7 @@ func TestCreateNewIdentityEmptyPassword(t *testing.T) {
assert.Equal(t, http.StatusOK, resp.Code)
}

func TestCreateNewIdentityNoPassword(t *testing.T) {
func TestCreateNewIdentityNoPassphrase(t *testing.T) {
mockIdm := identity.NewIdentityManagerFake(existingIdentities, newIdentity)
req, err := http.NewRequest(
http.MethodPost,
Expand All @@ -159,7 +159,7 @@ func TestCreateNewIdentityNoPassword(t *testing.T) {
`{
"message": "validation_error",
"errors" : {
"password": [ {"code" : "required" , "message" : "Field is required" } ]
"passphrase": [ {"code" : "required" , "message" : "Field is required" } ]
}
}`,
resp.Body.String(),
Expand All @@ -171,7 +171,7 @@ func TestCreateNewIdentity(t *testing.T) {
req, err := http.NewRequest(
http.MethodPost,
"/identities",
bytes.NewBufferString(`{"password": "mypass"}`),
bytes.NewBufferString(`{"passphrase": "mypass"}`),
)
assert.Nil(t, err)

Expand Down