froth-webdriverio-framework 3.0.38 → 3.0.40

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,33 @@
1
+ const crypto = require('crypto');
2
+
3
+ //const SECRET_KEY = "froth-testops@rd";
4
+
5
+ async function encryptData(data, secretKey) {
6
+ // Generate a random 16-byte IV (Initialization Vector)
7
+ const iv = crypto.randomBytes(16);
8
+
9
+ // Ensure the key is 16 bytes long
10
+ const key = Buffer.from(secretKey, 'utf-8');
11
+
12
+ // Initialize cipher in CBC mode with the key and IV
13
+ const cipher = crypto.createCipheriv('aes-128-cbc', key, iv);
14
+
15
+ // Encrypt the data
16
+ let encrypted = cipher.update(data, 'utf-8', 'base64');
17
+ encrypted += cipher.final('base64');
18
+
19
+ // Combine the IV and encrypted data, encode as base64
20
+ const encryptedData = Buffer.concat([iv, Buffer.from(encrypted, 'base64')]).toString('base64');
21
+
22
+ return encryptedData;
23
+ }
24
+
25
+
26
+
27
+ // Encrypt a password
28
+ //const encryptedPassword = encryptData("admin@1234", SECRET_KEY);
29
+ //console.log("Encrypted Password:", encryptedPassword);
30
+
31
+ module.exports = encryptData;
32
+
33
+
package/api/loginapi.js CHANGED
@@ -1,16 +1,16 @@
1
1
  //const fetch = require('node-fetch'); // Import the fetch function
2
2
  //const FormData = require('form-data'); // Import the FormData constructor
3
3
 
