User Tools
toolsandtechnologies:device_emulator
Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| toolsandtechnologies:device_emulator [2019/04/05 15:14] – rahulpatil | toolsandtechnologies:device_emulator [2021/06/25 10:09] (current) – external edit 127.0.0.1 | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| + | ====== Device-Emulator ====== | ||
| + | |||
| + | Device-Emulator is an application which emulates the behavior of controllers so they don't need to be hit multiple times for data fetching. This application will be primarily used by developers at Errigal on top of their internal apps like RDF, SNMP manager, and can be extended to work with other with minimal/no changes in the existing code-base. | ||
| + | |||
| + | The purpose of the Device Emulator is to provide reliable testing mocks for network devices. This is achieved by establishing a proxied connection between the development machine and the device to be tested and caching the responses corresponding to each request. In practice, this means that the first of any particular request goes straight through to the device, while all subsequent requests receive a cached copy of the response. | ||
| + | |||
| + | The emulator is divided into two parts: the proxy server itself, and the proxy api server for modifying the database of requests and responses. | ||
| + | |||
| + | ===== Repositories ===== | ||
| + | [[https:// | ||
| + | |||
| + | [[https:// | ||
| + | |||
| + | ===== Primary Documentation ===== | ||
| + | [[https:// | ||
| + | |||
| + | ==== Show & Tell Slides ===== | ||
| + | [[https:// | ||
| + | | Presentation]] | ||
| + | The slides were presented on Wednesday, 3rd April 2019. They give a concise definition of the problem statement and other relevant details regarding the project. | ||
| + | |||
| + | ==== Live Versions ==== | ||
| + | The apps are deployed on scotty as follows | ||
| + | |||
| + | Proxy Server - '' | ||
| + | |||
| + | Express Api - '' | ||
| + | FrontEnd - | ||
| + | |||
| + | ==== Device-Emulator Architecture ==== | ||
| + | {{: | ||
| + | |||
| + | === Running the Back-End/ | ||
| + | Prerequisite | ||
| + | |||
| + | Ensure you have Node.js latest stable build installed. The build should be accompanied with '' | ||
| + | |||
| + | * Git clone '' | ||
| + | * CD into device_emulator and make sure you're on the '' | ||
| + | * Run npm install in the project root directory. Once the install completes, the proxy can be started with node express_proxy and the server with node express_server [they will be served on different ports respectively] | ||
| + | * The device emulator expects details of the database to be provided on launch. This can be accomplished with a dbparams file in the working directory, or preferably using environment variables as follows: | ||
| + | DBHOST The host url of the database | ||
| + | |||
| + | username DBUSER The user which the device emulator will be logged in to MySQL as | ||
| + | |||
| + | password DBPASS The password for the database user | ||
| + | |||
| + | database DBNAME The name of the database where our data will be stored | ||
| + | * Additionally, | ||
| + | * If the above steps are completed successfully, | ||
| + | |||
| + | ==== Connecting to the Proxy ==== | ||
| + | To use the device emulator, the end user must adjust their network settings to forward all traffic to the proxy server | ||
| + | |||
| + | Windows | ||
| + | If you are using Windows, open the Internet Options dialog by launching the Control Panel, selecting " | ||
| + | |||
| + | Mac | ||
| + | Open the Network window by opening System Preferences and clicking Network Click the Advanced button with your current network selected Click the Proxies tab and check both HTTP and HTTPS proxies For both protocols, enter the proxy server address and set the port to 3000 Click Ok, then Apply to save the settings | ||
| + | |||
| + | |||
| + | ==== Running HTTPS on Proxy ==== | ||
| + | The proxy runs on port 3000 and provides both a HTTP and HTTPS proxy using the hoxy node.js library. HTTPS is achieved by an imposter server certified by a fake CA which must be explicitly trusted by the development computer to work. Once the proxy is running, it records every request-response pair to pass through it and saves them to a MySQL database. | ||
| + | |||
| + | ==== Trusting the Fake CA certificate ==== | ||
| + | To use the proxy server to access HTTPS endpoints, it is necessary to have the local computer trust the fake CA used by the Device Emulator. The CA cert and key files are saved in the Drive folder for this project, for the purposes of this guide, only the cert file is needed. | ||
| + | |||
| + | [[https:// | ||
| + | |||
| + | Windows | ||
| + | If you're using Microsoft Windows, click the search box on the taskbar or in the Start menu, and type " | ||
| + | |||
| + | Click "Local Computer," | ||
| + | |||
| + | Mac | ||
| + | If you're using an Apple Mac computer, you can import a root certificate for a certificate authority using the Keychain system. | ||
| + | |||
| + | Type " | ||
| + | |||
| + | Enter your password if prompted to do so, and log in and out of the computer, or restart it. If the certificate doesn' | ||
| + | |||
| + | ==== Running the Front-End Locally ==== | ||
| + | |||
| + | ## Overview | ||
| + | |||
| + | Device-Emulator-Front-End is an easy to use user-interface created for the device-emulator project. The purpose of this project is let developers get an overview of the recently called devices through various internal applications along with their request/ | ||
| + | |||
| + | ## Installation requirements. | ||
| + | |||
| + | This application is bootstrapped using [Create-React-App](https:// | ||
| + | To run the project locally, | ||
| + | |||
| + | 1. Git clone this repository | ||
| + | `git clone git@bitbucket.org: | ||
| + | Cd into **device-emulator** | ||
| + | 2. Ensure you've Node/ | ||
| + | - Node : v8.12.0 | ||
| + | - NPM : 6.4.1 | ||
| + | - Yarn : 1.9.4 | ||
| + | 3. It is recommended to use Yarn for downloading all the dependencies. But in it's absence, NPM would do the job. Perform the following commands from inside the project folder (directory where package.json is located) | ||
| + | `yarn install` or `npm install` | ||
| + | |||
| + | 4. Once the dependencies are downloaded, you can run the development project server by `npm start` . This should run the application on one of the available ports and the browser will be directed towards that port. | ||
| + | |||
| + | 5. The environment variables file needs to be created manually (.env) and the data for the same will be sent to via slack. You can copy,paste that data and re-run the application to get the enviroment varibales working. | ||
| + | |||
| + | ## Libraries Used | ||
| + | |||
| + | * [ReactJs](https:// | ||
| + | * [Redux](https:// | ||
| + | * [React-Redux](https:// | ||
| + | * [React-Router](https:// | ||
| + | * [React-Connected-Router](https:// | ||
| + | * [Redux-Thunk](https:// | ||
| + | * [Prettier](https:// | ||
| + | * [ES-Lint](https:// | ||
| + | * [Husky](https:// | ||
| + | * [Axios](https:// | ||
| + | |||
| + | #### Third Party React Web Components | ||
| + | |||
| + | - [Semantic UI React](https:// | ||
| + | |||
| + | #### Style-Guide | ||
| + | |||
| + | - The application uses Semantic UI React components over the traditional semantic UI classes. | ||
| + | - To over-ride the default styles of any component, look for styles.css files inside the components root directory & use ' | ||
| + | |||
| + | |||
| + | |||