Skip to content

Commit

Permalink
fix: validate only if limit is defined
Browse files Browse the repository at this point in the history
  • Loading branch information
murka committed Jan 26, 2023
1 parent e2c45d3 commit 09f88bf
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
7 changes: 5 additions & 2 deletions src/shadowbox/server/manager_service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -338,8 +338,11 @@ export class ShadowsocksManagerService {
);
}

const limit = (req.params.limit as DataLimit) || undefined;
const dataLimit = validateDataLimit(limit);
const dataLimit = (req.params.limit as DataLimit) || undefined;

if (dataLimit) {
validateDataLimit(dataLimit);
}

const accessKeyJson = accessKeyToApiJson(
await this.accessKeys.createNewAccessKey({encryptionMethod, name, dataLimit})
Expand Down
2 changes: 1 addition & 1 deletion src/shadowbox/server/server_access_key.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ describe('ServerAccessKeyRepository', () => {

it('New access keys sees the encryption method correctly', (done) => {
const repo = new RepoBuilder().build();
repo.createNewAccessKey('aes-256-gcm').then((accessKey) => {
repo.createNewAccessKey({encryptionMethod: 'aes-256-gcm'}).then((accessKey) => {
expect(accessKey).toBeDefined();
expect(accessKey.proxyParams.encryptionMethod).toEqual('aes-256-gcm');
done();
Expand Down

0 comments on commit 09f88bf

Please sign in to comment.