Skip to content
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

Fix void responses in Beta types #864

Merged
merged 3 commits into from
May 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
116 changes: 95 additions & 21 deletions playground/handlers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,89 @@ export async function actions() {
console.log('Removed the action: ' + updatedAction.name);
}

export async function attackProtection() {
const mgmntClient = new ManagementClient(program.opts());

const { data: breachedPasswordDetectionSettings } =
await mgmntClient.attackProtection.getBreachedPasswordDetectionConfig();
console.log(
'Got Breached password detection settings, enabled',
breachedPasswordDetectionSettings.enabled
);

const { data: updatedBreachedPasswordDetectionSettings } =
await mgmntClient.attackProtection.updateBreachedPasswordDetectionConfig({
enabled: !breachedPasswordDetectionSettings.enabled,
});
console.log(
'Updated Breached password detection settings, enabled, from',
breachedPasswordDetectionSettings.enabled,
'to',
updatedBreachedPasswordDetectionSettings.enabled
);

const { data: revertedBreachedPasswordDetectionSettings } =
await mgmntClient.attackProtection.updateBreachedPasswordDetectionConfig({
enabled: !updatedBreachedPasswordDetectionSettings.enabled,
});
console.log(
'Reverted Breached password detection settings, enabled, from',
updatedBreachedPasswordDetectionSettings.enabled,
'to',
revertedBreachedPasswordDetectionSettings.enabled
);

const { data: bruteForceConfig } = await mgmntClient.attackProtection.getBruteForceConfig();
console.log('Got Suspicious IP throttling config, enabled', bruteForceConfig.enabled);

const { data: updatedBruteForceConfig } =
await mgmntClient.attackProtection.updateBruteForceConfig({
enabled: !bruteForceConfig.enabled,
});
console.log(
'Updated Breached password detection settings, enabled, from',
bruteForceConfig.enabled,
'to',
updatedBruteForceConfig.enabled
);

const { data: revertedBruteForceConfig } =
await mgmntClient.attackProtection.updateBruteForceConfig({
enabled: !updatedBruteForceConfig.enabled,
});
console.log(
'Reverted Breached password detection settings, enabled, from',
updatedBruteForceConfig.enabled,
'to',
revertedBruteForceConfig.enabled
);

const { data: suspiciousIpThrottlingConfig } =
await mgmntClient.attackProtection.getSuspiciousIpThrottlingConfig();
console.log('Got Suspicious IP throttling config, enabled', suspiciousIpThrottlingConfig.enabled);

const { data: updatedSuspiciousIpThrottlingConfig } =
await mgmntClient.attackProtection.updateSuspiciousIpThrottlingConfig({
enabled: !suspiciousIpThrottlingConfig.enabled,
});
console.log(
'Updated Breached password detection settings, enabled, from',
suspiciousIpThrottlingConfig.enabled,
'to',
updatedSuspiciousIpThrottlingConfig.enabled
);

const { data: revertedSuspiciousIpThrottlingConfig } =
await mgmntClient.attackProtection.updateSuspiciousIpThrottlingConfig({
enabled: !updatedSuspiciousIpThrottlingConfig.enabled,
});
console.log(
'Reverted Breached password detection settings, enabled, from',
updatedSuspiciousIpThrottlingConfig.enabled,
'to',
revertedSuspiciousIpThrottlingConfig.enabled
);
}
export async function anomaly() {
const mgmntClient = new ManagementClient(program.opts());
try {
Expand Down Expand Up @@ -207,21 +290,21 @@ export async function clientGrants() {
(api) => api.identifier === 'ClientGrantTests'
);

await mgmntClient.clientGrants.create({
const { data: clientGrant } = await mgmntClient.clientGrants.create({
client_id: program.opts().clientId,
audience: api?.identifier as string,
scope: ['openid'],
});
console.log(`Created client grant ${clientGrant.id}`);

const { data: newClientGrant } = await mgmntClient.clientGrants.getAll({
audience: api?.identifier as string,
const { data: clientGrants } = await mgmntClient.clientGrants.getAll({
client_id: program.opts().clientId,
});

console.log(`Created client grant ${newClientGrant[0].id}`);
console.log(`Got client grants ${clientGrants.map((clientGrant) => clientGrant.id)}`);

const { data: updatedClientGrant } = await mgmntClient.clientGrants.update(
{ id: newClientGrant[0].id as string },
{ id: clientGrant.id as string },
{ scope: ['openid', 'profile'] }
);

Expand All @@ -230,8 +313,8 @@ export async function clientGrants() {
// Delete API for testing
await mgmntClient.resourceServers.delete({ id: api?.id as string });

await mgmntClient.clientGrants.delete({ id: newClientGrant[0].id as string });
console.log('Removed the client grant: ' + newClientGrant[0].id);
await mgmntClient.clientGrants.delete({ id: clientGrant.id as string });
console.log('Removed the client grant: ' + clientGrant.id);
}

export async function clients() {
Expand Down Expand Up @@ -636,7 +719,7 @@ export async function jobs() {
const usersFilePath = path.join(__dirname, '../test/data/users.json');

const { data: createImportJob } = await mgmntClient.jobs.importUsers({
users: fs.createReadStream(usersFilePath),
users: fs.createReadStream(usersFilePath) as any,
connection_id: connection.id as string,
});

Expand Down Expand Up @@ -957,13 +1040,10 @@ export async function resourceServers() {
const mgmntClient = new ManagementClient(program.opts());

const apiId = `api_${uuid()}`;
await mgmntClient.resourceServers.create({
const { data: createdApi } = await mgmntClient.resourceServers.create({
identifier: apiId,
scopes: [{ value: 'foo' }],
});
const createdApi = (await mgmntClient.resourceServers.getAll()).data.find(
(api) => api.identifier === apiId
) as ResourceServer;
console.log('Created api:', createdApi.id);

try {
Expand All @@ -978,15 +1058,12 @@ export async function resourceServers() {
gotApis.map((api) => api.id)
);

await mgmntClient.resourceServers.update(
const { data: gotUpdatedApi } = await mgmntClient.resourceServers.update(
{
id: createdApi.id as string,
},
{ token_lifetime: (createdApi.token_lifetime as number) + 1 }
);
const { data: gotUpdatedApi } = await mgmntClient.resourceServers.get({
id: createdApi.id as string,
});
console.log(
'Updated API token_lifetime from:',
createdApi.token_lifetime,
Expand Down Expand Up @@ -1340,7 +1417,7 @@ export async function users() {
);
console.log('Updated name on auth method:', createdAuthMethod.name, 'to', 'bar');

await mgmntClient.users.updateAuthenticationMethods(
const { data: updatedAuthMethods } = await mgmntClient.users.updateAuthenticationMethods(
{
id: updatedUser.user_id as string,
},
Expand All @@ -1354,12 +1431,9 @@ export async function users() {
} as PutAuthenticationMethodsRequestInner;
})
);
const { data: updatedAuthMethods } = await mgmntClient.users.getAuthenticationMethods({
id: updatedUser.user_id as string,
});
console.log(
'Updated all auth methods to names:',
updatedAuthMethods.map((x) => x.name)
updatedAuthMethods.map((x: any) => x.name)
);

await mgmntClient.users.deleteAuthenticationMethod({
Expand Down
7 changes: 7 additions & 0 deletions playground/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ dotenv.config({
import { program } from 'commander';
import {
actions,
attackProtection,
anomaly,
blacklists,
branding,
Expand Down Expand Up @@ -51,6 +52,7 @@ program
.description('Test all endpoints')
.action(async () => {
await actions();
await attackProtection();
await anomaly();
await blacklists();
await branding();
Expand Down Expand Up @@ -81,6 +83,11 @@ program

program.command('actions').description('Test CRUD on the actions endpoints').action(actions);

program
.command('attack-protection')
.description('Test CRUD on the attack protection endpoints')
.action(attackProtection);

program.command('anomaly').description('Test the anomaly endpoints').action(anomaly);

program.command('blacklists').description('Test the blacklists endpoints').action(blacklists);
Expand Down
34 changes: 20 additions & 14 deletions src/management/__generated/managers/attack-protection-manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export class AttackProtectionManager extends BaseAPI {
*/
async getBreachedPasswordDetectionConfig(
initOverrides?: InitOverride
): Promise<ApiResponse<void>> {
): Promise<ApiResponse<{ [key: string]: any }>> {
const response = await this.request(
{
path: `/attack-protection/breached-password-detection`,
Expand All @@ -28,15 +28,17 @@ export class AttackProtectionManager extends BaseAPI {
initOverrides
);

return runtime.VoidApiResponse.fromResponse(response);
return runtime.JSONApiResponse.fromResponse<any>(response);
}

/**
* Get the brute force configuration
*
* @throws {RequiredError}
*/
async getBruteForceConfig(initOverrides?: InitOverride): Promise<ApiResponse<void>> {
async getBruteForceConfig(
initOverrides?: InitOverride
): Promise<ApiResponse<{ [key: string]: any }>> {
const response = await this.request(
{
path: `/attack-protection/brute-force-protection`,
Expand All @@ -45,15 +47,17 @@ export class AttackProtectionManager extends BaseAPI {
initOverrides
);

return runtime.VoidApiResponse.fromResponse(response);
return runtime.JSONApiResponse.fromResponse<any>(response);
}

/**
* Get the brute force configuration defaults
*
* @throws {RequiredError}
*/
async getBruteForceDefaults(initOverrides?: InitOverride): Promise<ApiResponse<void>> {
async getBruteForceDefaults(
initOverrides?: InitOverride
): Promise<ApiResponse<{ [key: string]: any }>> {
const response = await this.request(
{
path: `/attack-protection/brute-force-protection/defaults`,
Expand All @@ -62,15 +66,17 @@ export class AttackProtectionManager extends BaseAPI {
initOverrides
);

return runtime.VoidApiResponse.fromResponse(response);
return runtime.JSONApiResponse.fromResponse<any>(response);
}

/**
* Get the suspicious IP throttling configuration
*
* @throws {RequiredError}
*/
async getSuspiciousIpThrottlingConfig(initOverrides?: InitOverride): Promise<ApiResponse<void>> {
async getSuspiciousIpThrottlingConfig(
initOverrides?: InitOverride
): Promise<ApiResponse<{ [key: string]: any }>> {
const response = await this.request(
{
path: `/attack-protection/suspicious-ip-throttling`,
Expand All @@ -79,7 +85,7 @@ export class AttackProtectionManager extends BaseAPI {
initOverrides
);

return runtime.VoidApiResponse.fromResponse(response);
return runtime.JSONApiResponse.fromResponse<any>(response);
}

/**
Expand All @@ -90,7 +96,7 @@ export class AttackProtectionManager extends BaseAPI {
async updateBreachedPasswordDetectionConfig(
bodyParameters: PatchBreachedPasswordDetectionRequest,
initOverrides?: InitOverride
): Promise<ApiResponse<void>> {
): Promise<ApiResponse<{ [key: string]: any }>> {
const headerParameters: runtime.HTTPHeaders = {};

headerParameters['Content-Type'] = 'application/json';
Expand All @@ -105,7 +111,7 @@ export class AttackProtectionManager extends BaseAPI {
initOverrides
);

return runtime.VoidApiResponse.fromResponse(response);
return runtime.JSONApiResponse.fromResponse<any>(response);
}

/**
Expand All @@ -116,7 +122,7 @@ export class AttackProtectionManager extends BaseAPI {
async updateBruteForceConfig(
bodyParameters: PatchBruteForceProtectionRequest,
initOverrides?: InitOverride
): Promise<ApiResponse<void>> {
): Promise<ApiResponse<{ [key: string]: any }>> {
const headerParameters: runtime.HTTPHeaders = {};

headerParameters['Content-Type'] = 'application/json';
Expand All @@ -131,7 +137,7 @@ export class AttackProtectionManager extends BaseAPI {
initOverrides
);

return runtime.VoidApiResponse.fromResponse(response);
return runtime.JSONApiResponse.fromResponse<any>(response);
}

/**
Expand All @@ -142,7 +148,7 @@ export class AttackProtectionManager extends BaseAPI {
async updateSuspiciousIpThrottlingConfig(
bodyParameters: PatchSuspiciousIpThrottlingRequest,
initOverrides?: InitOverride
): Promise<ApiResponse<void>> {
): Promise<ApiResponse<{ [key: string]: any }>> {
const headerParameters: runtime.HTTPHeaders = {};

headerParameters['Content-Type'] = 'application/json';
Expand All @@ -157,6 +163,6 @@ export class AttackProtectionManager extends BaseAPI {
initOverrides
);

return runtime.VoidApiResponse.fromResponse(response);
return runtime.JSONApiResponse.fromResponse<any>(response);
}
}
4 changes: 2 additions & 2 deletions src/management/__generated/managers/client-grants-manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ export class ClientGrantsManager extends BaseAPI {
async create(
bodyParameters: ClientGrantCreate,
initOverrides?: InitOverride
): Promise<ApiResponse<void>> {
): Promise<ApiResponse<ClientGrant>> {
const headerParameters: runtime.HTTPHeaders = {};

headerParameters['Content-Type'] = 'application/json';
Expand All @@ -154,6 +154,6 @@ export class ClientGrantsManager extends BaseAPI {
initOverrides
);

return runtime.VoidApiResponse.fromResponse(response);
return runtime.JSONApiResponse.fromResponse(response);
}
}
Loading