Skip to content

Commit af60bd9

Browse files
authored
.env variable prefixed with idoit to prevent collisions with os (#33)
1 parent 47d5979 commit af60bd9

9 files changed

Lines changed: 77 additions & 77 deletions

File tree

.env.dist

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
11
# URL to i-doit API (required):
2-
URL=https://demo.i-doit.com/src/jsonrpc.php
2+
IDOIT_URL=https://demo.i-doit.com/src/jsonrpc.php
33

44
# PORT to i-doit API (optional):
5-
#PORT=8443
5+
#IDOIT_PORT=8443
66

77
# API key to select tenant (required):
8-
KEY=xxx
8+
IDOIT_KEY=xxx
99

1010
# Login with user name (optional):
11-
#USERNAME=admin
11+
#IDOIT_USERNAME=admin
1212

1313
# User's password (optional):
14-
#PASSWORD=admin
14+
#IDOIT_PASSWORD=admin
1515

1616
# Enforce language (optional):
17-
#LANGUAGE=en
17+
#IDOIT_LANGUAGE=en
1818

1919
# Disable security-related cURL options:
20-
#BYPASS_SECURE_CONNECTION=1
20+
#IDOIT_BYPASS_SECURE_CONNECTION=1

tests/Idoit/APIClient/APITest.php

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ public function testRawRequest() {
230230
'jsonrpc' => '2.0',
231231
'method' => 'idoit.version',
232232
'params' => [
233-
'apikey' => getenv('KEY')
233+
'apikey' => getenv('IDOIT_KEY')
234234
],
235235
'id' => 1
236236
];
@@ -252,7 +252,7 @@ public function testRequestWithAdditionalHeaders() {
252252
'jsonrpc' => '2.0',
253253
'method' => 'idoit.version',
254254
'params' => [
255-
'apikey' => getenv('KEY')
255+
'apikey' => getenv('IDOIT_KEY')
256256
],
257257
'id' => 1
258258
];
@@ -460,7 +460,7 @@ public function testRequestWithMissingVersionNumber() {
460460
$request = [
461461
'method' => 'idoit.version',
462462
'params' => [
463-
'apikey' => getenv('KEY')
463+
'apikey' => getenv('IDOIT_KEY')
464464
],
465465
'id' => 1
466466
];
@@ -502,7 +502,7 @@ public function testRequestWithInvalidVersionNumbers($versionNumber) {
502502
'jsonrpc' => $versionNumber,
503503
'method' => 'idoit.version',
504504
'params' => [
505-
'apikey' => getenv('KEY')
505+
'apikey' => getenv('IDOIT_KEY')
506506
],
507507
'id' => 1
508508
];
@@ -541,7 +541,7 @@ public function testRequestWithValidIdentifiers($identifier) {
541541
'jsonrpc' => '2.0',
542542
'method' => 'idoit.version',
543543
'params' => [
544-
'apikey' => getenv('KEY')
544+
'apikey' => getenv('IDOIT_KEY')
545545
],
546546
'id' => $identifier
547547
];
@@ -579,7 +579,7 @@ public function testRequestWithInvalidIdentifiers($identifier) {
579579
'jsonrpc' => '2.0',
580580
'method' => 'idoit.version',
581581
'params' => [
582-
'apikey' => getenv('KEY')
582+
'apikey' => getenv('IDOIT_KEY')
583583
],
584584
'id' => $identifier
585585
];
@@ -600,7 +600,7 @@ public function testRequestWithMissingMethod() {
600600
$request = [
601601
'jsonrpc' => '2.0',
602602
'params' => [
603-
'apikey' => getenv('KEY')
603+
'apikey' => getenv('IDOIT_KEY')
604604
],
605605
'id' => 1
606606
];
@@ -643,7 +643,7 @@ public function testRequestWithInvalidMethods($method) {
643643
'jsonrpc' => '2.0',
644644
'method' => $method,
645645
'params' => [
646-
'apikey' => getenv('KEY')
646+
'apikey' => getenv('IDOIT_KEY')
647647
],
648648
'id' => 1
649649
];
@@ -681,7 +681,7 @@ public function testRequestWithUnknownMethod(string $method) {
681681
'jsonrpc' => '2.0',
682682
'method' => $method,
683683
'params' => [
684-
'apikey' => getenv('KEY')
684+
'apikey' => getenv('IDOIT_KEY')
685685
],
686686
'id' => 1
687687
];
@@ -705,23 +705,23 @@ public function testRepeatingIdentifiersInBatchRequest() {
705705
'jsonrpc' => '2.0',
706706
'method' => 'idoit.version',
707707
'params' => [
708-
'apikey' => getenv('KEY')
708+
'apikey' => getenv('IDOIT_KEY')
709709
],
710710
'id' => 1
711711
],
712712
[
713713
'jsonrpc' => '2.0',
714714
'method' => 'idoit.version',
715715
'params' => [
716-
'apikey' => getenv('KEY')
716+
'apikey' => getenv('IDOIT_KEY')
717717
],
718718
'id' => $this->generateRandomString()
719719
],
720720
[
721721
'jsonrpc' => '2.0',
722722
'method' => 'idoit.version',
723723
'params' => [
724-
'apikey' => getenv('KEY')
724+
'apikey' => getenv('IDOIT_KEY')
725725
],
726726
'id' => 1
727727
]
@@ -746,7 +746,7 @@ public function testVariousApiKeysInBatchRequest() {
746746
'jsonrpc' => '2.0',
747747
'method' => 'idoit.version',
748748
'params' => [
749-
'apikey' => getenv('KEY')
749+
'apikey' => getenv('IDOIT_KEY')
750750
],
751751
'id' => 1
752752
],
@@ -789,7 +789,7 @@ public function testNotification() {
789789
'jsonrpc' => '2.0',
790790
'method' => 'idoit.version',
791791
'params' => [
792-
'apikey' => getenv('KEY')
792+
'apikey' => getenv('IDOIT_KEY')
793793
]
794794
];
795795

@@ -812,21 +812,21 @@ public function testOnlyNotificationsInBatchRequest() {
812812
'jsonrpc' => '2.0',
813813
'method' => 'idoit.version',
814814
'params' => [
815-
'apikey' => getenv('KEY')
815+
'apikey' => getenv('IDOIT_KEY')
816816
]
817817
],
818818
[
819819
'jsonrpc' => '2.0',
820820
'method' => 'cmdb.object.read',
821821
'params' => [
822-
'apikey' => getenv('KEY')
822+
'apikey' => getenv('IDOIT_KEY')
823823
]
824824
],
825825
[
826826
'jsonrpc' => '2.0',
827827
'method' => 'cmdb.category.read',
828828
'params' => [
829-
'apikey' => getenv('KEY')
829+
'apikey' => getenv('IDOIT_KEY')
830830
]
831831
]
832832
];
@@ -847,22 +847,22 @@ public function testSomeNotificationsInBatchRequest() {
847847
'jsonrpc' => '2.0',
848848
'method' => 'idoit.version',
849849
'params' => [
850-
'apikey' => getenv('KEY')
850+
'apikey' => getenv('IDOIT_KEY')
851851
],
852852
'id' => 1
853853
],
854854
[
855855
'jsonrpc' => '2.0',
856856
'method' => 'cmdb.object.read',
857857
'params' => [
858-
'apikey' => getenv('KEY')
858+
'apikey' => getenv('IDOIT_KEY')
859859
]
860860
],
861861
[
862862
'jsonrpc' => '2.0',
863863
'method' => 'cmdb.category.read',
864864
'params' => [
865-
'apikey' => getenv('KEY')
865+
'apikey' => getenv('IDOIT_KEY')
866866
],
867867
'id' => 2
868868
]

tests/Idoit/APIClient/BaseTest.php

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -127,27 +127,27 @@ public static function setUpBeforeClass(): void {
127127
*/
128128
public function setUp(): void {
129129
$config = [
130-
API::URL => getenv('URL'),
131-
API::KEY => getenv('KEY'),
132-
API::BYPASS_SECURE_CONNECTION => getenv('BYPASS_SECURE_CONNECTION')
130+
API::URL => getenv('IDOIT_URL'),
131+
API::KEY => getenv('IDOIT_KEY'),
132+
API::BYPASS_SECURE_CONNECTION => getenv('IDOIT_BYPASS_SECURE_CONNECTION')
133133
];
134134

135-
if (getenv('PORT') !== false) {
136-
$config[API::PORT] = (int) getenv('PORT');
135+
if (getenv('IDOIT_PORT') !== false) {
136+
$config[API::PORT] = (int) getenv('IDOIT_PORT');
137137
}
138138

139139
if (getenv('IDOIT_LANGUAGE') !== false) {
140140
$config[API::LANGUAGE] = getenv('IDOIT_LANGUAGE');
141141
}
142142

143-
if (getenv('USERNAME') !== false && getenv('PASSWORD') !== false) {
144-
$config[API::USERNAME] = getenv('USERNAME');
145-
$config[API::PASSWORD] = getenv('PASSWORD');
143+
if (getenv('IDOIT_USERNAME') !== false && getenv('IDOIT_PASSWORD') !== false) {
144+
$config[API::USERNAME] = getenv('IDOIT_USERNAME');
145+
$config[API::PASSWORD] = getenv('IDOIT_PASSWORD');
146146
}
147147

148-
if (getenv('BYPASS_SECURE_CONNECTION') !== false) {
148+
if (getenv('IDOIT_BYPASS_SECURE_CONNECTION') !== false) {
149149
$config[API::BYPASS_SECURE_CONNECTION] = filter_var(
150-
getenv('BYPASS_SECURE_CONNECTION'),
150+
getenv('IDOIT_BYPASS_SECURE_CONNECTION'),
151151
FILTER_VALIDATE_BOOLEAN,
152152
FILTER_NULL_ON_FAILURE
153153
);

tests/Idoit/APIClient/CMDBCategoryInfoTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ public function testReadVirtualCategoryInfo(string $categoryConstant) {
158158
'method' => 'cmdb.category_info',
159159
'params' => array(
160160
'category' => $categoryConstant,
161-
'apikey' => getenv('KEY')
161+
'apikey' => getenv('IDOIT_KEY')
162162
),
163163
'id' => 1
164164
];
@@ -187,7 +187,7 @@ public function testReadVirtualCategoryEntries(string $categoryConstant) {
187187
'params' => array(
188188
'category' => $categoryConstant,
189189
'objID' => $objectID,
190-
'apikey' => getenv('KEY')
190+
'apikey' => getenv('IDOIT_KEY')
191191
),
192192
'id' => 1
193193
];

tests/Idoit/APIClient/Extension/PrintMetaData.php

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -109,27 +109,27 @@ protected function loadComposer(): self {
109109
protected function connectToAPI(): self {
110110
try {
111111
$config = [
112-
API::URL => getenv('URL'),
113-
API::KEY => getenv('KEY'),
114-
API::BYPASS_SECURE_CONNECTION => getenv('BYPASS_SECURE_CONNECTION')
112+
API::URL => getenv('IDOIT_URL'),
113+
API::KEY => getenv('IDOIT_KEY'),
114+
API::BYPASS_SECURE_CONNECTION => getenv('IDOIT_BYPASS_SECURE_CONNECTION')
115115
];
116116

117-
if (getenv('PORT') !== false) {
118-
$config[API::PORT] = (int) getenv('PORT');
117+
if (getenv('IDOIT_PORT') !== false) {
118+
$config[API::PORT] = (int) getenv('IDOIT_PORT');
119119
}
120120

121121
if (getenv('IDOIT_LANGUAGE') !== false) {
122122
$config[API::LANGUAGE] = getenv('IDOIT_LANGUAGE');
123123
}
124124

125-
if (getenv('USERNAME') !== false && getenv('PASSWORD') !== false) {
126-
$config[API::USERNAME] = getenv('USERNAME');
127-
$config[API::PASSWORD] = getenv('PASSWORD');
125+
if (getenv('IDOIT_USERNAME') !== false && getenv('IDOIT_PASSWORD') !== false) {
126+
$config[API::USERNAME] = getenv('IDOIT_USERNAME');
127+
$config[API::PASSWORD] = getenv('IDOIT_PASSWORD');
128128
}
129129

130-
if (getenv('BYPASS_SECURE_CONNECTION') !== false) {
130+
if (getenv('IDOIT_BYPASS_SECURE_CONNECTION') !== false) {
131131
$config[API::BYPASS_SECURE_CONNECTION] = filter_var(
132-
getenv('BYPASS_SECURE_CONNECTION'),
132+
getenv('IDOIT_BYPASS_SECURE_CONNECTION'),
133133
FILTER_VALIDATE_BOOLEAN,
134134
FILTER_NULL_ON_FAILURE
135135
);
@@ -180,7 +180,7 @@ protected function getAPIVersion(): self {
180180
* @return self Returns itself
181181
*/
182182
protected function printMetaData(): self {
183-
$url = getenv('URL');
183+
$url = getenv('IDOIT_URL');
184184
$libName = $this->composer['name'];
185185
$libVersion = $this->composer['extra']['version'];
186186
$phpVersion = PHP_VERSION;

tests/Idoit/APIClient/Issues/API134Test.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ protected function performCall(string $method, string $expectedMessage) {
7474
'jsonrpc' => '2.0',
7575
'method' => $method,
7676
'params' => [
77-
'apikey' => getenv('KEY'),
77+
'apikey' => getenv('IDOIT_KEY'),
7878
'objID' => $objectID,
7979
'category' => Category::CATG__MODEL,
8080
'data' => [

tests/Idoit/APIClient/Issues/API153Test.php

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -105,31 +105,31 @@ public function provideAPIKeys(): array {
105105
*/
106106
public function testFaultyCredentials(string $username, string $password) {
107107
if (empty($username)) {
108-
$username = getenv('USERNAME');
108+
$username = getenv('IDOIT_USERNAME');
109109
}
110110

111111
if (empty($password)) {
112-
$password = getenv('PASSWORD');
112+
$password = getenv('IDOIT_PASSWORD');
113113
}
114114

115115
$config = [
116116
API::USERNAME => $username,
117117
API::PASSWORD => $password,
118-
API::KEY => getenv('KEY'),
119-
API::URL => getenv('URL')
118+
API::KEY => getenv('IDOIT_KEY'),
119+
API::URL => getenv('IDOIT_URL')
120120
];
121121

122122
if (getenv('IDOIT_LANGUAGE') !== false) {
123123
$config[API::LANGUAGE] = getenv('IDOIT_LANGUAGE');
124124
}
125125

126-
if (getenv('PORT') !== false) {
127-
$config[API::PORT] = (int) getenv('PORT');
126+
if (getenv('IDOIT_PORT') !== false) {
127+
$config[API::PORT] = (int) getenv('IDOIT_PORT');
128128
}
129129

130-
if (getenv('BYPASS_SECURE_CONNECTION') !== false) {
130+
if (getenv('IDOIT_BYPASS_SECURE_CONNECTION') !== false) {
131131
$config[API::BYPASS_SECURE_CONNECTION] = filter_var(
132-
getenv('BYPASS_SECURE_CONNECTION'),
132+
getenv('IDOIT_BYPASS_SECURE_CONNECTION'),
133133
FILTER_VALIDATE_BOOLEAN,
134134
FILTER_NULL_ON_FAILURE
135135
);
@@ -141,7 +141,7 @@ public function testFaultyCredentials(string $username, string $password) {
141141
'jsonrpc' => '2.0',
142142
'method' => 'idoit.version',
143143
'params' => [
144-
'apikey' => getenv('KEY')
144+
'apikey' => getenv('IDOIT_KEY')
145145
],
146146
'id' => 1
147147
];
@@ -162,22 +162,22 @@ public function testFaultyCredentials(string $username, string $password) {
162162
public function testFaultyKey(string $apiKey) {
163163
$config = [
164164
API::KEY => $apiKey,
165-
API::USERNAME => getenv('USERNAME'),
166-
API::PASSWORD => getenv('PASSWORD'),
167-
API::URL => getenv('URL')
165+
API::USERNAME => getenv('IDOIT_USERNAME'),
166+
API::PASSWORD => getenv('IDOIT_PASSWORD'),
167+
API::URL => getenv('IDOIT_URL')
168168
];
169169

170170
if (getenv('IDOIT_LANGUAGE') !== false) {
171171
$config[API::LANGUAGE] = getenv('IDOIT_LANGUAGE');
172172
}
173173

174-
if (getenv('PORT') !== false) {
175-
$config[API::PORT] = (int) getenv('PORT');
174+
if (getenv('IDOIT_PORT') !== false) {
175+
$config[API::PORT] = (int) getenv('IDOIT_PORT');
176176
}
177177

178-
if (getenv('BYPASS_SECURE_CONNECTION') !== false) {
178+
if (getenv('IDOIT_BYPASS_SECURE_CONNECTION') !== false) {
179179
$config[API::BYPASS_SECURE_CONNECTION] = filter_var(
180-
getenv('BYPASS_SECURE_CONNECTION'),
180+
getenv('IDOIT_BYPASS_SECURE_CONNECTION'),
181181
FILTER_VALIDATE_BOOLEAN,
182182
FILTER_NULL_ON_FAILURE
183183
);

0 commit comments

Comments
 (0)