Skip to content

Commit

Permalink
feat: remove digest security
Browse files Browse the repository at this point in the history
  • Loading branch information
freaz committed Jul 19, 2023
1 parent 846e0c4 commit e79149c
Show file tree
Hide file tree
Showing 7 changed files with 112 additions and 283 deletions.
8 changes: 8 additions & 0 deletions src/interfaces/providerjson/providerjson.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,14 @@
"query"
],
"type": "string"
},
"ApiKeyBodyType": {
"$id": "ApiKeyBodyType",
"description": "Body type to inject security value to.",
"enum": [
"json"
],
"type": "string"
}
},
"description": "Type decribing provider.json document.",
Expand Down
1 change: 0 additions & 1 deletion src/interfaces/providerjson/providerjson.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ export enum ApiKeyPlacement {
export enum HttpScheme {
BASIC = 'basic',
BEARER = 'bearer',
DIGEST = 'digest',
}

/**
Expand Down
148 changes: 11 additions & 137 deletions src/interfaces/providerjson/providerjson.utils.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { IntegrationParameter, prepareProviderParameters } from '.';
import {
ApiKeyBodyType,
ApiKeyPlacement,
HttpScheme,
SecurityScheme,
Expand All @@ -10,7 +11,6 @@ import {
isApiKeySecurityScheme,
isBasicAuthSecurityScheme,
isBearerTokenSecurityScheme,
isDigestSecurityScheme,
isValidProviderName,
prepareSecurityValues,
} from './providerjson.utils';
Expand Down Expand Up @@ -42,14 +42,6 @@ describe('ProviderJsonDocument', () => {
"id": "swapidev",
"type": "http",
"scheme": "basic"
},
{
"id": "swapidev",
"type": "http",
"scheme": "digest",
"statusCode": 401,
"challengeHeader": "www-authenticate",
"authorizationHeader": "authorizaation"
}
],
"defaultService": "swapidev",
Expand Down Expand Up @@ -81,15 +73,7 @@ describe('ProviderJsonDocument', () => {
id: 'swapidev',
type: 'http',
scheme: 'basic',
},
{
id: 'swapidev',
type: 'http',
scheme: 'digest',
statusCode: 401,
challengeHeader: 'www-authenticate',
authorizationHeader: 'authorizaation',
},
}
],
defaultService: 'swapidev',
parameters: [{ name: 'userId', description: "some user's id" }],
Expand Down Expand Up @@ -382,7 +366,8 @@ describe('ProviderJsonDocument', () => {
isApiKeySecurityScheme({
id: 'swapidev',
type: SecurityType.APIKEY,
in: ApiKeyPlacement.PATH,
in: ApiKeyPlacement.BODY,
bodyType: ApiKeyBodyType.JSON,
name: 'X-API-Key',
})
).toEqual(true);
Expand All @@ -392,7 +377,7 @@ describe('ProviderJsonDocument', () => {
isApiKeySecurityScheme({
id: 'swapidev',
type: SecurityType.APIKEY,
in: ApiKeyPlacement.QUERY,
in: ApiKeyPlacement.PATH,
name: 'X-API-Key',
})
).toEqual(true);
Expand All @@ -401,17 +386,18 @@ describe('ProviderJsonDocument', () => {
expect(
isApiKeySecurityScheme({
id: 'swapidev',
type: SecurityType.HTTP,
scheme: HttpScheme.BEARER,
type: SecurityType.APIKEY,
in: ApiKeyPlacement.QUERY,
name: 'X-API-Key',
})
).toEqual(false);
).toEqual(true);
}
{
expect(
isApiKeySecurityScheme({
id: 'swapidev',
type: SecurityType.HTTP,
scheme: HttpScheme.BASIC,
scheme: HttpScheme.BEARER,
})
).toEqual(false);
}
Expand All @@ -420,7 +406,7 @@ describe('ProviderJsonDocument', () => {
isApiKeySecurityScheme({
id: 'swapidev',
type: SecurityType.HTTP,
scheme: HttpScheme.DIGEST,
scheme: HttpScheme.BASIC,
})
).toEqual(false);
}
Expand Down Expand Up @@ -455,15 +441,6 @@ describe('ProviderJsonDocument', () => {
})
).toEqual(true);
}
{
expect(
isBasicAuthSecurityScheme({
id: 'swapidev',
type: SecurityType.HTTP,
scheme: HttpScheme.DIGEST,
})
).toEqual(false);
}
});

it('checks BearerTokenSecurity type correctly', () => {
Expand Down Expand Up @@ -495,101 +472,8 @@ describe('ProviderJsonDocument', () => {
})
).toEqual(false);
}
{
expect(
isBearerTokenSecurityScheme({
id: 'swapidev',
type: SecurityType.HTTP,
scheme: HttpScheme.DIGEST,
})
).toEqual(false);
}
});

it('checks DigestAuthSecurity type correctly', () => {
{
expect(
isDigestSecurityScheme({
id: 'swapidev',
type: SecurityType.APIKEY,
in: ApiKeyPlacement.HEADER,
name: 'X-API-Key',
})
).toEqual(false);
}
{
expect(
isDigestSecurityScheme({
id: 'swapidev',
type: SecurityType.HTTP,
scheme: HttpScheme.BEARER,
})
).toEqual(false);
}
{
expect(
isDigestSecurityScheme({
id: 'swapidev',
type: SecurityType.HTTP,
scheme: HttpScheme.BASIC,
})
).toEqual(false);
}
{
expect(
isDigestSecurityScheme({
id: 'swapidev',
type: SecurityType.HTTP,
scheme: HttpScheme.DIGEST,
})
).toEqual(true);
}
{
expect(
isDigestSecurityScheme({
id: 'swapidev',
type: SecurityType.HTTP,
scheme: HttpScheme.DIGEST,
statusCode: 401,
})
).toEqual(true);
}
{
expect(
isDigestSecurityScheme({
id: 'swapidev',
type: SecurityType.HTTP,
scheme: HttpScheme.DIGEST,
statusCode: 401,
challengeHeader: 'test',
})
).toEqual(true);
}
{
expect(
isDigestSecurityScheme({
id: 'swapidev',
type: SecurityType.HTTP,
scheme: HttpScheme.DIGEST,
statusCode: 401,
challengeHeader: 'test',
authorizationHeader: 'auth',
})
).toEqual(true);
}
{
expect(
isDigestSecurityScheme({
id: 'swapidev',
type: SecurityType.HTTP,
scheme: HttpScheme.DIGEST,
statusCode: undefined,
challengeHeader: undefined,
authorizationHeader: undefined,
})
).toEqual(true);
}
});
});
describe('ProviderJson name check', () => {
it('checks Provider name correctly', () => {
Expand Down Expand Up @@ -622,11 +506,6 @@ describe('prepareSecurityValues', () => {
type: SecurityType.HTTP,
scheme: HttpScheme.BASIC,
},
{
id: 'digest',
type: SecurityType.HTTP,
scheme: HttpScheme.DIGEST,
},
];

it('prepares security values', () => {
Expand All @@ -644,11 +523,6 @@ describe('prepareSecurityValues', () => {
username: `$TEST_PROVIDER_USERNAME`,
password: `$TEST_PROVIDER_PASSWORD`,
},
{
id: 'digest',
username: `$TEST_PROVIDER_USERNAME`,
password: `$TEST_PROVIDER_PASSWORD`,
},
]);
});

Expand Down
22 changes: 0 additions & 22 deletions src/interfaces/superjson/superjson.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -733,28 +733,6 @@
"token"
],
"type": "object"
},
{
"$id": "DigestSecurityValues",
"additionalProperties": false,
"description": "Security values for digest security scheme",
"properties": {
"id": {
"type": "string"
},
"password": {
"type": "string"
},
"username": {
"type": "string"
}
},
"required": [
"id",
"password",
"username"
],
"type": "object"
}
],
"description": "Authorization variables."
Expand Down
Loading

0 comments on commit e79149c

Please sign in to comment.