-
Notifications
You must be signed in to change notification settings - Fork 674
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
MF-1516 - Fix API key issuing #1530
Conversation
Signed-off-by: Filip Bugarski <filipbugarski@gmail.com>
Signed-off-by: Filip Bugarski <filipbugarski@gmail.com>
Codecov Report
@@ Coverage Diff @@
## master #1530 +/- ##
=======================================
Coverage 67.60% 67.61%
=======================================
Files 133 133
Lines 10930 10933 +3
=======================================
+ Hits 7389 7392 +3
+ Misses 2937 2936 -1
- Partials 604 605 +1
Continue to review full report at Codecov.
|
auth/service.go
Outdated
@@ -167,7 +167,15 @@ func (svc service) Identify(ctx context.Context, token string) (Identity, error) | |||
} | |||
|
|||
switch key.Type { | |||
case APIKey, RecoveryKey, UserKey: | |||
case RecoveryKey, LoginKey: | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove the empty line.
auth/service.go
Outdated
|
||
return Identity{ID: key.IssuerID, Email: key.Subject}, nil | ||
case APIKey: | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here.
Signed-off-by: Filip Bugarski <filipbugarski@gmail.com>
Signed-off-by: Filip Bugarski <filipbugarski@gmail.com>
auth/api/http/keys/endpoint_test.go
Outdated
|
||
ts := newServer(svc) | ||
defer ts.Close() | ||
client := ts.Client() | ||
|
||
uk := issueRequest{Type: auth.UserKey} | ||
uk := issueRequest{Type: auth.LoginKey} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
uk
can be changed to lk
@@ -104,11 +104,11 @@ func TestIssue(t *testing.T) { | |||
status int | |||
}{ | |||
{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Status Created case is missing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Line 118
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Line 118 have test for ak
- api key
But in master
the there is test case for user key
aka login key
https://github.com/mainflux/mainflux/blob/ad8b7ddf5afac43699f7080d006dd40de0559222/auth/api/http/keys/endpoint_test.go#L107
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You cant create login key over HTTP API anymore.
auth/service_test.go
Outdated
@@ -58,7 +58,7 @@ func TestIssue(t *testing.T) { | |||
{ | |||
desc: "issue user key", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Description can be changed to issue login key
auth/service_test.go
Outdated
@@ -67,7 +67,7 @@ func TestIssue(t *testing.T) { | |||
{ | |||
desc: "issue user key with no time", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Description shall be changed to login key
auth/service_test.go
Outdated
@@ -180,7 +180,7 @@ func TestRetrieve(t *testing.T) { | |||
IssuedAt: time.Now(), | |||
} | |||
|
|||
_, userToken, err := svc.Issue(context.Background(), "", auth.Key{Type: auth.UserKey, IssuedAt: time.Now(), IssuerID: id, Subject: email}) | |||
_, userToken, err := svc.Issue(context.Background(), "", auth.Key{Type: auth.LoginKey, IssuedAt: time.Now(), IssuerID: id, Subject: email}) | |||
assert.Nil(t, err, fmt.Sprintf("Issuing user key expected to succeed: %s", err)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
user key
shall be changed to login key
and also in line number 187
Signed-off-by: Filip Bugarski <filipbugarski@gmail.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
* Fix API keys saving Signed-off-by: Filip Bugarski <filipbugarski@gmail.com> * Fix API key creation Signed-off-by: Filip Bugarski <filipbugarski@gmail.com> * Fix tests Signed-off-by: Filip Bugarski <filipbugarski@gmail.com> * Delete empty lines Signed-off-by: Filip Bugarski <filipbugarski@gmail.com> * Remove empty lines Signed-off-by: Filip Bugarski <filipbugarski@gmail.com> * Fix typo Signed-off-by: Filip Bugarski <filipbugarski@gmail.com> * Change user key to login key Signed-off-by: Filip Bugarski <filipbugarski@gmail.com> Signed-off-by: skovacevic <stefan.kovacevic@mainflux.io>
Signed-off-by: Filip Bugarski filipbugarski@gmail.com
What does this do?
This pull request fixes issue with storing Mainflux API keys.
Which issue(s) does this PR fix/relate to?
Fixes #1516.
List any changes that modify/break current functionality
The only API key can be created by the user HTTP API.
Have you included tests for your changes?
Yes. Tests are fixed to match new changes.
Did you document any new/modified functionality?
Yes.
Notes
N/A