Skip to content

Commit

Permalink
feat: Adding a MockAuthService, improving docs (#92)
Browse files Browse the repository at this point in the history
The mock auth service uses axios-mock-adapter in its implementation to allow mocking of any http client calls the auth service might make on behalf of an application.

This PR also fleshes out the docs for the auth service to try to add some detail around the differences between the interface, AxiosJwtAuthService, and new MockAuthService implementations.
  • Loading branch information
davidjoy authored Jun 9, 2020
1 parent db97454 commit da4dc1b
Show file tree
Hide file tree
Showing 8 changed files with 339 additions and 22 deletions.
21 changes: 5 additions & 16 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@
"@commitlint/config-angular": "8.2.0",
"@edx/frontend-build": "2.0.6",
"@edx/paragon": "7.1.5",
"axios-mock-adapter": "1.17.0",
"babel-polyfill": "6.26.0",
"codecov": "3.6.5",
"enzyme": "3.10.0",
Expand All @@ -53,6 +52,7 @@
"dependencies": {
"@cospired/i18n-iso-languages": "2.1.2",
"axios": "0.18.1",
"axios-mock-adapter": "1.17.0",
"form-urlencoded": "4.1.4",
"glob": "7.1.6",
"history": "4.10.1",
Expand Down
10 changes: 5 additions & 5 deletions src/auth/AxiosJwtAuthService.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,18 +62,19 @@ class AxiosJwtAuthService {
}

/**
* Gets the authenticated HTTP client singleton which is an axios instance.
* Gets the authenticated HTTP client for the service. This is an axios instance.
*
* @returns {HttpClient} Singleton. A configured axios http client
* @returns {HttpClient} A configured axios http client which can be used for authenticated
* requests.
*/
getAuthenticatedHttpClient() {
return this.authenticatedHttpClient;
}

/**
* Gets the unauthenticated HTTP lient singleton which is an axios instance.
* Gets the unauthenticated HTTP client for the service. This is an axios instance.
*
* @returns {HttpClient} Singleton. A configured axios http client
* @returns {HttpClient} A configured axios http client.
*/
getHttpClient() {
return this.httpClient;
Expand Down Expand Up @@ -157,7 +158,6 @@ class AxiosJwtAuthService {
* Sets the authenticated user to the provided value.
*
* @param {UserData} authUser
* @emits AUTHENTICATED_USER_CHANGED
*/
setAuthenticatedUser(authUser) {
this.authenticatedUser = authUser;
Expand Down
Loading

0 comments on commit da4dc1b

Please sign in to comment.