Skip to content

Commit

Permalink
fix: getEnvironmentVariableValue returns Value
Browse files Browse the repository at this point in the history
Breaking Change:
- Before getEnvironmentVariableValue returned Object with property Value, now it returns the Value directly.
  • Loading branch information
AhashSritharan committed Mar 29, 2024
1 parent e06e9cc commit 8378f56
Show file tree
Hide file tree
Showing 7 changed files with 47 additions and 10 deletions.
5 changes: 3 additions & 2 deletions build/src/XrmEx.js

Large diffs are not rendered by default.

24 changes: 22 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -89,10 +89,11 @@
"typedoc-plugin-markdown": "^3.15.3",
"typescript": "^5.1.3",
"vitest": "^0.32.2",
"xrm-mock": "^3.5.9"
"xrm-mock": "^3.5.9",
"otpauth": "^9.2.2"
},
"overrides": {
"semver": "~7.5.3",
"word-wrap": "npm:@aashutoshrathi/word-wrap"
}
}
}
Binary file modified release/xrm-ex.zip
Binary file not shown.
3 changes: 2 additions & 1 deletion src/XrmEx.ts
Original file line number Diff line number Diff line change
Expand Up @@ -116,13 +116,14 @@ export namespace XrmEx {
export async function getEnvironmentVariableValue(
environmentVariableSchemaName: string
): Promise<string> {
return executeFunction("RetrieveEnvironmentVariableValue", [
let response = await executeFunction("RetrieveEnvironmentVariableValue", [
{
Name: "DefinitionSchemaName",
Type: "String",
Value: environmentVariableSchemaName,
},
]);
return Object.hasOwn(response, "Value") ? response.Value : response;
}
/**
* A map of CRM data types to their corresponding type names, structural properties, and JavaScript types.
Expand Down
5 changes: 3 additions & 2 deletions testBuild/src/XrmEx.js

Large diffs are not rendered by default.

15 changes: 14 additions & 1 deletion tests/auth.setup.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { test as setup } from '@playwright/test';
import fs from 'fs';
import path from 'path';
import { TOTP } from 'otpauth';
import * as process from 'process';
import { fileURLToPath } from 'url';
const __filename = fileURLToPath(import.meta.url);
Expand All @@ -12,7 +13,7 @@ setup('authenticate', async ({ playwright, request }) => {
: loadJson();

//Exit in env properties are not set
if (!env || !env.CONTACT_RECORD_URL || !env.CRM_URL || !env.USER_NAME || !env.USER_PASSWORD) {
if (!env || !env.CONTACT_RECORD_URL || !env.CRM_URL || !env.USER_NAME || !env.USER_PASSWORD || !env.TOTP) {
console.log('Missing environment variables');
return;
}
Expand All @@ -29,6 +30,17 @@ setup('authenticate', async ({ playwright, request }) => {
await page.getByRole('button', { name: 'Next' }).click();
await page.getByPlaceholder('Password').type(env.USER_PASSWORD);
await page.getByRole('button', { name: 'Sign in' }).click();
const otpTextBox = page.getByRole('textbox', { name: 'Enter code' });
var totp = new TOTP({
algorithm: 'SHA1',
digits: 6,
period: 30,
secret: env.TOTP,
});
// Generate a token.
var token = totp.generate();
otpTextBox.fill(token);
await page.getByRole('button', { name: 'Verify' }).click();
await page.getByRole('button', { name: 'No' }).click();
}
await page.context().storageState({ path: userAuthFile });
Expand All @@ -39,6 +51,7 @@ export interface CRMConfig {
USER_NAME: string;
USER_PASSWORD: string;
CONTACT_RECORD_URL: string;
TOTP: string;
}
function loadJson() {
const filePath = path.join(__dirname, '../playwright.env.json');
Expand Down

0 comments on commit 8378f56

Please sign in to comment.