4
-
4
+ const enc = require('./aesEncryption.js')
5
5
  async function getLoginToken(frothUrl, email, password) {
6
6
  try {
7
7
  const url = `${frothUrl}/api/login/`;
8
8
  console.log("URL: " + url);
9
9
  const formData = new FormData();
10
10
  formData.append('email_or_username', email);
11
- formData.append('password', password);
12
- formData.append('is_ad_user',false)
13
-
11
+ formData.append('password', await enc(password,"froth-testops@rd"));
12
+ formData.append('is_ad_user', false)
13
+
14
14
  const response = await fetch(url, {
15
15
  method: 'POST',
16
16
  headers: {
@@ -22,7 +22,7 @@ async function getLoginToken(frothUrl, email, password) {
22
22
 
23
23
  if (response.ok) {
24
24
  const data = await response.json();
25
- // console.log('Token:', data.access_token);
25
+ // console.log('Token:', data.access_token);
26
26
  return data.access_token;
27
27
  } else {
28
28
  console.error('Login failed:', response.statusText);
@@ -36,14 +36,16 @@ async function getLoginToken(frothUrl, email, password) {
36
36
 
37
37
  // async function main() {
38
38
  // try {
39
- // const frothUrl = "devapi.frothtestops.com";
39
+ // const frothUrl = "https://devapi.frothtestops.com";
40
40
  // const username = "frothbot@roboticodigital.com";
41
- // const password = "RnJvdGh0ZXN0b3BzQDU1NQ==";
41
+ // const password = "Frothtestops@555";
42
+ // const encryptedPassword = await enc(password,"froth-testops@rd")
43
+ // console.log("Encrypted Password:", encryptedPassword);
42
44
 
43
- // const token = await getLoginToken(frothUrl, username, password);
45
+ // const token = await getLoginToken(frothUrl, username, encryptedPassword);
44
46
  // if (!token) {
45
47
  // throw new Error('Login failed, no token obtained');
46
- // }else{
48
+ // } else {
47
49
  // console.log(token)
48
50
  // }
49
51
 
@@ -43,7 +43,7 @@ async function setEnvVariables() {
43
43
  BUFFER.setItem("FROTH_INTEGRATION_ID", process.env.INTEGRATION_ID || 1);
44
44
  BUFFER.setItem("ORGANISATION_DOMAIN_URL", process.env.ORGANISATION_DOMAIN_URL || "https://devapi.frothtestops.com");
45
45
  BUFFER.setItem("SERVICE_USER", "frothbot@roboticodigital.com");
46
- BUFFER.setItem("SERVICE_PASSWORD", "l5xa8AozQ2xldniR1hkkGm7z1ePl7SGy00GlAIdH9v7Bq3ENQKmGCdRTZgKbbTx+");
46
+ BUFFER.setItem("SERVICE_PASSWORD", "Frothtestops@555");
47
47
 
48
48
 
49
49
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "froth-webdriverio-framework",
3
- "version": "3.0.38",
3
+ "version": "3.0.40",
4
4
  "readme": "WebdriverIO Integration",
5
5
  "description": "WebdriverIO and BrowserStack App Automate",
6
6
  "license": "MIT",
@@ -31,12 +31,13 @@
31
31
  "@wdio/local-runner": "^9.0.9",
32
32
  "@wdio/mocha-framework": "^8.36.1",
33
33
  "@wdio/spec-reporter": "^8.36.1",
34
- "appium": "^2.11.3",
35
- "appium-uiautomator2-driver": "^2.29.11",
34
+ "appium": "^1.22.3",
35
+ "appium-uiautomator2-driver": "^2.2.0",
36
36
  "assert": "^2.1.0",
37
37
  "axios": "^1.7.7",
38
38
  "browserstack-local": "^1.5.5",
39
39
  "chai": "^5.1.1",
40
+ "crypto": "^1.0.1",
40
41
  "deepmerge": "^4.3.1",
41
42
  "form-data": "^4.0.0",
42
43
  "mysql2": "^3.10.2",
@@ -1,73 +0,0 @@
1
- const mysql = require('mysql2/promise');
2
- const { Pool } = require('pg');
3
-
4
- // Function to establish connection to MySQL database
5
- async function connectToMySQL(hostname, username, password, dbname, portnumber) {
6
- try {
7
- const poolConfig = {
8
- host: hostname,
9
- user: username,
10
- password: password,
11
- database: dbname,
12
- port: portnumber,
13
- waitForConnections: true,
14
- connectionLimit: 10,
15
- queueLimit: 0
16
- };
17
-
18
-
19
- let pool = mysql.createPool(poolConfig);
20
- console.log('MySQL connection pool created.');
21
- return pool;
22
- } catch (error) {
23
- console.error('Error creating MySQL connection pool:', error);
24
- throw error;
25
- }
26
- }
27
-
28
-
29
- // Function to fetch data from the database
30
- async function fetchDataFromDB(connectionpool, query) {
31
- let connection = null;
32
- let finalResult = null;
33
- try {
34
- console.log("connectionpool" + connectionpool)
35
- connection = await connectionpool.getConnection();
36
-
37
- console.log('Connected to the MySQL database.' + connection);
38
-
39
- const [rows] = await connection.execute(query);
40
- const dataArray = rows;
41
- finalResult = {
42
- totalNumberOfRecords: dataArray.length,
43
- records: dataArray
44
- };
45
- console.log(JSON.stringify(finalResult, null, 2));
46
- } catch (error) {
47
- console.error('Error fetching data:', error);
48
- } finally {
49
- if (connection) {
50
- connection.release();
51
- }
52
- }
53
- return finalResult;
54
- }
55
-
56
- // Main function to call the database connection and fetch data
57
- // async function main() {
58
- // try {
59
- // const connection = await connectToMySQL('10.0.0.6', 'root', 'password123', 'power_seraya_step', 3406);
60
- // console.log('Connection pool created.' + connection);
61
- // const query = 'SELECT id,EventID,NoPlate FROM store_images limit 2';
62
- // await fetchDataFromDB(connection, query);
63
- // } catch (err) {
64
- // console.log('Error connecting to database:', err.stack);
65
- // }
66
- // }
67
-
68
- // main();
69
-
70
- module.exports = {
71
- connectToMySQL,
72
- fetchDataFromDB
73
- };
@@ -1,69 +0,0 @@
1
- const { Pool } = require('pg');
2
-
3
- // Function to establish connection to MySQL database
4
- async function connectToPostgreSQL(hostname, username, password1, dbname, portnumber) {
5
- try {
6
- console.log('Connecting to the PostgreSQL database...');
7
-
8
- const poolConfig = {
9
- host: hostname,
10
- user: username,
11
- password: password1,
12
- database: dbname,
13
- port: portnumber // Increased connection timeout
14
- };
15
-
16
- const pool = new Pool(poolConfig);
17
- console.log('PostgreSQL connection pool created.');
18
-
19
- return pool;
20
- } catch (error) {
21
- console.error('Error creating MySQL connection pool:', error);
22
- throw error;
23
- }
24
- }
25
-
26
-
27
- // Function to fetch data from the database
28
- async function fetchDataFromPostgresDB(connectionpool, query) {
29
- let connection = null;
30
- let finalResult = null;
31
- try {
32
- connection = await connectionpool.connect();
33
-
34
- const result = await connection.query(query);
35
- const dataArray = result[0] || result.rows; // Adjust for MySQL and PostgreSQL response formats
36
- finalResult = {
37
- totalNumberOfRecords: dataArray.length,
38
- records: dataArray
39
- };
40
- // console.log(JSON.stringify(finalResult, null, 2));
41
- } catch (error) {
42
- console.error('Error fetching data:', error);
43
-
44
- } finally {
45
- if (connection) {
46
- connection.release();
47
- }
48
- }
49
- return finalResult;
50
- }
51
-
52
- // Main function to call the database connection and fetch data
53
- // async function main() {
54
- // try {
55
- // const connection = await connectToMySQL('10.0.0.6', 'root', 'password123', 'power_seraya_step', 3406);
56
- // console.log('Connection pool created.' + connection);
57
- // const query = 'SELECT id,EventID,NoPlate FROM store_images limit 2';
58
- // await fetchDataFromDB(connection, query);
59
- // } catch (err) {
60
- // console.log('Error connecting to database:', err.stack);
61
- // }
62
- // }
63
-
64
- // main();
65
-
66
- module.exports = {
67
- connectToPostgreSQL,
68
- fetchDataFromPostgresDB
69
- };