Skip to content

Commit

Permalink
Resolved Issues
Browse files Browse the repository at this point in the history
  • Loading branch information
vr-varad authored and rajdip-b committed Aug 2, 2024
1 parent d13637b commit 28fdd3a
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 47 deletions.
11 changes: 7 additions & 4 deletions packages/api-client/src/controllers/secret/secret.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,26 +59,29 @@ export default class SecretController {
static async getAllSecretsOfProject(
request: GetAllSecretsOfProjectRequest,
headers?: Record<string, string>
): Promise<GetAllSecretsOfProjectResponse> {
): Promise<GetAllSecretsOfProjectResponse[]> {
let url = `/api/secret/${request.projectId}?decryptValue=true`
request.page && (url += `page=${request.page}&`)
request.limit && (url += `limit=${request.limit}&`)
request.sort && (url += `sort=${request.sort}&`)
request.order && (url += `order=${request.order}&`)
request.search && (url += `search=${request.search}&`)
return this.apiClient.get(url, headers)
return this.apiClient.get<GetAllSecretsOfProjectResponse[]>(url, headers)
}

static async getAllSecretsOfEnvironment(
request: GetAllSecretsOfEnvironmentRequest,
headers?: Record<string, string>
): Promise<GetAllSecretsOfEnvironmentResponse> {
): Promise<GetAllSecretsOfEnvironmentResponse[]> {
let url = `/api/secret/${request.projectId}/${request.environmentId}`
request.page && (url += `page=${request.page}&`)
request.limit && (url += `limit=${request.limit}&`)
request.sort && (url += `sort=${request.sort}&`)
request.order && (url += `order=${request.order}&`)
request.search && (url += `search=${request.search}&`)
return this.apiClient.get(url, headers)
return this.apiClient.get<GetAllSecretsOfEnvironmentResponse[]>(
url,
headers
)
}
}
65 changes: 31 additions & 34 deletions packages/api-client/src/types/secret.types.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ export interface CreateSecretRequest {
projectId: string
name: string
note?: string
rotateAfter?: string
rotateAfter?: '24' | '168' | '720' | '8760' | 'never'
entries?: [
{
value: string
Expand Down Expand Up @@ -35,7 +35,7 @@ export interface UpdateSecretRequest {
secretId: string
name?: string
note?: string
rotateAfter?: string
rotateAfter?: '24' | '168' | '720' | '8760' | 'never'
entries?: [
{
value: string
Expand All @@ -45,8 +45,18 @@ export interface UpdateSecretRequest {
}

export interface UpdateSecretResponse {
secret: any
updatedVersions: any
secret: {
id: string
name: string
note: string
}
updatedVersions: [
{
id?: string
environmentId: string
value: string
}
]
}

export interface DeleteSecretRequest {
Expand All @@ -73,25 +83,28 @@ export interface GetAllSecretsOfProjectRequest {
search?: string
}
export interface GetAllSecretsOfProjectResponse {
items: {
secret: {
id: string
name: string
createdAt: string
updatedAt: string
rotateAt: string | null
rotateAt: string
note: string | null
lastUpdatedById: string
projectId: string
project: {
workspaceId: string
lastUpdatedBy: {
id: string
name: string
}
}
values: {
environment: {
id: string
name: string
}
versions: [
{
value: string
environmentId: string
}
]
}[]
value: string
version: number
}
}

export interface GetAllSecretsOfEnvironmentRequest {
Expand All @@ -104,23 +117,7 @@ export interface GetAllSecretsOfEnvironmentRequest {
search?: string
}
export interface GetAllSecretsOfEnvironmentResponse {
items: {
id: string
name: string
createdAt: string
updatedAt: string
rotateAt: string | null
note: string | null
lastUpdatedById: string
projectId: string
project: {
workspaceId: string
}
versions: [
{
value: string
environmentId: string
}
]
}[]
name: string
value: string
isPlaintext: boolean
}
24 changes: 15 additions & 9 deletions packages/api-client/tests/secret.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -117,15 +117,11 @@ describe('Get Variable tests', () => {

// RollBack a Particular Version of a Secret
it('should roll back a version of a secret', async () => {
try {
const rollbackSecret = await SecretController.rollbackSecret(
{ secretId, environmentId: environment.id, version: 1 },
{ 'x-e2e-user-email': email }
)
expect(rollbackSecret.count).toBe(1)
} catch (error) {
console.log(error)
}
const rollbackSecret = await SecretController.rollbackSecret(
{ secretId, environmentId: environment.id, version: 1 },
{ 'x-e2e-user-email': email }
)
expect(rollbackSecret.count).toBe(1)
})

// Get all secrets of a Project
Expand All @@ -147,6 +143,16 @@ describe('Get Variable tests', () => {
{ 'x-e2e-user-email': email }
)
expect(secrets.length).toBe(1)
secrets.forEach((secret) => {
expect(secret).toHaveProperty('name')
expect(typeof secret.name).toBe('string')

expect(secret).toHaveProperty('value')
expect(typeof secret.value).toBe('string')

expect(secret).toHaveProperty('isPlaintext')
expect(typeof secret.isPlaintext).toBe('boolean')
})
})

// Delete a Secert from a Project
Expand Down

0 comments on commit 28fdd3a

Please sign in to comment.