Skip to content

Commit

Permalink
fix(cacheClient): test cache login
Browse files Browse the repository at this point in the history
  • Loading branch information
JGiter committed Nov 17, 2021
1 parent cfc962e commit dec430f
Show file tree
Hide file tree
Showing 8 changed files with 33 additions and 34 deletions.
Expand Up @@ -54,7 +54,6 @@
- [login](modules_cacheClient_cacheClient_service.CacheClient.md#login)
- [rejectClaim](modules_cacheClient_cacheClient_service.CacheClient.md#rejectclaim)
- [requestClaim](modules_cacheClient_cacheClient_service.CacheClient.md#requestclaim)
- [testLogin](modules_cacheClient_cacheClient_service.CacheClient.md#testlogin)

## Constructors

Expand Down Expand Up @@ -764,17 +763,3 @@ ___
#### Implementation of

[ICacheClient](../interfaces/modules_cacheClient_ICacheClient.ICacheClient.md).[requestClaim](../interfaces/modules_cacheClient_ICacheClient.ICacheClient.md#requestclaim)

___

### testLogin

**testLogin**(): `Promise`<`void`\>

#### Returns

`Promise`<`void`\>

#### Implementation of

[ICacheClient](../interfaces/modules_cacheClient_ICacheClient.ICacheClient.md).[testLogin](../interfaces/modules_cacheClient_ICacheClient.ICacheClient.md#testlogin)
Expand Up @@ -45,7 +45,6 @@
- [login](modules_cacheClient_ICacheClient.ICacheClient.md#login)
- [rejectClaim](modules_cacheClient_ICacheClient.ICacheClient.md#rejectclaim)
- [requestClaim](modules_cacheClient_ICacheClient.ICacheClient.md#requestclaim)
- [testLogin](modules_cacheClient_ICacheClient.ICacheClient.md#testlogin)

## Properties

Expand Down Expand Up @@ -546,13 +545,3 @@ ___
#### Returns

`Promise`<`void`\>

___

### testLogin

**testLogin**(): `Promise`<`void`\>

#### Returns

`Promise`<`void`\>
7 changes: 7 additions & 0 deletions docs/api/modules/index.md
Expand Up @@ -61,6 +61,7 @@
- [StakeStatus](index.md#stakestatus)
- [StakingPool](index.md#stakingpool)
- [StakingService](index.md#stakingservice)
- [TEST\_LOGIN\_NAMESPACE](index.md#test_login_namespace)
- [VOLTA\_CHAIN\_ID](index.md#volta_chain_id)
- [addSupportedDID](index.md#addsupporteddid)
- [agreement\_type\_hash](index.md#agreement_type_hash)
Expand Down Expand Up @@ -441,6 +442,12 @@ Re-exports: [StakingService](../classes/modules_staking_staking_service.StakingS

___

### TEST\_LOGIN\_NAMESPACE

Re-exports: [TEST\_LOGIN\_NAMESPACE](modules_cacheClient_cacheClient_types.md#test_login_namespace)

___

### VOLTA\_CHAIN\_ID

Re-exports: [VOLTA\_CHAIN\_ID](utils_constants.md#volta_chain_id)
Expand Down
7 changes: 7 additions & 0 deletions docs/api/modules/modules_cacheClient.md
Expand Up @@ -11,6 +11,7 @@
- [ICacheClient](modules_cacheClient.md#icacheclient)
- [Order](modules_cacheClient.md#order)
- [SearchType](modules_cacheClient.md#searchtype)
- [TEST\_LOGIN\_NAMESPACE](modules_cacheClient.md#test_login_namespace)

## References

Expand Down Expand Up @@ -53,3 +54,9 @@ ___
### SearchType

Re-exports: [SearchType](../enums/modules_cacheClient_cacheClient_types.SearchType.md)

___

### TEST\_LOGIN\_NAMESPACE

Re-exports: [TEST\_LOGIN\_NAMESPACE](modules_cacheClient_cacheClient_types.md#test_login_namespace)
10 changes: 10 additions & 0 deletions docs/api/modules/modules_cacheClient_cacheClient_types.md
Expand Up @@ -16,6 +16,10 @@
- [AssetsFilter](modules_cacheClient_cacheClient_types.md#assetsfilter)
- [ClaimsFilter](modules_cacheClient_cacheClient_types.md#claimsfilter)

### Variables

- [TEST\_LOGIN\_NAMESPACE](modules_cacheClient_cacheClient_types.md#test_login_namespace)

## Type aliases

### AssetsFilter
Expand Down Expand Up @@ -43,3 +47,9 @@ ___
| :------ | :------ |
| `isAccepted?` | `boolean` |
| `namespace?` | `string` |

## Variables

### TEST\_LOGIN\_NAMESPACE

`Const` **TEST\_LOGIN\_NAMESPACE**: ``"testing.if.logged.in"``
1 change: 0 additions & 1 deletion src/modules/cacheClient/ICacheClient.ts
Expand Up @@ -10,7 +10,6 @@ import { SearchType } from ".";

export interface ICacheClient {
pubKeyAndIdentityToken: IPubKeyAndIdentityToken | undefined;
testLogin: () => Promise<void>;
login: () => Promise<void>;
isAuthEnabled: () => boolean;

Expand Down
14 changes: 7 additions & 7 deletions src/modules/cacheClient/cacheClient.service.ts
Expand Up @@ -12,7 +12,7 @@ import { IPubKeyAndIdentityToken } from "../signer/signer.types";
import { cacheConfigs } from "../../config/cache.config";
import { ICacheClient } from "./ICacheClient";
import { AssetsFilter, ClaimsFilter } from "./cacheClient.types";
import { SearchType } from ".";
import { SearchType, TEST_LOGIN_NAMESPACE } from ".";

export class CacheClient implements ICacheClient {
public pubKeyAndIdentityToken: IPubKeyAndIdentityToken | undefined;
Expand Down Expand Up @@ -87,12 +87,6 @@ export class CacheClient implements ICacheClient {
return Promise.reject(error);
}

async testLogin(): Promise<void> {
// Simple test to check if logged in or no. TODO: have dedicated endpoint on the cache-server
// If receive unauthorized response, expect that refreshToken() will be called
await this.getRoleDefinition("testing.if.logged.in");
}

async login() {
await this.testLogin();
}
Expand Down Expand Up @@ -302,4 +296,10 @@ export class CacheClient implements ICacheClient {
return { token, refreshToken };
}
}

private async testLogin(): Promise<void> {
// Simple test to check if logged in or no. TODO: have dedicated endpoint on the cache-server
// If receive unauthorized response, expect that refreshToken() will be called
await this.getRoleDefinition(TEST_LOGIN_NAMESPACE);
}
}
2 changes: 2 additions & 0 deletions src/modules/cacheClient/cacheClient.types.ts
Expand Up @@ -27,3 +27,5 @@ export enum SearchType {
Org = "Org",
Role = "Role",
}

export const TEST_LOGIN_NAMESPACE = "testing.if.logged.in";

0 comments on commit dec430f

Please sign in to comment.