-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
bd6731c
commit e751a34
Showing
21 changed files
with
1,254 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
API_KEY=zut_DrBAgY0Ealb0vOu3JNVJryiQ5ViqJbmoxHK2Sw |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
# Specify files that shouldn't be modified by Fern | ||
|
||
src/core/fetcher/Fetcher.ts | ||
test/integration |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,6 @@ | ||
node_modules | ||
.DS_Store | ||
/dist | ||
/dist | ||
|
||
.idea/ | ||
.env |
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
import { VectaraClient } from "../../src"; | ||
|
||
describe('Test ApiKeys', () => { | ||
const client = new VectaraClient({ | ||
apiKey: process.env.APIKEY, | ||
}); | ||
let key: string; | ||
|
||
beforeEach(async () => { | ||
const response = await client.corpora.create({ | ||
name: "test-api-key-manager", | ||
key: "test-document-manager" | ||
}); | ||
if (response.key) { | ||
key = response.key; | ||
} | ||
|
||
await new Promise((resolve) => setTimeout(resolve, 60000)); | ||
}); | ||
|
||
afterEach(async () => { | ||
const corpora = await client.corpora.list(); | ||
for await (const corpus of corpora) { | ||
await client.corpora.delete(corpus.key ?? ""); | ||
} | ||
const apiKeys = await client.apiKeys.list(); | ||
for await (const apiKey of apiKeys) { | ||
await client.apiKeys.delete(apiKey.id ?? ""); | ||
} | ||
}); | ||
|
||
test('test create api key', async () => { | ||
const response = await client.apiKeys.create({ | ||
name: "test-key", | ||
apiKeyRole: "serving", | ||
corpusKeys: [key] | ||
}); | ||
|
||
expect(response.name).toBe("test-key"); | ||
expect(response.enabled).toBe(true); | ||
expect(response.apiKeyRole).toBe("serving"); | ||
}); | ||
|
||
test('test delete api key', async () => { | ||
const createResponse = await client.apiKeys.create({ | ||
name: "test-key", | ||
apiKeyRole: "serving", | ||
corpusKeys: [key] | ||
}); | ||
|
||
const deleteResponse = await client.apiKeys.delete(createResponse.id ?? ""); | ||
expect(deleteResponse).toBeNull(); | ||
}); | ||
|
||
test('test get api key', async () => { | ||
const createResponse = await client.apiKeys.create({ | ||
name: "test-key", | ||
apiKeyRole: "serving", | ||
corpusKeys: [key] | ||
}); | ||
|
||
const getResponse = await client.apiKeys.get(createResponse.id ?? ""); | ||
expect(getResponse.name).toBe(createResponse.name); | ||
}); | ||
|
||
test('test update api key', async () => { | ||
const createResponse = await client.apiKeys.create({ | ||
name: "test-key", | ||
apiKeyRole: "serving", | ||
corpusKeys: [key] | ||
}); | ||
|
||
const updateResponse = await client.apiKeys.update(createResponse.id ?? "", { enabled: false }); | ||
expect(updateResponse.enabled).toBe(false); | ||
}); | ||
|
||
test('test list api keys', async () => { | ||
const apiKeysNames: string[] = []; | ||
|
||
for (let index = 0; index < 2; index++) { | ||
const createResponse = await client.apiKeys.create({ | ||
name: `test-key-${index}`, | ||
apiKeyRole: "serving", | ||
corpusKeys: [key] | ||
}); | ||
if (createResponse.name) apiKeysNames.push(createResponse.name); | ||
} | ||
|
||
const apiKeys = await client.apiKeys.list(); | ||
for await (const apiKey of apiKeys) { | ||
expect(apiKeysNames).toContain(apiKey.name); | ||
} | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
import { VectaraClient } from "../../src"; | ||
|
||
describe('Test AppClient', () => { | ||
const client = new VectaraClient({ | ||
apiKey: process.env.APIKEY, | ||
}); | ||
|
||
afterEach(async () => { | ||
const appClients = await client.appClients.list(); | ||
for await (const appClient of appClients) { | ||
await client.appClients.delete(appClient.id ?? ""); | ||
} | ||
}); | ||
|
||
test('test create app client', async () => { | ||
const response = await client.appClients.create({ body: { | ||
type: "client_credentials", | ||
name: "test-client", | ||
apiRoles: ["owner"] | ||
}}); | ||
|
||
expect(response.name).toBe("test-client"); | ||
expect(response.clientId).not.toBeNull(); | ||
expect(response.clientSecret).not.toBeNull(); | ||
}); | ||
|
||
test('test get app client', async () => { | ||
const createResponse = await client.appClients.create({ body: { | ||
type: "client_credentials", | ||
name: "test-client", | ||
apiRoles: ["owner"] | ||
}}); | ||
|
||
const getResponse = await client.appClients.get(createResponse.id ?? ""); | ||
|
||
expect(getResponse.clientId).toBe(createResponse.clientId); | ||
expect(getResponse.clientSecret).toBe(createResponse.clientSecret); | ||
}); | ||
|
||
test('test delete app client', async () => { | ||
const createResponse = await client.appClients.create({ body: { | ||
type: "client_credentials", | ||
name: "test-client", | ||
apiRoles: ["owner"] | ||
}}); | ||
|
||
const delResponse = await client.appClients.delete(createResponse.id ?? ""); | ||
|
||
expect(delResponse).toBeNull(); | ||
}); | ||
|
||
test('test update app client', async () => { | ||
const createResponse = await client.appClients.create({ body: { | ||
type: "client_credentials", | ||
name: "test-client", | ||
apiRoles: ["owner"] | ||
}}); | ||
|
||
const updateResponse = await client.appClients.update(createResponse.id ?? "", { | ||
apiRoles: ["owner", "administrator"], | ||
description: "test client" | ||
}); | ||
|
||
expect(updateResponse.apiRoles).toEqual(["administrator"]); | ||
expect(updateResponse.description).toBe("test client"); | ||
}); | ||
|
||
test('test list app clients', async () => { | ||
const clientIds: string[] = []; | ||
for (let index = 0; index < 2; index++) { | ||
const createResponse = await client.appClients.create({ body: { | ||
type: "client_credentials", | ||
name: `test-client-${index}`, | ||
apiRoles: ["owner"] | ||
}}); | ||
if (createResponse.clientId) clientIds.push(createResponse.clientId); | ||
} | ||
|
||
const clients = await client.appClients.list(); | ||
|
||
for await (const client of clients) { | ||
expect(clientIds).toContain(client.clientId); | ||
} | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import { VectaraClient } from "../../src"; | ||
|
||
describe('Test Auth Manager', () => { | ||
const client = new VectaraClient({ | ||
apiKey: process.env.APIKEY, | ||
}); | ||
let clientId: string; | ||
let clientSecret: string; | ||
|
||
beforeEach(async () => { | ||
const response = await client.appClients.create({ body: { | ||
type: "client_credentials", | ||
name: "test-client", | ||
apiRoles: ["owner"] | ||
}}); | ||
clientId = response.clientId ?? ""; | ||
clientSecret = response.clientSecret ?? ""; | ||
}); | ||
|
||
afterEach(async () => { | ||
const appClients = await client.appClients.list(); | ||
for await (const appClient of appClients) { | ||
await client.appClients.delete(appClient.id ?? ""); | ||
} | ||
}); | ||
|
||
test('test get access token', async () => { | ||
const response = await client.auth.getToken({ | ||
clientId: clientId, | ||
clientSecret: clientSecret, | ||
}); | ||
|
||
expect(response.accessToken).not.toBeNull(); | ||
expect(response.tokenType).not.toBeNull(); | ||
expect(response.expiresIn).not.toBeNull(); | ||
}); | ||
}); |
Oops, something went wrong.