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

MG-2051 - Fix unable to reset user password #2052

Closed
wants to merge 72 commits into from
Closed
Show file tree
Hide file tree
Changes from 2 commits
Commits
Show all changes
72 commits
Select commit Hold shift + click to select a range
b589429
MG-2051 - Fixed unable to reset user password
Jan 10, 2024
f0e7989
MG-2051 - Reset secret tests
Jan 11, 2024
293fc1b
MG-2051 - Reset secret tests
Jan 11, 2024
ca49888
NOISSUE - Add group service tests (#241)
rodneyosodo Jan 10, 2024
73a2c07
MG-1968 - List all status domains by default (#248)
arvindh123 Jan 10, 2024
97432fd
NOISSUE - Increase minimum docker-compose version in README.md (#260)
chaevan Jan 10, 2024
4375254
NOISSUE - Resolve falsely passing CI (#214)
Musilah Jan 10, 2024
7776e24
MG-1961 - Add Domains OpenAPI Spec (#261)
arvindh123 Jan 10, 2024
a10ab93
MG-1967 - Handle errors in Things gRPC server and client (#257)
arvindh123 Jan 10, 2024
32d43b1
NOISSUE - List Permissions when listing Users (#269)
arvindh123 Jan 10, 2024
d16e9ad
NOISSUE - Add pagemetadata to ReadMessage function in sdk (#2055)
ianmuchyri Jan 10, 2024
52b650f
NOISSUE - Fix Domain listing and updating (#271)
arvindh123 Jan 12, 2024
53d5e8b
NOISSUE - Add group API tests (#243)
rodneyosodo Jan 12, 2024
8237312
NOISSUE - Add tests for pkg/clients (#258)
rodneyosodo Jan 16, 2024
da8ab37
NOISSUE - Fix Compose With v2.24.0 (#273)
rodneyosodo Jan 18, 2024
b658847
NOISSUE - Use methods for accessing in generated code (#204)
rodneyosodo Jan 18, 2024
1b9d11a
MG-234 - Improve Logging (#255)
Musilah Jan 18, 2024
08ab338
NOISSUE - Improve tests in things service (#200)
felixgateru Jan 18, 2024
e89cd59
NOISSUE - Improve tests in users service (#194)
felixgateru Jan 18, 2024
8631318
NOISSUE - Limit Max Traces kept in-memory by Jaeger all-in-one (#259)
chaevan Jan 19, 2024
eba62a8
NOISSUE - Bug Fix on Listing Things (#274)
rodneyosodo Jan 19, 2024
e4bbdf6
NOISSUE - Update VerneMQ build scripts (#2058)
dborovcanin Jan 19, 2024
cd27330
NOISSUE - Update dependencies (#2061)
dborovcanin Jan 23, 2024
5eb9592
NOISSUE - Revert Mosquitto broker version in MQTT tests (#2063)
dborovcanin Jan 24, 2024
e69b69f
NOISSUE - Use VerneMQ as the dafault MQTT broker (#2064)
dborovcanin Jan 24, 2024
0e5ba6f
MG-234 - Improve Logging Middleware (#272)
Musilah Jan 24, 2024
6f1fb12
NOISSUE - Improve tests in Auth service (#262)
felixgateru Jan 25, 2024
95c4cc5
NOISSUE - Replace docs link in API docs
dborovcanin Jan 25, 2024
48379d6
NOISSUE - Replace deprecated gRPC instrumentation method (#278)
SammyOina Jan 25, 2024
64a1672
NOISSUE - Make Check Interval Configurable (#277)
rodneyosodo Jan 25, 2024
c3742aa
NOISSUE - Update CallHome version (#2066)
dborovcanin Jan 26, 2024
79d089d
NOISSUE - Fix Listing of things connected to a channel (#279)
arvindh123 Jan 26, 2024
ede1b39
NOISSUE - Fix messaging handler logger (#280)
arvindh123 Jan 26, 2024
c74c86d
MG-104: Rename/Replace filed owner with domain (#268)
arvindh123 Jan 27, 2024
56ed2c2
NOISSUE - Simplify docker deployment (#275)
rodneyosodo Jan 29, 2024
5c88207
NOISSUE - Replace deprecated gRPC metrics collection with stats handl…
SammyOina Jan 29, 2024
bd0f859
NOISSUE - Remove CHANGELOG (#2067)
dborovcanin Jan 29, 2024
4635b14
NOISSUE - Bump github.com/opencontainers/runc from 1.1.10 to 1.1.12 (…
dependabot[bot] Feb 12, 2024
e882cd5
NOISSUE - Pin the version of `golangci-lint` (#2077)
rodneyosodo Feb 12, 2024
30b741b
NOISSUE - Add Postgres DB for UI (#2082)
rodneyosodo Feb 15, 2024
de3481f
NOISSUE - Fix provision configuration loading (#2078)
arvindh123 Feb 19, 2024
aafff21
NOISSUE - Fix Bootstrap thing creation flow (#2083)
arvindh123 Feb 19, 2024
84a1ca9
NOISSUE - Vault operations with app role authentication (#2084)
arvindh123 Feb 20, 2024
ee8d24d
NOISSUE - Remove duplicate errors (#2086)
rodneyosodo Feb 21, 2024
6745435
NOIISUE - Update Vault setup scripts to support Vault CLI (#2091)
arvindh123 Feb 22, 2024
0e49c12
NOISSUE : Add Domain routes in Nginx x509 conf (#2100)
arvindh123 Feb 22, 2024
17a9d36
NOISSUE - Fix panic during revocation of expired certificate (#2101)
arvindh123 Feb 23, 2024
233ecfa
NOISSUE - Add job for checking `go.mod` changes (#2097)
rodneyosodo Feb 23, 2024
e36919b
NOISSUE - Fix assign and unassign commands in CLI (#2102)
arvindh123 Feb 26, 2024
5d54aa8
NOISSUE - Add Event Subscriber Config (#2054)
rodneyosodo Feb 26, 2024
f116e28
MG-1887 - Add support for OAuth2.0 (#2103)
rodneyosodo Mar 1, 2024
292c08b
NOISSUE - Update UI service env variables (#2105)
ianmuchyri Mar 4, 2024
145fdb3
NOISSUE - Update timescale reader (#2085)
Musilah Mar 5, 2024
49d25af
NOISSUE - Update UI environment variables (#2107)
ianmuchyri Mar 7, 2024
2200a2d
NOISSUE - Bump github.com/go-jose/go-jose/v3 from 3.0.1 to 3.0.3 (#2108)
dependabot[bot] Mar 8, 2024
6929ea4
NOISSUE - Update Aggregation SQL query (#2111)
ianmuchyri Mar 12, 2024
110ac4b
NOISSUE - Bump github.com/lestrrat-go/jwx/v2 from 2.0.19 to 2.0.21 (#…
dependabot[bot] Mar 12, 2024
b6a1cb8
NOISSUE - Add Secret Validation on Registration (#2109)
rodneyosodo Mar 13, 2024
291c2a3
NOISSUE - Bump google.golang.org/protobuf from 1.32.0 to 1.33.0 (#2112)
dependabot[bot] Mar 14, 2024
7ee657c
NOISSUE - Remove OAuth2.0 tokens from Magistrala token (#2106)
rodneyosodo Mar 14, 2024
6e6dfba
NOISSUE - Bump github.com/jackc/pgx/v5 from 5.5.2 to 5.5.4 (#2116)
dependabot[bot] Mar 15, 2024
887072f
NOISSUE - Convert SenML Payload Time To UnixNano (#2115)
rodneyosodo Mar 15, 2024
441d3a7
NOISSUE - Add Domain URL to CLI and SDK configuration (#2118)
arvindh123 Mar 20, 2024
f5d0c41
NOISSUE - Add property based testing to users service (#2087)
rodneyosodo Mar 22, 2024
698d213
NOISSUE - Bump github.com/docker/docker from 24.0.7+incompatible to 2…
dependabot[bot] Mar 26, 2024
0f4a709
NOISSUE - Fix Timescale Reader query (#2120)
ianmuchyri Mar 26, 2024
097b547
NOISSUE - Fix OPC-UA adapter (#2114)
WashingtonKK Apr 1, 2024
a5c7d8e
NOISSUE - Fix links in README.md file (#2129)
dborovcanin Apr 3, 2024
4c4217d
NOISSUE - Fix Failing Users Property Based Tests (#2134)
rodneyosodo Apr 3, 2024
9ffbc5e
MG-2125 - Unable to enable thing using bootstrap (#2132)
JeffMboya Apr 3, 2024
834dd56
Reset secret tests
Apr 3, 2024
3fec0a5
Merge branch 'main' into MG-2051
VeddySama Apr 3, 2024
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
5 changes: 3 additions & 2 deletions users/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -317,12 +317,13 @@ func (svc service) ResetSecret(ctx context.Context, resetToken, secret string) e
return err
}
c = mgclients.Client{
ID: id,
Credentials: mgclients.Credentials{
Identity: c.Credentials.Identity,
Secret: secret,
Secret: secret,
},
UpdatedAt: time.Now(),
UpdatedBy: id,
Status: c.Status,
}
if _, err := svc.clients.UpdateSecret(ctx, c); err != nil {
return errors.Wrap(svcerr.ErrAuthorization, err)
Expand Down
64 changes: 64 additions & 0 deletions users/service_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1451,6 +1451,70 @@ func TestRefreshToken(t *testing.T) {
}
}

func TestResetSecret(t *testing.T) {
cRepo := new(mocks.Repository)
auth := new(authmocks.Service)
e := mocks.NewEmailer()
svc := users.NewService(cRepo, auth, e, phasher, idProvider, passRegex, true)

cases := []struct {
desc string
resetToken string
secret string
client mgclients.Client
err error
}{
{
desc: "reset secret with valid reset token for an existing client",
resetToken: validToken,
client: client,
secret: "newSecret",
arvindh123 marked this conversation as resolved.
Show resolved Hide resolved
err: nil,
},
{
desc: "reset secret with valid reset token for an non-existing client",
resetToken: validToken,
client: mgclients.Client{},
secret: "newSecret",
err: repoerr.ErrNotFound,
},
{
desc: "reset secret with wrong password format for an existing client",
resetToken: validToken,
client: client,
secret: "secret",
err: errors.ErrAuthentication,
},
{
desc: "reset secret with invalid reset token for an existing client",
resetToken: inValidToken,
client: client,
secret: "newSecret",
err: svcerr.ErrAuthentication,
},
}

for _, tc := range cases {
repoCall := auth.On("Identify", mock.Anything, &magistrala.IdentityReq{Token: validToken}).Return(&magistrala.IdentityRes{UserId: client.ID}, nil)
if tc.resetToken == inValidToken {
repoCall = auth.On("Identify", mock.Anything, &magistrala.IdentityReq{Token: inValidToken}).Return(&magistrala.IdentityRes{}, svcerr.ErrAuthentication)
}
repoCall1 := cRepo.On("RetrieveByID", context.Background(), client.ID).Return(tc.client, tc.err)
repoCall2 := cRepo.On("UpdateSecret", context.Background(), mock.Anything).Return(tc.client, tc.err)
err := svc.ResetSecret(context.Background(), tc.resetToken, tc.secret)
assert.True(t, errors.Contains(err, tc.err), fmt.Sprintf("%s: expected %s got %s\n", tc.desc, tc.err, err))
if tc.err == nil {
ok := repoCall1.Parent.AssertCalled(t, "RetrieveByID", context.Background(), tc.client.ID)
assert.True(t, ok, fmt.Sprintf("RetrieveByID was not called on %s", tc.desc))
ok = repoCall2.Parent.AssertCalled(t, "UpdateSecret", context.Background(), mock.Anything)
assert.True(t, ok, fmt.Sprintf("UpdateSecret was not called on %s", tc.desc))
}
repoCall.Unset()
repoCall1.Unset()
repoCall2.Unset()
}
}

func clientsToUUIDs(clients []mgclients.Client) []string {
ids := []string{}
for _, c := range clients {
Expand Down