Skip to content

Commit

Permalink
build: move apikey and secret to env variables
Browse files Browse the repository at this point in the history
  • Loading branch information
vishalnarkhede committed Apr 5, 2022
1 parent a2a5715 commit 98659c2
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 10 deletions.
7 changes: 5 additions & 2 deletions .github/workflows/type.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,10 @@ jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: ./.github/actions/setup-node
uses: actions/checkout@v2
uses: ./.github/actions/setup-node
- name: Run API type definition tests
run: yarn test-types
env:
API_KEY: ${{ secrets.TS_TEST_API_KEY }}
API_SECRET: ${{ secrets.TS_TEST_API_SECRET }}
6 changes: 5 additions & 1 deletion test/typescript/response-generators/client.js
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,11 @@ async function syncTeam() {
text: 'New Event?',
user: { id: user1 },
});
return await client.sync([channel.cid], new Date(Date.now() - 1000 * 60).toISOString());
const response = await client.sync([channel.cid], new Date(Date.now() - 1000 * 60).toISOString());

const serverClient = await utils.disableMultitenancy();

return response;
}

async function updateAppSettings() {
Expand Down
19 changes: 12 additions & 7 deletions test/typescript/utils.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
const { StreamChat } = require('../../dist');
require('dotenv').config();
const apiKey = '892s22ypvt6m';
const apiSecret = '5cssrefv55rs3cnkk38kfjam2k7c2ykwn4h79dqh66ym89gm65cxy4h9jx4cypd6';

const multiTenancySecret = 'pf8krbh9z3vc8d35dn65tq4xsa4jqmcbdgp5spuej2fprm6rqc5mtxuxghgxw43u';
const multiTenancyKey = '2g3vcvcnmm5u';
require('dotenv').config({ path: `${process.cwd()}/test/typescript/.env` });

const apiKey = process.env.API_KEY;
const apiSecret = process.env.API_SECRET;

module.exports = {
createMultiTenancyUsers: async function createMultiTenancyUsers(userIDs, teams = [], additionalInfo) {
Expand All @@ -24,7 +23,7 @@ module.exports = {
return await serverClient.upsertUsers(users);
},
createMultiTenancyUserToken: function createUserToken(userID) {
const chat = new StreamChat(multiTenancyKey, multiTenancySecret);
const chat = new StreamChat(apiKey, apiSecret);
return chat.createToken(userID);
},
createUserToken: function createUserToken(userID) {
Expand Down Expand Up @@ -57,7 +56,7 @@ module.exports = {
return channel;
},
getMultiTenancyTestClient: async function getMultiTenancyTestClient(serverSide) {
const client = new StreamChat(multiTenancyKey, serverSide ? multiTenancySecret : null, {
const client = new StreamChat(apiKey, serverSide ? apiSecret : null, {
timeout: 8000,
allowServerSideConnect: true,
});
Expand Down Expand Up @@ -97,6 +96,12 @@ module.exports = {
client.connectUser({ id: userID, ...options }, this.createUserToken(userID));
return client;
},
disableMultitenancy: async function disableMultitenancy() {
const client = await this.getMultiTenancyTestClient(true);
await client.updateAppSettings({
multi_tenant_enabled: false,
});
},
runAndLogPromise: function runAndLogPromise(promiseCallable) {
promiseCallable().catch((err) => {
console.warn('runAndLogPromise failed with error', err);
Expand Down

0 comments on commit 98659c2

Please sign in to comment.