@itentialopensource/adapter-mockdevice 2.0.0 → 2.1.0
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.
- package/AUTH.md +10 -0
- package/CHANGELOG.md +16 -0
- package/CODE_OF_CONDUCT.md +43 -0
- package/CONTRIBUTING.md +13 -0
- package/ENHANCE.md +69 -0
- package/adapter.js +3 -0
- package/changelogs/CHANGELOG.md +15 -0
- package/error.json +190 -0
- package/metadata.json +47 -0
- package/package.json +11 -11
- package/propertiesDecorators.json +14 -0
- package/refs?service=git-upload-pack +0 -0
- package/utils/adapterInfo.js +206 -0
- package/utils/artifactize.js +1 -1
- package/utils/packModificationScript.js +1 -1
- package/utils/removeHooks.js +20 -0
- package/utils/testRunner.js +17 -17
package/AUTH.md
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
## Authenticating Mock Device Adapter
|
|
2
|
+
|
|
3
|
+
This document will go through the steps for authenticating the Mock Device adapter with. Properly configuring the properties for an adapter in IAP is critical for getting the adapter online. You can read more about adapter authentication <a href="https://docs.itential.com/opensource/docs/authentication" target="_blank">HERE</a>.
|
|
4
|
+
|
|
5
|
+
### Authentication
|
|
6
|
+
|
|
7
|
+
### Troubleshooting
|
|
8
|
+
- Make sure you copied over the correct username and password.
|
|
9
|
+
- Turn on debug level logs for the adapter in IAP Admin Essentials.
|
|
10
|
+
- Investigate the logs
|
package/CHANGELOG.md
CHANGED
|
@@ -1,4 +1,20 @@
|
|
|
1
1
|
|
|
2
|
+
## 2.1.0 [01-08-2024]
|
|
3
|
+
|
|
4
|
+
* 2023 migration changes
|
|
5
|
+
|
|
6
|
+
See merge request itentialopensource/adapters/adapter-mockdevice!15
|
|
7
|
+
|
|
8
|
+
---
|
|
9
|
+
|
|
10
|
+
## 2.0.1 [08-11-2023]
|
|
11
|
+
|
|
12
|
+
* Add response code to getConfig
|
|
13
|
+
|
|
14
|
+
See merge request itentialopensource/adapters/adapter-mockdevice!13
|
|
15
|
+
|
|
16
|
+
---
|
|
17
|
+
|
|
2
18
|
## 2.0.0 [06-01-2023]
|
|
3
19
|
|
|
4
20
|
* Major/adapt 2666
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
# Contributor Covenant Code of Conduct
|
|
2
|
+
|
|
3
|
+
## Our Pledge
|
|
4
|
+
|
|
5
|
+
In the interest of fostering an open and welcoming environment, we as contributors and maintainers pledge to making participation in our project and our community a harassment-free experience for everyone, regardless of age, body size, disability, ethnicity, gender identity and expression, level of experience, nationality, personal appearance, race, religion, or sexual identity and orientation.
|
|
6
|
+
|
|
7
|
+
## Our Standards
|
|
8
|
+
|
|
9
|
+
Examples of behavior that contributes to creating a positive environment include:
|
|
10
|
+
|
|
11
|
+
- Using welcoming and inclusive language
|
|
12
|
+
- Being respectful of differing viewpoints and experiences
|
|
13
|
+
- Gracefully accepting constructive criticism
|
|
14
|
+
- Focusing on what is best for the community
|
|
15
|
+
- Showing empathy towards other community members
|
|
16
|
+
|
|
17
|
+
Examples of unacceptable behavior by participants include:
|
|
18
|
+
|
|
19
|
+
- The use of sexualized language or imagery and unwelcome sexual attention or advances
|
|
20
|
+
- Trolling, insulting/derogatory comments, and personal or political attacks
|
|
21
|
+
- Public or private harassment
|
|
22
|
+
- Publishing others' private information, such as a physical or electronic address, without explicit permission
|
|
23
|
+
- Other conduct which could reasonably be considered inappropriate in a professional setting
|
|
24
|
+
|
|
25
|
+
## Our Responsibilities
|
|
26
|
+
|
|
27
|
+
Project maintainers are responsible for clarifying the standards of acceptable behavior and are expected to take appropriate and fair corrective action in response to any instances of unacceptable behavior.
|
|
28
|
+
|
|
29
|
+
Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, or to ban temporarily or permanently any contributor for other behaviors that they deem inappropriate, threatening, offensive, or harmful.
|
|
30
|
+
|
|
31
|
+
## Scope
|
|
32
|
+
|
|
33
|
+
This Code of Conduct applies both within project spaces and in public spaces when an individual is representing the project or its community. Examples of representing a project or community include using an official project e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event. Representation of a project may be further defined and clarified by project maintainers.
|
|
34
|
+
|
|
35
|
+
## Enforcement
|
|
36
|
+
|
|
37
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by contacting the project team at support@itential.com. All complaints will be reviewed and investigated and will result in a response that is deemed necessary and appropriate to the circumstances. The project team is obligated to maintain confidentiality with regard to the reporter of an incident. Further details of specific enforcement policies may be posted separately.
|
|
38
|
+
|
|
39
|
+
Project maintainers who do not follow or enforce the Code of Conduct in good faith may face temporary or permanent repercussions as determined by other members of the project's leadership.
|
|
40
|
+
|
|
41
|
+
## Attribution
|
|
42
|
+
|
|
43
|
+
This Code of Conduct is adapted from the <a href="http://contributor-covenant.org" target="_blank">Contributor Covenant</a>, version 1.4, available at <a href="http://contributor-covenant.org/version/1/4/" target="_blank">version</a>
|
package/CONTRIBUTING.md
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
# Contributing
|
|
2
|
+
|
|
3
|
+
First off, thanks for taking the time to contribute!
|
|
4
|
+
|
|
5
|
+
The following is a set of rules for contributing.
|
|
6
|
+
|
|
7
|
+
## Code of Conduct
|
|
8
|
+
|
|
9
|
+
This project and everyone participating in it is governed by the Code of Conduct. By participating, you are expected to uphold this code. Please report unacceptable behavior to support@itential.com.
|
|
10
|
+
|
|
11
|
+
## How to Contribute
|
|
12
|
+
|
|
13
|
+
Follow the contributing guide (here)[https://gitlab.com/itentialopensource/adapters/contributing-guide]
|
package/ENHANCE.md
ADDED
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
## Enhancements
|
|
2
|
+
|
|
3
|
+
### Adding a Second Instance of an Adapter
|
|
4
|
+
|
|
5
|
+
You can add a second instance of this adapter without adding new code on the file system. To do this go into the IAP Admin Essentials and add a new service config for this adapter. The two instances of the adapter should have unique ids. In addition, they should point to different instances (unique host and port) of the other system.
|
|
6
|
+
|
|
7
|
+
### Adding Adapter Calls
|
|
8
|
+
|
|
9
|
+
There are multiple ways to add calls to an existing adapter.
|
|
10
|
+
|
|
11
|
+
The easiest way would be to use the Adapter Builder update process. This process takes in a Swagger or OpenAPI document, allows you to select the calls you want to add and then generates a zip file that can be used to update the adapter. Once you have the zip file simply put it in the adapter directory and execute `npm run adapter:update`.
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
mv updatePackage.zip adapter-mockdevice
|
|
15
|
+
cd adapter-mockdevice
|
|
16
|
+
npm run adapter:update
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
If you do not have a Swagger or OpenAPI document, you can use a Postman Collection and convert that to an OpenAPI document using APIMatic and then follow the first process.
|
|
20
|
+
|
|
21
|
+
If you want to manually update the adapter that can also be done the key thing is to make sure you update all of the right files. Within the entities directory you will find 1 or more entities. You can create a new entity or add to an existing entity. Each entity has an action.json file, any new call will need to be put in the action.json file. It will also need to be added to the enum for the ph_request_type in the appropriate schema files. Once this configuration is complete you will need to add the call to the adapter.js file and, in order to make it available as a workflow task in IAP, it should also be added to the pronghorn.json file. You can optionally add it to the unit and integration test files. There is more information on how to work on each of these files in the <a href="https://docs.itential.com/opensource/docs/adapters" target="_blank">Adapter Technical Resources</a> on our Documentation Site.
|
|
22
|
+
|
|
23
|
+
```text
|
|
24
|
+
Files to update
|
|
25
|
+
* entities/<entity>/action.json: add an action
|
|
26
|
+
* entities/<entity>/schema.json (or the schema defined on the action): add action to the enum for ph_request_type
|
|
27
|
+
* adapter.js: add the new method and make sure it calls the proper entity and action
|
|
28
|
+
* pronghorn.json: add the new method
|
|
29
|
+
* test/unit/adapterTestUnit.js (optional but best practice): add unit test(s) - function is there, any required parameters error when not passed in
|
|
30
|
+
* test/integration/adapterTestIntegration.js (optional but best practice): add integration test
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
### Adding Adapter Properties
|
|
34
|
+
|
|
35
|
+
While changing adapter properties is done in the service instance configuration section of IAP, adding properties has to be done in the adapter. To add a property you should edit the propertiesSchema.json with the proper information for the property. In addition, you should modify the sampleProperties to have the new property in it.
|
|
36
|
+
|
|
37
|
+
```text
|
|
38
|
+
Files to update
|
|
39
|
+
* propertiesSchema.json: add the new property and how it is defined
|
|
40
|
+
* sampleProperties: add the new property with a default value
|
|
41
|
+
* test/unit/adapterTestUnit.js (optional but best practice): add the property to the global properties
|
|
42
|
+
* test/integration/adapterTestIntegration.js (optional but best practice): add the property to the global properties
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
### Changing Adapter Authentication
|
|
46
|
+
|
|
47
|
+
Often an adapter is built before knowing the authentication and authentication processes can also change over time. The adapter supports many different kinds of authentication but it does require configuration. Some forms of authentication can be defined entirely with the adapter properties but others require configuration.
|
|
48
|
+
|
|
49
|
+
```text
|
|
50
|
+
Files to update
|
|
51
|
+
* entities/.system/action.json: change the getToken action as needed
|
|
52
|
+
* entities/.system/schemaTokenReq.json: add input parameters (external name is name in other system)
|
|
53
|
+
* entities/.system/schemaTokenResp.json: add response parameters (external name is name in other system)
|
|
54
|
+
* propertiesSchema.json: add any new property and how it is defined
|
|
55
|
+
* sampleProperties: add any new property with a default value
|
|
56
|
+
* test/unit/adapterTestUnit.js (optional but best practice): add the property to the global properties
|
|
57
|
+
* test/integration/adapterTestIntegration.js (optional but best practice): add the property to the global properties
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
### Enhancing Adapter Integration Tests
|
|
61
|
+
|
|
62
|
+
The adapter integration tests are written to be able to test in either stub (standalone) mode or integrated to the other system. However, if integrating to the other system, you may need to provide better data than what the adapter provides by default as that data is likely to fail for create and update. To provide better data, edit the adapter integration test file. Make sure you do not remove the marker and keep custom code below the marker so you do not impact future migrations. Once the edits are complete, run the integration test as it instructs you to above. When you run integrated to the other system, you can also save mockdata for future use by changing the isSaveMockData flag to true.
|
|
63
|
+
|
|
64
|
+
```text
|
|
65
|
+
Files to update
|
|
66
|
+
* test/integration/adapterTestIntegration.js: add better data for the create and update calls so that they will not fail.
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
As mentioned previously, for most of these changes as well as other possible changes, there is more information on how to work on an adapter in the <a href="https://docs.itential.com/opensource/docs/adapters" target="_blank">Adapter Technical Resources</a> on our Documentation Site.
|
package/adapter.js
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
// Set globals
|
|
2
2
|
/* global database pronghornProps log eventSystem */
|
|
3
|
+
/* eslint default-param-last: warn */
|
|
4
|
+
|
|
3
5
|
const path = require('path');
|
|
4
6
|
const fs = require('fs');
|
|
5
7
|
const { unzip } = require('zlib');
|
|
@@ -318,6 +320,7 @@ class MockDevice {
|
|
|
318
320
|
});
|
|
319
321
|
}
|
|
320
322
|
return callback({
|
|
323
|
+
code: 200,
|
|
321
324
|
device: deviceId,
|
|
322
325
|
config: result.config
|
|
323
326
|
});
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
## 2.0.1 [08-11-2023]
|
|
2
|
+
|
|
3
|
+
* Add response code to getConfig
|
|
4
|
+
|
|
5
|
+
See merge request itentialopensource/adapters/adapter-mockdevice!13
|
|
6
|
+
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
## 2.0.0 [06-01-2023]
|
|
10
|
+
|
|
11
|
+
* Major/adapt 2666
|
|
12
|
+
|
|
13
|
+
See merge request itentialopensource/adapters/staging/adapter-mockdevice!12
|
|
14
|
+
|
|
15
|
+
---
|
package/error.json
ADDED
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
{
|
|
2
|
+
"errors": [
|
|
3
|
+
{
|
|
4
|
+
"key": "Unable To Save To Database",
|
|
5
|
+
"icode": "AD.100",
|
|
6
|
+
"displayString": "Error on saving to Database $VARIABLE$",
|
|
7
|
+
"recommendation": "Verify the database connectivity and credentials"
|
|
8
|
+
},
|
|
9
|
+
{
|
|
10
|
+
"key": "Database Error",
|
|
11
|
+
"icode": "AD.101",
|
|
12
|
+
"displayString": "Database Error: $VARIABLE$",
|
|
13
|
+
"recommendation": "Verify the database connectivity, schema and permissions"
|
|
14
|
+
},
|
|
15
|
+
{
|
|
16
|
+
"key": "Database Credentials",
|
|
17
|
+
"icode": "AD.102",
|
|
18
|
+
"displayString": "Database Error: Invalid Credentials",
|
|
19
|
+
"recommendation": "Verify the database credentials"
|
|
20
|
+
},
|
|
21
|
+
{
|
|
22
|
+
"key": "No Queue Item",
|
|
23
|
+
"icode": "AD.110",
|
|
24
|
+
"displayString": "Queue Item $VARIABLE$ not found in queue",
|
|
25
|
+
"recommendation": "Make sure the queue is working properly"
|
|
26
|
+
},
|
|
27
|
+
{
|
|
28
|
+
"key": "Unable To Create Queue",
|
|
29
|
+
"icode": "AD.111",
|
|
30
|
+
"displayString": "Unable to create queue: $VARIABLE$",
|
|
31
|
+
"recommendation": "Verify access to the database, redis or system memory"
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
"key": "Queue Full",
|
|
35
|
+
"icode": "AD.112",
|
|
36
|
+
"displayString": "Request $VARIABLE$ Transaction $VARIABLE$ rejected - queue full at $VARIABLE$",
|
|
37
|
+
"recommendation": "Make sure the queue is working properly"
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
"key": "Unable To Clear Queue",
|
|
41
|
+
"icode": "AD.113",
|
|
42
|
+
"displayString": "Unable to clear queue: $VARIABLE$",
|
|
43
|
+
"recommendation": "Make sure the queue exists"
|
|
44
|
+
},
|
|
45
|
+
{
|
|
46
|
+
"key": "Unable To Claim Turn",
|
|
47
|
+
"icode": "AD.114",
|
|
48
|
+
"displayString": "Request $VARIABLE$ Transaction $VARIABLE$ unable to claim license: $VARIABLE$",
|
|
49
|
+
"recommendation": "Make sure the queue is working properly"
|
|
50
|
+
},
|
|
51
|
+
{
|
|
52
|
+
"key": "Unable To Free Turn",
|
|
53
|
+
"icode": "AD.115",
|
|
54
|
+
"displayString": "Request $VARIABLE$ Transaction $VARIABLE$ unable to free license: $VARIABLE$",
|
|
55
|
+
"recommendation": "Make sure the queue is working properly"
|
|
56
|
+
},
|
|
57
|
+
{
|
|
58
|
+
"key": "Item In Wrong State",
|
|
59
|
+
"icode": "AD.116",
|
|
60
|
+
"displayString": "Queue item is in the wrong state: $VARIABLE$ ",
|
|
61
|
+
"recommendation": "Make sure the queue is working properly"
|
|
62
|
+
},
|
|
63
|
+
{
|
|
64
|
+
"key": "Missing Data",
|
|
65
|
+
"icode": "AD.300",
|
|
66
|
+
"displayString": "$VARIABLE$ is required",
|
|
67
|
+
"recommendation": "Please provide the required data"
|
|
68
|
+
},
|
|
69
|
+
{
|
|
70
|
+
"key": "Missing File",
|
|
71
|
+
"icode": "AD.301",
|
|
72
|
+
"displayString": "Can not open file $VARIABLE$",
|
|
73
|
+
"recommendation": "Verify the file exists and has proper permissions"
|
|
74
|
+
},
|
|
75
|
+
{
|
|
76
|
+
"key": "Invalid Action File",
|
|
77
|
+
"icode": "AD.302",
|
|
78
|
+
"displayString": "Invalid action file: $VARIABLE$ in $VARIABLE$",
|
|
79
|
+
"recommendation": "Verify the action file"
|
|
80
|
+
},
|
|
81
|
+
{
|
|
82
|
+
"key": "Unsupported Protocol",
|
|
83
|
+
"icode": "AD.303",
|
|
84
|
+
"displayString": "Protocol $VARIABLE$ not currently supported",
|
|
85
|
+
"recommendation": "Verify the protocol on the action"
|
|
86
|
+
},
|
|
87
|
+
{
|
|
88
|
+
"key": "Invalid Schema File",
|
|
89
|
+
"icode": "AD.304",
|
|
90
|
+
"displayString": "Invalid schema file: $VARIABLE$ in $VARIABLE$",
|
|
91
|
+
"recommendation": "Verify the action file"
|
|
92
|
+
},
|
|
93
|
+
{
|
|
94
|
+
"key": "Invalid Properties",
|
|
95
|
+
"icode": "AD.305",
|
|
96
|
+
"displayString": "Invalid properties: $VARIABLE$",
|
|
97
|
+
"recommendation": "Verify the properties for the adapter"
|
|
98
|
+
},
|
|
99
|
+
{
|
|
100
|
+
"key": "Missing Properties",
|
|
101
|
+
"icode": "AD.306",
|
|
102
|
+
"displayString": "Property $VARIABLE$ is required",
|
|
103
|
+
"recommendation": "Please provide the required property"
|
|
104
|
+
},
|
|
105
|
+
{
|
|
106
|
+
"key": "Query Not Translated",
|
|
107
|
+
"icode": "AD.310",
|
|
108
|
+
"displayString": "Query Not Translated",
|
|
109
|
+
"recommendation": "Verify the information passed in the query object"
|
|
110
|
+
},
|
|
111
|
+
{
|
|
112
|
+
"key": "Payload Not Translated",
|
|
113
|
+
"icode": "AD.311",
|
|
114
|
+
"displayString": "Payload Not Translated",
|
|
115
|
+
"recommendation": "Verify the information passed in the payload object"
|
|
116
|
+
},
|
|
117
|
+
{
|
|
118
|
+
"key": "Schema Validation Failure",
|
|
119
|
+
"icode": "AD.312",
|
|
120
|
+
"displayString": "Schema validation failed on $VARIABLE$",
|
|
121
|
+
"recommendation": "Verify the information provided is in the correct format with everything required"
|
|
122
|
+
},
|
|
123
|
+
{
|
|
124
|
+
"key": "Entity Cache Not Loading",
|
|
125
|
+
"icode": "AD.320",
|
|
126
|
+
"displayString": "Could not load entity: $VARIABLE$, into cache",
|
|
127
|
+
"recommendation": "Verify the cache is working properly"
|
|
128
|
+
},
|
|
129
|
+
{
|
|
130
|
+
"key": "Error Verifying Entity Cache",
|
|
131
|
+
"icode": "AD.321",
|
|
132
|
+
"displayString": "Could not verify entity in cache",
|
|
133
|
+
"recommendation": "Verify the cache is working properly"
|
|
134
|
+
},
|
|
135
|
+
{
|
|
136
|
+
"key": "Unable To Authenticate",
|
|
137
|
+
"icode": "AD.400",
|
|
138
|
+
"displayString": "Unable to authenticate with $VARIABLE$, response $VARIABLE$",
|
|
139
|
+
"recommendation": "Verify the user credentials and check the response for more information"
|
|
140
|
+
},
|
|
141
|
+
{
|
|
142
|
+
"key": "Unable To Encode",
|
|
143
|
+
"icode": "AD.401",
|
|
144
|
+
"displayString": "Can not perform base64 encoding on $VARIABLE$",
|
|
145
|
+
"recommendation": "Check the authentication format"
|
|
146
|
+
},
|
|
147
|
+
{
|
|
148
|
+
"key": "Unable To Get Token",
|
|
149
|
+
"icode": "AD.402",
|
|
150
|
+
"displayString": "Unable to get token for user: $VARIABLE$",
|
|
151
|
+
"recommendation": "Verify the user credentials and the system information"
|
|
152
|
+
},
|
|
153
|
+
{
|
|
154
|
+
"key": "Error On Request",
|
|
155
|
+
"icode": "AD.500",
|
|
156
|
+
"displayString": "Error $VARIABLE$ received on request",
|
|
157
|
+
"recommendation": "Verify the request is accurate via debug logs and postman"
|
|
158
|
+
},
|
|
159
|
+
{
|
|
160
|
+
"key": "Request Timeout",
|
|
161
|
+
"icode": "AD.501",
|
|
162
|
+
"displayString": "The Adapter has run out of time for the request",
|
|
163
|
+
"recommendation": "Increase your adapter request.attempt_timeout property"
|
|
164
|
+
},
|
|
165
|
+
{
|
|
166
|
+
"key": "Invalid Response",
|
|
167
|
+
"icode": "AD.502",
|
|
168
|
+
"displayString": "Invalid response received for $VARIABLE$",
|
|
169
|
+
"recommendation": "Verify the request is accurate via debug logs and postman"
|
|
170
|
+
},
|
|
171
|
+
{
|
|
172
|
+
"key": "Failure Response",
|
|
173
|
+
"icode": "AD.503",
|
|
174
|
+
"displayString": "Failure response received for $VARIABLE$",
|
|
175
|
+
"recommendation": "Check the reason for failure in the stack trace"
|
|
176
|
+
},
|
|
177
|
+
{
|
|
178
|
+
"key": "Suspended Adapter",
|
|
179
|
+
"icode": "AD.600",
|
|
180
|
+
"displayString": "Adapter is suspended",
|
|
181
|
+
"recommendation": "Check if external system is functional and unsuspend if appropriate"
|
|
182
|
+
},
|
|
183
|
+
{
|
|
184
|
+
"key": "Caught Exception",
|
|
185
|
+
"icode": "AD.900",
|
|
186
|
+
"displayString": "Caught Exception $VARIABLE$",
|
|
187
|
+
"recommendation": "Evaluate why the exception took place"
|
|
188
|
+
}
|
|
189
|
+
]
|
|
190
|
+
}
|
package/metadata.json
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "adapter-mockdevice",
|
|
3
|
+
"webName": "Adapter for Integration to Mockdevice",
|
|
4
|
+
"vendor": "Mockdevice",
|
|
5
|
+
"product": "Mockdevice",
|
|
6
|
+
"osVersion": [],
|
|
7
|
+
"apiVersions": [],
|
|
8
|
+
"iapVersions": [
|
|
9
|
+
"2021.1.x",
|
|
10
|
+
"2021.2.x",
|
|
11
|
+
"2022.1.x",
|
|
12
|
+
"2023.1.x"
|
|
13
|
+
],
|
|
14
|
+
"method": "Library",
|
|
15
|
+
"type": "Adapter",
|
|
16
|
+
"domains": [],
|
|
17
|
+
"tags": [],
|
|
18
|
+
"useCases": [],
|
|
19
|
+
"deprecated": {
|
|
20
|
+
"isDeprecated": false
|
|
21
|
+
},
|
|
22
|
+
"brokerSince": "",
|
|
23
|
+
"documentation": {
|
|
24
|
+
"storeLink": "",
|
|
25
|
+
"npmLink": "https://www.npmjs.com/package/@itentialopensource/adapter-mockdevice",
|
|
26
|
+
"repoLink": "https://gitlab.com/itentialopensource/adapters/adapter-mockdevice",
|
|
27
|
+
"docLink": "",
|
|
28
|
+
"demoLinks": [],
|
|
29
|
+
"trainingLinks": [],
|
|
30
|
+
"faqLink": "https://docs.itential.com/opensource/docs/troubleshooting-an-adapter",
|
|
31
|
+
"contributeLink": "https://gitlab.com/itentialopensource/adapters/contributing-guide",
|
|
32
|
+
"issueLink": "https://itential.atlassian.net/servicedesk/customer/portals",
|
|
33
|
+
"webLink": "",
|
|
34
|
+
"vendorLink": "",
|
|
35
|
+
"productLink": "",
|
|
36
|
+
"apiLinks": []
|
|
37
|
+
},
|
|
38
|
+
"assets": [],
|
|
39
|
+
"relatedItems": {
|
|
40
|
+
"adapters": [],
|
|
41
|
+
"integrations": [],
|
|
42
|
+
"ecosystemApplications": [],
|
|
43
|
+
"workflowProjects": [],
|
|
44
|
+
"transformationProjects": [],
|
|
45
|
+
"exampleProjects": []
|
|
46
|
+
}
|
|
47
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@itentialopensource/adapter-mockdevice",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.1.0",
|
|
4
4
|
"description": "mock implementation of device broker",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"repository": {
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
},
|
|
17
17
|
"scripts": {
|
|
18
18
|
"artifactize": "npm i && node utils/packModificationScript.js",
|
|
19
|
-
"preinstall": "node utils/setup.js
|
|
19
|
+
"preinstall": "node utils/setup.js",
|
|
20
20
|
"deinstall": "node utils/removeHooks.js",
|
|
21
21
|
"lint": "node --max_old_space_size=4096 ./node_modules/eslint/bin/eslint.js . --ext .json --ext .js",
|
|
22
22
|
"test:integration": "mocha test/integration/adapterTestIntegration.js --LOG=error",
|
|
@@ -38,22 +38,22 @@
|
|
|
38
38
|
"Pre-Release"
|
|
39
39
|
],
|
|
40
40
|
"dependencies": {
|
|
41
|
-
"ajv": "^8.
|
|
41
|
+
"ajv": "^8.12.0",
|
|
42
42
|
"axios": "^0.21.0",
|
|
43
43
|
"esprima": "^4.0.1",
|
|
44
|
-
"fs-extra": "^
|
|
45
|
-
"package-json-validator": "^0.6.3",
|
|
44
|
+
"fs-extra": "^11.1.1",
|
|
46
45
|
"readline-sync": "^1.4.10",
|
|
47
|
-
"semver": "^7.
|
|
46
|
+
"semver": "^7.5.4"
|
|
48
47
|
},
|
|
49
48
|
"devDependencies": {
|
|
50
|
-
"chai": "^4.3.
|
|
51
|
-
"eslint": "^
|
|
49
|
+
"chai": "^4.3.7",
|
|
50
|
+
"eslint": "^8.44.0",
|
|
51
|
+
"eslint-config-airbnb-base": "^15.0.0",
|
|
52
|
+
"eslint-plugin-import": "^2.27.5",
|
|
53
|
+
"eslint-plugin-json": "^3.1.0",
|
|
52
54
|
"eslint-config-airbnb": "^18.2.1",
|
|
53
55
|
"eslint-config-prettier": "^8.1.0",
|
|
54
|
-
"eslint-plugin-import": "^2.22.1",
|
|
55
56
|
"eslint-plugin-jsdoc": "^32.3.0",
|
|
56
|
-
"eslint-plugin-json": "^2.1.2",
|
|
57
57
|
"eslint-plugin-mocha": "^8.1.0",
|
|
58
58
|
"eslint-plugin-node": "^11.1.0",
|
|
59
59
|
"eslint-plugin-prettier": "^3.3.1",
|
|
@@ -69,7 +69,7 @@
|
|
|
69
69
|
"prettier-plugin-package": "^1.3.0",
|
|
70
70
|
"pretty-quick": "^3.1.0",
|
|
71
71
|
"shellcheck": "^1.0.0",
|
|
72
|
-
"testdouble": "^3.
|
|
72
|
+
"testdouble": "^3.18.0",
|
|
73
73
|
"winston": "^3.3.3"
|
|
74
74
|
},
|
|
75
75
|
"lint-staged": {
|
|
Binary file
|
|
@@ -0,0 +1,206 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/* @copyright Itential, LLC 2019 */
|
|
3
|
+
/* eslint global-require:warn */
|
|
4
|
+
/* eslint import/no-dynamic-require:warn */
|
|
5
|
+
/* eslint prefer-destructuring:warn */
|
|
6
|
+
|
|
7
|
+
const path = require('path');
|
|
8
|
+
const fs = require('fs-extra');
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* This script will determine the information about the adapter and store
|
|
12
|
+
* it into a file in the adapter.
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* get adapter information
|
|
17
|
+
*/
|
|
18
|
+
function adapterInfo() {
|
|
19
|
+
// set the base pase of the adapter - tool shoud be one level up in utils
|
|
20
|
+
let adaptdir = __dirname;
|
|
21
|
+
const infoRes = {};
|
|
22
|
+
|
|
23
|
+
if (adaptdir.endsWith('/utils')) {
|
|
24
|
+
adaptdir = adaptdir.substring(0, adaptdir.length - 6);
|
|
25
|
+
}
|
|
26
|
+
const pack = require(`${adaptdir}/package.json`);
|
|
27
|
+
infoRes.version = pack.version;
|
|
28
|
+
|
|
29
|
+
let configCount = 0;
|
|
30
|
+
if (fs.existsSync(`${adaptdir}/pronghorn.json`)) {
|
|
31
|
+
const cFile = fs.readFileSync(`${adaptdir}/pronghorn.json`, 'utf8');
|
|
32
|
+
configCount += cFile.split('\n').length;
|
|
33
|
+
} else {
|
|
34
|
+
console.log('Missing - pronghorn.json');
|
|
35
|
+
}
|
|
36
|
+
if (fs.existsSync(`${adaptdir}/propertiesSchema.json`)) {
|
|
37
|
+
const cFile = fs.readFileSync(`${adaptdir}/propertiesSchema.json`, 'utf8');
|
|
38
|
+
configCount += cFile.split('\n').length;
|
|
39
|
+
} else {
|
|
40
|
+
console.log('Missing - propertiesSchema.json');
|
|
41
|
+
}
|
|
42
|
+
if (fs.existsSync(`${adaptdir}/error.json`)) {
|
|
43
|
+
const cFile = fs.readFileSync(`${adaptdir}/error.json`, 'utf8');
|
|
44
|
+
configCount += cFile.split('\n').length;
|
|
45
|
+
} else {
|
|
46
|
+
console.log('Missing - error.json');
|
|
47
|
+
}
|
|
48
|
+
const entitydir = path.join(adaptdir, '/entities');
|
|
49
|
+
if (fs.existsSync(entitydir) && fs.statSync(entitydir).isDirectory()) {
|
|
50
|
+
const entities = fs.readdirSync(entitydir);
|
|
51
|
+
// need to go through each entity in the entities directory
|
|
52
|
+
for (let e = 0; e < entities.length; e += 1) {
|
|
53
|
+
if (fs.statSync(`${entitydir}/${entities[e]}`).isDirectory()) {
|
|
54
|
+
const cfiles = fs.readdirSync(entitydir);
|
|
55
|
+
for (let c = 0; c < cfiles.length; c += 1) {
|
|
56
|
+
if (cfiles[c].endsWith('.json')) {
|
|
57
|
+
const ccFile = fs.readFileSync(`${entitydir}/${entities[e]}/${cfiles[c]}`, 'utf8');
|
|
58
|
+
configCount += ccFile.split('\n').length;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
} else {
|
|
64
|
+
console.log('Could not find the entities directory');
|
|
65
|
+
}
|
|
66
|
+
infoRes.configLines = configCount;
|
|
67
|
+
|
|
68
|
+
let scodeCount = 0;
|
|
69
|
+
if (fs.existsSync(`${adaptdir}/utils/artifactize.js`)) {
|
|
70
|
+
const sFile = fs.readFileSync(`${adaptdir}/utils/artifactize.js`, 'utf8');
|
|
71
|
+
scodeCount += sFile.split('\n').length;
|
|
72
|
+
} else {
|
|
73
|
+
console.log('Missing - utils/artifactize.js');
|
|
74
|
+
}
|
|
75
|
+
if (fs.existsSync(`${adaptdir}/utils/basicGet.js`)) {
|
|
76
|
+
const sFile = fs.readFileSync(`${adaptdir}/utils/basicGet.js`, 'utf8');
|
|
77
|
+
scodeCount += sFile.split('\n').length;
|
|
78
|
+
} else {
|
|
79
|
+
console.log('Missing - utils/basicGet.js');
|
|
80
|
+
}
|
|
81
|
+
if (fs.existsSync(`${adaptdir}/utils/checkMigrate.js`)) {
|
|
82
|
+
const sFile = fs.readFileSync(`${adaptdir}/utils/checkMigrate.js`, 'utf8');
|
|
83
|
+
scodeCount += sFile.split('\n').length;
|
|
84
|
+
} else {
|
|
85
|
+
console.log('Missing - utils/checkMigrate.js');
|
|
86
|
+
}
|
|
87
|
+
if (fs.existsSync(`${adaptdir}/utils/findPath.js`)) {
|
|
88
|
+
const sFile = fs.readFileSync(`${adaptdir}/utils/findPath.js`, 'utf8');
|
|
89
|
+
scodeCount += sFile.split('\n').length;
|
|
90
|
+
} else {
|
|
91
|
+
console.log('Missing - utils/findPath.js');
|
|
92
|
+
}
|
|
93
|
+
if (fs.existsSync(`${adaptdir}/utils/modify.js`)) {
|
|
94
|
+
const sFile = fs.readFileSync(`${adaptdir}/utils/modify.js`, 'utf8');
|
|
95
|
+
scodeCount += sFile.split('\n').length;
|
|
96
|
+
} else {
|
|
97
|
+
console.log('Missing - utils/modify.js');
|
|
98
|
+
}
|
|
99
|
+
if (fs.existsSync(`${adaptdir}/utils/packModificationScript.js`)) {
|
|
100
|
+
const sFile = fs.readFileSync(`${adaptdir}/utils/packModificationScript.js`, 'utf8');
|
|
101
|
+
scodeCount += sFile.split('\n').length;
|
|
102
|
+
} else {
|
|
103
|
+
console.log('Missing - utils/packModificationScript.js');
|
|
104
|
+
}
|
|
105
|
+
if (fs.existsSync(`${adaptdir}/utils/setup.js`)) {
|
|
106
|
+
const sFile = fs.readFileSync(`${adaptdir}/utils/setup.js`, 'utf8');
|
|
107
|
+
scodeCount += sFile.split('\n').length;
|
|
108
|
+
} else {
|
|
109
|
+
console.log('Missing - utils/setup.js');
|
|
110
|
+
}
|
|
111
|
+
if (fs.existsSync(`${adaptdir}/utils/tbScript.js`)) {
|
|
112
|
+
const sFile = fs.readFileSync(`${adaptdir}/utils/tbScript.js`, 'utf8');
|
|
113
|
+
scodeCount += sFile.split('\n').length;
|
|
114
|
+
} else {
|
|
115
|
+
console.log('Missing - utils/tbScript.js');
|
|
116
|
+
}
|
|
117
|
+
if (fs.existsSync(`${adaptdir}/utils/tbUtils.js`)) {
|
|
118
|
+
const sFile = fs.readFileSync(`${adaptdir}/utils/tbUtils.js`, 'utf8');
|
|
119
|
+
scodeCount += sFile.split('\n').length;
|
|
120
|
+
} else {
|
|
121
|
+
console.log('Missing - utils/tbUtils.js');
|
|
122
|
+
}
|
|
123
|
+
if (fs.existsSync(`${adaptdir}/utils/testRunner.js`)) {
|
|
124
|
+
const sFile = fs.readFileSync(`${adaptdir}/utils/testRunner.js`, 'utf8');
|
|
125
|
+
scodeCount += sFile.split('\n').length;
|
|
126
|
+
} else {
|
|
127
|
+
console.log('Missing - utils/testRunner.js');
|
|
128
|
+
}
|
|
129
|
+
if (fs.existsSync(`${adaptdir}/utils/troubleshootingAdapter.js`)) {
|
|
130
|
+
const sFile = fs.readFileSync(`${adaptdir}/utils/troubleshootingAdapter.js`, 'utf8');
|
|
131
|
+
scodeCount += sFile.split('\n').length;
|
|
132
|
+
} else {
|
|
133
|
+
console.log('Missing - utils/troubleshootingAdapter.js');
|
|
134
|
+
}
|
|
135
|
+
infoRes.scriptLines = scodeCount;
|
|
136
|
+
|
|
137
|
+
let codeCount = 0;
|
|
138
|
+
if (fs.existsSync(`${adaptdir}/adapter.js`)) {
|
|
139
|
+
const aFile = fs.readFileSync(`${adaptdir}/adapter.js`, 'utf8');
|
|
140
|
+
codeCount += aFile.split('\n').length;
|
|
141
|
+
} else {
|
|
142
|
+
console.log('Missing - utils/adapter.js');
|
|
143
|
+
}
|
|
144
|
+
if (fs.existsSync(`${adaptdir}/adapterBase.js`)) {
|
|
145
|
+
const aFile = fs.readFileSync(`${adaptdir}/adapterBase.js`, 'utf8');
|
|
146
|
+
codeCount += aFile.split('\n').length;
|
|
147
|
+
} else {
|
|
148
|
+
console.log('Missing - utils/adapterBase.js');
|
|
149
|
+
}
|
|
150
|
+
infoRes.codeLines = codeCount;
|
|
151
|
+
|
|
152
|
+
let tcodeCount = 0;
|
|
153
|
+
let ttestCount = 0;
|
|
154
|
+
if (fs.existsSync(`${adaptdir}/test/integration/adapterTestBasicGet.js`)) {
|
|
155
|
+
const tFile = fs.readFileSync(`${adaptdir}/test/integration/adapterTestBasicGet.js`, 'utf8');
|
|
156
|
+
tcodeCount += tFile.split('\n').length;
|
|
157
|
+
ttestCount += tFile.split('it(\'').length;
|
|
158
|
+
} else {
|
|
159
|
+
console.log('Missing - test/integration/adapterTestBasicGet.js');
|
|
160
|
+
}
|
|
161
|
+
if (fs.existsSync(`${adaptdir}/test/integration/adapterTestConnectivity.js`)) {
|
|
162
|
+
const tFile = fs.readFileSync(`${adaptdir}/test/integration/adapterTestConnectivity.js`, 'utf8');
|
|
163
|
+
tcodeCount += tFile.split('\n').length;
|
|
164
|
+
ttestCount += tFile.split('it(\'').length;
|
|
165
|
+
} else {
|
|
166
|
+
console.log('Missing - test/integration/adapterTestConnectivity.js');
|
|
167
|
+
}
|
|
168
|
+
if (fs.existsSync(`${adaptdir}/test/integration/adapterTestIntegration.js`)) {
|
|
169
|
+
const tFile = fs.readFileSync(`${adaptdir}/test/integration/adapterTestIntegration.js`, 'utf8');
|
|
170
|
+
tcodeCount += tFile.split('\n').length;
|
|
171
|
+
ttestCount += tFile.split('it(\'').length;
|
|
172
|
+
} else {
|
|
173
|
+
console.log('Missing - test/integration/adapterTestIntegration.js');
|
|
174
|
+
}
|
|
175
|
+
if (fs.existsSync(`${adaptdir}/test/unit/adapterBaseTestUnit.js`)) {
|
|
176
|
+
const tFile = fs.readFileSync(`${adaptdir}/test/unit/adapterBaseTestUnit.js`, 'utf8');
|
|
177
|
+
tcodeCount += tFile.split('\n').length;
|
|
178
|
+
ttestCount += tFile.split('it(\'').length;
|
|
179
|
+
} else {
|
|
180
|
+
console.log('Missing - test/unit/adapterBaseTestUnit.js');
|
|
181
|
+
}
|
|
182
|
+
if (fs.existsSync(`${adaptdir}/test/unit/adapterTestUnit.js`)) {
|
|
183
|
+
const tFile = fs.readFileSync(`${adaptdir}/test/unit/adapterTestUnit.js`, 'utf8');
|
|
184
|
+
tcodeCount += tFile.split('\n').length;
|
|
185
|
+
ttestCount += tFile.split('it(\'').length;
|
|
186
|
+
} else {
|
|
187
|
+
console.log('Missing - test/unit/adapterTestUnit.js');
|
|
188
|
+
}
|
|
189
|
+
infoRes.testLines = tcodeCount;
|
|
190
|
+
infoRes.testCases = ttestCount;
|
|
191
|
+
infoRes.totalCodeLines = scodeCount + codeCount + tcodeCount;
|
|
192
|
+
|
|
193
|
+
if (fs.existsSync(`${adaptdir}/pronghorn.json`)) {
|
|
194
|
+
// Read the entity schema from the file system
|
|
195
|
+
const phFile = path.join(adaptdir, '/pronghorn.json');
|
|
196
|
+
const prong = require(phFile);
|
|
197
|
+
infoRes.wfTasks = prong.methods.length;
|
|
198
|
+
} else {
|
|
199
|
+
console.log('Missing - pronghorn.json');
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
console.log(JSON.stringify(infoRes));
|
|
203
|
+
fs.writeFileSync(`${adaptdir}/report/adapterInfo.json`, JSON.stringify(infoRes, null, 2));
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
adapterInfo();
|
package/utils/artifactize.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
/* @copyright Itential, LLC 2019 */
|
|
3
3
|
|
|
4
|
-
const fs = require('fs-extra');
|
|
5
4
|
const path = require('path');
|
|
6
5
|
const { spawnSync } = require('child_process');
|
|
6
|
+
const fs = require('fs-extra');
|
|
7
7
|
const { createBundle } = require('./artifactize');
|
|
8
8
|
|
|
9
9
|
const nodeEntryPath = path.resolve('.');
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
const fs = require('fs');
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* This script will uninstall pre-commit or pre-push hooks in case there's ever a need to
|
|
5
|
+
* commit/push something that has issues
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
const precommitPath = '.git/hooks/pre-commit';
|
|
9
|
+
const prepushPath = '.git/hooks/pre-push';
|
|
10
|
+
fs.unlink(precommitPath, (err) => {
|
|
11
|
+
if (err && err.code !== 'ENOENT') {
|
|
12
|
+
console.log(`${err.message}`);
|
|
13
|
+
}
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
fs.unlink(prepushPath, (err) => {
|
|
17
|
+
if (err && err.code !== 'ENOENT') {
|
|
18
|
+
console.log(`${err.message}`);
|
|
19
|
+
}
|
|
20
|
+
});
|
package/utils/testRunner.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
/* @copyright Itential, LLC 2019 */
|
|
3
3
|
|
|
4
|
+
const execute = require('child_process').exec;
|
|
4
5
|
const fs = require('fs-extra');
|
|
5
6
|
const rl = require('readline-sync');
|
|
6
|
-
const execute = require('child_process').exec;
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
9
|
* This script will determine the type of integration test to run
|
|
@@ -47,11 +47,11 @@ function replaceTestVars(test) {
|
|
|
47
47
|
let intTest = fs.readFileSync(test, 'utf8');
|
|
48
48
|
|
|
49
49
|
// replace stub variable but check if it exists first
|
|
50
|
-
let sindex = intTest.indexOf('
|
|
50
|
+
let sindex = intTest.indexOf('samProps.stub');
|
|
51
51
|
let eindex = intTest.indexOf(';', sindex);
|
|
52
52
|
let replStr = intTest.substring(sindex, eindex + 1);
|
|
53
53
|
if (sindex > -1) {
|
|
54
|
-
intTest = intTest.replace(replStr, `
|
|
54
|
+
intTest = intTest.replace(replStr, `samProps.stub = ${stub};`);
|
|
55
55
|
}
|
|
56
56
|
|
|
57
57
|
// replace isRapidFail variable but check if it exists first
|
|
@@ -71,46 +71,46 @@ function replaceTestVars(test) {
|
|
|
71
71
|
}
|
|
72
72
|
|
|
73
73
|
// replace host variable
|
|
74
|
-
sindex = intTest.indexOf('
|
|
74
|
+
sindex = intTest.indexOf('samProps.host');
|
|
75
75
|
eindex = intTest.indexOf(';', sindex);
|
|
76
76
|
replStr = intTest.substring(sindex, eindex + 1);
|
|
77
|
-
intTest = intTest.replace(replStr, `
|
|
77
|
+
intTest = intTest.replace(replStr, `samProps.host = '${host}';`);
|
|
78
78
|
|
|
79
79
|
// replace username variable
|
|
80
|
-
sindex = intTest.indexOf('
|
|
80
|
+
sindex = intTest.indexOf('samProps.authentication.username');
|
|
81
81
|
eindex = intTest.indexOf(';', sindex);
|
|
82
82
|
replStr = intTest.substring(sindex, eindex + 1);
|
|
83
|
-
intTest = intTest.replace(replStr, `
|
|
83
|
+
intTest = intTest.replace(replStr, `samProps.authentication.username = '${username}';`);
|
|
84
84
|
|
|
85
85
|
// replace password variable
|
|
86
|
-
sindex = intTest.indexOf('
|
|
86
|
+
sindex = intTest.indexOf('samProps.authentication.password');
|
|
87
87
|
eindex = intTest.indexOf(';', sindex);
|
|
88
88
|
replStr = intTest.substring(sindex, eindex + 1);
|
|
89
|
-
intTest = intTest.replace(replStr, `
|
|
89
|
+
intTest = intTest.replace(replStr, `samProps.authentication.password = '${password}';`);
|
|
90
90
|
|
|
91
91
|
// replace protocol variable
|
|
92
|
-
sindex = intTest.indexOf('
|
|
92
|
+
sindex = intTest.indexOf('samProps.protocol');
|
|
93
93
|
eindex = intTest.indexOf(';', sindex);
|
|
94
94
|
replStr = intTest.substring(sindex, eindex + 1);
|
|
95
|
-
intTest = intTest.replace(replStr, `
|
|
95
|
+
intTest = intTest.replace(replStr, `samProps.protocol = '${protocol}';`);
|
|
96
96
|
|
|
97
97
|
// replace port variable
|
|
98
|
-
sindex = intTest.indexOf('
|
|
98
|
+
sindex = intTest.indexOf('samProps.port');
|
|
99
99
|
eindex = intTest.indexOf(';', sindex);
|
|
100
100
|
replStr = intTest.substring(sindex, eindex + 1);
|
|
101
|
-
intTest = intTest.replace(replStr, `
|
|
101
|
+
intTest = intTest.replace(replStr, `samProps.port = ${port};`);
|
|
102
102
|
|
|
103
103
|
// replace sslenable variable
|
|
104
|
-
sindex = intTest.indexOf('
|
|
104
|
+
sindex = intTest.indexOf('samProps.ssl.enabled');
|
|
105
105
|
eindex = intTest.indexOf(';', sindex);
|
|
106
106
|
replStr = intTest.substring(sindex, eindex + 1);
|
|
107
|
-
intTest = intTest.replace(replStr, `
|
|
107
|
+
intTest = intTest.replace(replStr, `samProps.ssl.enabled = ${sslenable};`);
|
|
108
108
|
|
|
109
109
|
// replace sslinvalid variable
|
|
110
|
-
sindex = intTest.indexOf('
|
|
110
|
+
sindex = intTest.indexOf('samProps.ssl.accept_invalid_cert');
|
|
111
111
|
eindex = intTest.indexOf(';', sindex);
|
|
112
112
|
replStr = intTest.substring(sindex, eindex + 1);
|
|
113
|
-
intTest = intTest.replace(replStr, `
|
|
113
|
+
intTest = intTest.replace(replStr, `samProps.ssl.accept_invalid_cert = ${sslinvalid};`);
|
|
114
114
|
|
|
115
115
|
console.log(`Updates to ${test} complete`);
|
|
116
116
|
fs.writeFileSync(test, intTest);
|