Skip to content

Commit

Permalink
Update Keys + Update Test Layout (samrum#15)
Browse files Browse the repository at this point in the history
* Update secret key and client id

* Use .env for test credential config

* Add .env files to .gitignore

* Add .env example file

* Update test layout and make functional test a proper test

* Bump version to 2.0.8
  • Loading branch information
samrum authored Feb 12, 2020
1 parent 67a1395 commit c4f72a8
Show file tree
Hide file tree
Showing 15 changed files with 65 additions and 70 deletions.
5 changes: 5 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
DEVICEID="XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX"
VIN="1G2ZF58B774109863"
USERNAME="[email protected]"
PASSWORD="p@ssw0rd"
ONSTARPIN="1234"
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ dist
coverage
.rpt2_cache
testCredentials.json
.env
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ jobs:
include:
- stage: Produce Coverage
node_js: node
script: jest --coverage && cat ./coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js && rm -rf ./coverage
script: jest test/unit --coverage && cat ./coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js && rm -rf ./coverage
10 changes: 6 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "onstarjs",
"version": "2.0.7",
"version": "2.0.8",
"description": "Unofficial package for making OnStar API requests",
"main": "dist/index.js",
"module": "dist/index.esm.js",
Expand All @@ -14,9 +14,10 @@
"scripts": {
"build": "rm -rf dist && rollup -c",
"dev": "rm -rf dist && rollup -c -w",
"test": "jest",
"coverage": "jest --coverage",
"functional": "ts-node test/functional.ts",
"test": "jest test/unit",
"test:unit": "jest test/unit",
"test:coverage": "jest test/unit --coverage",
"test:functional": "jest test/functional",
"prepublishOnly": "yarn run test && yarn run build"
},
"sideEffects": false,
Expand Down Expand Up @@ -49,6 +50,7 @@
"@types/jsonwebtoken": "^8.3.2",
"@types/uuid": "^3.4.4",
"coveralls": "^3.0.3",
"dotenv": "^8.2.0",
"jest": "^24.7.1",
"prettier": "^1.16.4",
"rollup": "^1.9.0",
Expand Down
4 changes: 2 additions & 2 deletions src/TokenHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import uuidv4 from "uuid/v4";

import { OAuthToken, OnStarConfig } from "./types";

const SECRET_KEY = "rXSAQVGjlDrgyuIhEcXC";
const CLIENT_ID = "OMB_CVY_iOS_3M0";
const SECRET_KEY = "KVIZwNskbBdgpyuEalwv";
const CLIENT_ID = "OMB_CVY_iOS_3P0";

class TokenHandler {
constructor(private config: OnStarConfig) {}
Expand Down
52 changes: 0 additions & 52 deletions test/functional.ts

This file was deleted.

34 changes: 34 additions & 0 deletions test/functional/OnStar.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import dotenv from "dotenv";
dotenv.config();
import OnStar from "../../src/index";

jest.setTimeout(15000);

let onStar: OnStar;

describe("OnStarJs", () => {
beforeAll(() => {
onStar = OnStar.create({
deviceId: process.env.DEVICEID || "",
vin: process.env.VIN || "",
username: process.env.USERNAME || "",
password: process.env.PASSWORD || "",
onStarPin: process.env.ONSTARPIN || "",
checkRequestStatus: false,
});
});

test("Account Info", async () => {
const result = await onStar.getAccountVehicles();

expect(result.status).toEqual("success");
expect(result.response.data).toHaveProperty("vehicles");
});

test("Lock Door", async () => {
const result = await onStar.lockDoor();

expect(result.status).toEqual("success");
expect(result.response.data).toHaveProperty("commandResponse");
});
});
4 changes: 2 additions & 2 deletions test/OnStar.test.ts → test/unit/OnStar.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { mock, instance } from "ts-mockito";

import OnStar from "../src/index";
import RequestService from "../src/RequestService";
import OnStar from "../../src/index";
import RequestService from "../../src/RequestService";
import { testConfig } from "./testData";

let onStar: OnStar;
Expand Down
2 changes: 1 addition & 1 deletion test/Request.test.ts → test/unit/Request.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import Request, { RequestMethod } from "../src/Request";
import Request, { RequestMethod } from "../../src/Request";

describe("Request", () => {
test("Property Methods", () => {
Expand Down
4 changes: 2 additions & 2 deletions test/RequestError.test.ts → test/unit/RequestError.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import Request from "../src/Request";
import RequestError from "../src/RequestError";
import Request from "../../src/Request";
import RequestError from "../../src/RequestError";

describe("RequestError", () => {
test("Property Methods", () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import RequestResult from "../src/RequestResult";
import RequestResult from "../../src/RequestResult";

describe("RequestResult", () => {
test("Property Methods", () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { mock, instance, when, anything } from "ts-mockito";
import TokenHandler from "../src/TokenHandler";
import { HttpClient } from "../src/types";
import RequestService from "../src/RequestService";
import TokenHandler from "../../src/TokenHandler";
import { HttpClient } from "../../src/types";
import RequestService from "../../src/RequestService";
import { testConfig, authToken, expiredAuthToken } from "./testData";

let requestService: RequestService;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import TokenHandler from "../src/TokenHandler";
import TokenHandler from "../../src/TokenHandler";
import { testConfig, authToken, expiredAuthToken } from "./testData";

let tokenHandler: TokenHandler;
Expand Down
2 changes: 1 addition & 1 deletion test/testData.ts → test/unit/testData.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { OAuthToken } from "../src/types";
import { OAuthToken } from "../../src/types";

const testConfig = {
deviceId: "742249ce-18e0-4c82-8bb2-9975367a7631",
Expand Down
5 changes: 5 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1022,6 +1022,11 @@ domexception@^1.0.1:
dependencies:
webidl-conversions "^4.0.2"

dotenv@^8.2.0:
version "8.2.0"
resolved "https://registry.yarnpkg.com/dotenv/-/dotenv-8.2.0.tgz#97e619259ada750eea3e4ea3e26bceea5424b16a"
integrity sha512-8sJ78ElpbDJBHNeBzUbUVLsqKdccaa/BXF1uPTw3GrvQTBgrQrtObr2mUrE38vzYd8cEv+m/JBfDLioYcfXoaw==

ecc-jsbn@~0.1.1:
version "0.1.2"
resolved "https://registry.yarnpkg.com/ecc-jsbn/-/ecc-jsbn-0.1.2.tgz#3a83a904e54353287874c564b7549386849a98c9"
Expand Down

0 comments on commit c4f72a8

Please sign in to comment.