-
Notifications
You must be signed in to change notification settings - Fork 384
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
feat/CXSPA-7935:Modify the OCC API endpoint for SPA consumes(#19141) #19141
Changes from all commits
c54bc87
a88ddd0
bbe404c
88cd3ce
811c6ef
cb9f1aa
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -233,16 +233,15 @@ describe('OccUserProfileAdapter', () => { | |||||
.subscribe((result) => expect(result).toEqual('')); | ||||||
|
||||||
const mockReq = httpMock.expectOne((req) => { | ||||||
return ( | ||||||
req.method === 'POST' && | ||||||
req.serializeBody() === `userId=${testUserId}` | ||||||
); | ||||||
return req.method === 'POST' && req.url === '/userRestoreToken'; | ||||||
}); | ||||||
|
||||||
expect(occEndpointsService.buildUrl).toHaveBeenCalledWith( | ||||||
'userForgotPassword' | ||||||
'userRestoreToken' | ||||||
); | ||||||
|
||||||
expect(mockReq.cancelled).toBeFalsy(); | ||||||
expect(mockReq.request.body).toEqual({ loginId: testUserId }); | ||||||
mockReq.flush(''); | ||||||
}); | ||||||
}); | ||||||
|
@@ -301,28 +300,24 @@ describe('OccUserProfileAdapter', () => { | |||||
const currentPassword = 'Qwe123!'; | ||||||
const newUserId = '[email protected]'; | ||||||
|
||||||
let result: Object; | ||||||
|
||||||
occUserAdapter | ||||||
.updateEmail(userId, currentPassword, newUserId) | ||||||
.subscribe((value) => (result = value)); | ||||||
.subscribe(); | ||||||
|
||||||
const mockReq = httpMock.expectOne((req) => { | ||||||
return ( | ||||||
req.method === 'PUT' && | ||||||
req.serializeBody() === | ||||||
`password=${currentPassword}&newLogin=${newUserId}` | ||||||
); | ||||||
return req.method === 'POST' && req.url === '/userUpdateLoginId'; | ||||||
}); | ||||||
|
||||||
expect(occEndpointsService.buildUrl).toHaveBeenCalledWith( | ||||||
'userUpdateLoginId', | ||||||
{ urlParams: { userId } } | ||||||
); | ||||||
expect(mockReq.cancelled).toBeFalsy(); | ||||||
|
||||||
expect(mockReq.request.body).toEqual({ | ||||||
newLoginId: newUserId, | ||||||
password: currentPassword, | ||||||
}); | ||||||
mockReq.flush(''); | ||||||
expect(result).toEqual(''); | ||||||
}); | ||||||
}); | ||||||
|
||||||
|
@@ -332,17 +327,12 @@ describe('OccUserProfileAdapter', () => { | |||||
const oldPassword = 'OldPass123!'; | ||||||
const newPassword = 'NewPass456!'; | ||||||
|
||||||
let result: Object; | ||||||
|
||||||
occUserAdapter | ||||||
.updatePassword(userId, oldPassword, newPassword) | ||||||
.subscribe((value) => (result = value)); | ||||||
.subscribe(); | ||||||
|
||||||
const mockReq = httpMock.expectOne((req) => { | ||||||
return ( | ||||||
req.method === 'PUT' && | ||||||
req.serializeBody() === `old=${oldPassword}&new=${newPassword}` | ||||||
); | ||||||
return req.method === 'POST' && req.url === '/userUpdatePassword'; | ||||||
}); | ||||||
|
||||||
expect(occEndpointsService.buildUrl).toHaveBeenCalledWith( | ||||||
|
@@ -351,8 +341,11 @@ describe('OccUserProfileAdapter', () => { | |||||
); | ||||||
|
||||||
expect(mockReq.cancelled).toBeFalsy(); | ||||||
expect(mockReq.request.body).toEqual({ | ||||||
oldPassword: oldPassword, | ||||||
newPassword: newPassword, | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
}); | ||||||
mockReq.flush(''); | ||||||
expect(result).toEqual(''); | ||||||
}); | ||||||
}); | ||||||
|
||||||
|
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -96,16 +96,11 @@ export class OccUserProfileAdapter implements UserProfileAdapter { | |||||
} | ||||||
|
||||||
requestForgotPasswordEmail(userEmailAddress: string): Observable<unknown> { | ||||||
const url = this.occEndpoints.buildUrl('userForgotPassword'); | ||||||
const httpParams: HttpParams = new HttpParams().set( | ||||||
'userId', | ||||||
userEmailAddress | ||||||
); | ||||||
let headers = new HttpHeaders({ | ||||||
...CONTENT_TYPE_URLENCODED_HEADER, | ||||||
}); | ||||||
const url = this.occEndpoints.buildUrl('userRestoreToken'); | ||||||
const body = { loginId: userEmailAddress }; | ||||||
let headers = new HttpHeaders(CONTENT_TYPE_JSON_HEADER); | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
headers = InterceptorUtil.createHeader(USE_CLIENT_TOKEN, true, headers); | ||||||
return this.http.post(url, httpParams, { headers }).pipe( | ||||||
return this.http.post(url, body, { headers }).pipe( | ||||||
catchError((error) => { | ||||||
throw normalizeHttpError(error, this.logger); | ||||||
}) | ||||||
|
@@ -134,13 +129,12 @@ export class OccUserProfileAdapter implements UserProfileAdapter { | |||||
const url = this.occEndpoints.buildUrl('userUpdateLoginId', { | ||||||
urlParams: { userId }, | ||||||
}); | ||||||
const httpParams: HttpParams = new HttpParams() | ||||||
.set('password', currentPassword) | ||||||
.set('newLogin', newUserId); | ||||||
const headers = new HttpHeaders({ | ||||||
...CONTENT_TYPE_URLENCODED_HEADER, | ||||||
}); | ||||||
return this.http.put(url, httpParams, { headers }).pipe( | ||||||
const body = { | ||||||
newLoginId: newUserId, | ||||||
password: currentPassword, | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
}; | ||||||
const headers = new HttpHeaders(CONTENT_TYPE_JSON_HEADER); | ||||||
return this.http.post(url, body, { headers }).pipe( | ||||||
catchError((error) => { | ||||||
throw normalizeHttpError(error, this.logger); | ||||||
}) | ||||||
|
@@ -155,13 +149,12 @@ export class OccUserProfileAdapter implements UserProfileAdapter { | |||||
const url = this.occEndpoints.buildUrl('userUpdatePassword', { | ||||||
urlParams: { userId }, | ||||||
}); | ||||||
const httpParams: HttpParams = new HttpParams() | ||||||
.set('old', oldPassword) | ||||||
.set('new', newPassword); | ||||||
const headers = new HttpHeaders({ | ||||||
...CONTENT_TYPE_URLENCODED_HEADER, | ||||||
}); | ||||||
return this.http.put(url, httpParams, { headers }).pipe( | ||||||
const body = { | ||||||
oldPassword: oldPassword, | ||||||
newPassword: newPassword, | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
}; | ||||||
const headers = new HttpHeaders(CONTENT_TYPE_JSON_HEADER); | ||||||
return this.http.post(url, body, { headers }).pipe( | ||||||
catchError((error) => { | ||||||
throw normalizeHttpError(error, this.logger); | ||||||
}) | ||||||
|
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.