@onlineapps/conn-base-storage 1.0.4 → 1.0.5
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/coverage/coverage-final.json +5 -5
- package/coverage/lcov-report/index.html +19 -19
- package/coverage/lcov.info +1 -551
- package/package.json +1 -1
- package/src/config.js +0 -3
- package/src/defaults.js +5 -5
- package/src/index.js +2 -2
- package/src/internal-url-adapter.js +1 -18
- package/tests/unit/internal-url-adapter.test.js +23 -28
- package/onlineapps-conn-base-storage-1.0.0.tgz +0 -0
|
@@ -9,8 +9,6 @@ describe('InternalUrlAdapter @unit', () => {
|
|
|
9
9
|
|
|
10
10
|
beforeEach(() => {
|
|
11
11
|
adapter = new InternalUrlAdapter();
|
|
12
|
-
// Tests run inside a Docker container; force local-mode behavior unless explicitly enabled.
|
|
13
|
-
adapter.isRunningInDocker = jest.fn(() => false);
|
|
14
12
|
});
|
|
15
13
|
|
|
16
14
|
describe('URL Resolution', () => {
|
|
@@ -27,7 +25,7 @@ describe('InternalUrlAdapter @unit', () => {
|
|
|
27
25
|
const internalUrl = 'internal://storage/bucket/path/to/file.json';
|
|
28
26
|
const resolved = adapter.resolve(internalUrl);
|
|
29
27
|
|
|
30
|
-
expect(resolved).toBe('http://
|
|
28
|
+
expect(resolved).toBe('http://127.0.0.1:9000/bucket/path/to/file.json');
|
|
31
29
|
});
|
|
32
30
|
|
|
33
31
|
test('should resolve internal://registry URL', () => {
|
|
@@ -35,7 +33,7 @@ describe('InternalUrlAdapter @unit', () => {
|
|
|
35
33
|
const internalUrl = 'internal://registry/services/list';
|
|
36
34
|
const resolved = adapter.resolve(internalUrl);
|
|
37
35
|
|
|
38
|
-
expect(resolved).toBe('http://
|
|
36
|
+
expect(resolved).toBe('http://127.0.0.1:8080/services/list');
|
|
39
37
|
});
|
|
40
38
|
|
|
41
39
|
test('should resolve internal://monitoring URL', () => {
|
|
@@ -58,7 +56,7 @@ describe('InternalUrlAdapter @unit', () => {
|
|
|
58
56
|
const internalUrl = 'internal://storage/bucket/file?version=2&download=true';
|
|
59
57
|
const resolved = adapter.resolve(internalUrl);
|
|
60
58
|
|
|
61
|
-
expect(resolved).toBe('http://
|
|
59
|
+
expect(resolved).toBe('http://127.0.0.1:9000/bucket/file?version=2&download=true');
|
|
62
60
|
});
|
|
63
61
|
|
|
64
62
|
test('should throw error for unknown service', () => {
|
|
@@ -77,7 +75,7 @@ describe('InternalUrlAdapter @unit', () => {
|
|
|
77
75
|
});
|
|
78
76
|
|
|
79
77
|
test('should preserve query parameters in conversion', () => {
|
|
80
|
-
const actualUrl = 'http://
|
|
78
|
+
const actualUrl = 'http://127.0.0.1:9000/bucket/file?version=2';
|
|
81
79
|
const internal = adapter.toInternal(actualUrl, 'storage');
|
|
82
80
|
|
|
83
81
|
expect(internal).toBe('internal://storage/bucket/file?version=2');
|
|
@@ -86,7 +84,7 @@ describe('InternalUrlAdapter @unit', () => {
|
|
|
86
84
|
|
|
87
85
|
describe('Service Registration', () => {
|
|
88
86
|
test('should register new service', () => {
|
|
89
|
-
adapter.registerService('custom', 'custom-container:8080', '
|
|
87
|
+
adapter.registerService('custom', 'custom-container:8080', '127.0.0.1:8080');
|
|
90
88
|
|
|
91
89
|
const internalUrl = 'internal://custom/api/endpoint';
|
|
92
90
|
adapter.dockerNetwork = true;
|
|
@@ -96,13 +94,13 @@ describe('InternalUrlAdapter @unit', () => {
|
|
|
96
94
|
});
|
|
97
95
|
|
|
98
96
|
test('should override existing service', () => {
|
|
99
|
-
adapter.registerService('storage', 'new-storage:9001', '
|
|
97
|
+
adapter.registerService('storage', 'new-storage:9001', '127.0.0.1:9001');
|
|
100
98
|
|
|
101
99
|
const internalUrl = 'internal://storage/bucket/file';
|
|
102
100
|
adapter.dockerNetwork = false;
|
|
103
101
|
const resolved = adapter.resolve(internalUrl);
|
|
104
102
|
|
|
105
|
-
expect(resolved).toBe('http://
|
|
103
|
+
expect(resolved).toBe('http://127.0.0.1:9001/bucket/file');
|
|
106
104
|
});
|
|
107
105
|
});
|
|
108
106
|
|
|
@@ -120,9 +118,9 @@ describe('InternalUrlAdapter @unit', () => {
|
|
|
120
118
|
|
|
121
119
|
const transformed = adapter.transformResponse(response);
|
|
122
120
|
|
|
123
|
-
expect(transformed.url).toBe('http://
|
|
124
|
-
expect(transformed.backup).toBe('http://
|
|
125
|
-
expect(transformed.metadata.thumbnail).toBe('http://
|
|
121
|
+
expect(transformed.url).toBe('http://127.0.0.1:9000/bucket/file.json');
|
|
122
|
+
expect(transformed.backup).toBe('http://127.0.0.1:9000/backup/file.json');
|
|
123
|
+
expect(transformed.metadata.thumbnail).toBe('http://127.0.0.1:9000/thumbnails/thumb.jpg');
|
|
126
124
|
});
|
|
127
125
|
|
|
128
126
|
test('should handle arrays in response', () => {
|
|
@@ -138,8 +136,8 @@ describe('InternalUrlAdapter @unit', () => {
|
|
|
138
136
|
|
|
139
137
|
const transformed = adapter.transformResponse(response);
|
|
140
138
|
|
|
141
|
-
expect(transformed.files[0]).toBe('http://
|
|
142
|
-
expect(transformed.files[1]).toBe('http://
|
|
139
|
+
expect(transformed.files[0]).toBe('http://127.0.0.1:9000/file1.json');
|
|
140
|
+
expect(transformed.files[1]).toBe('http://127.0.0.1:9000/file2.json');
|
|
143
141
|
expect(transformed.files[2]).toBe('http://external.com/file3.json');
|
|
144
142
|
});
|
|
145
143
|
|
|
@@ -165,19 +163,18 @@ describe('InternalUrlAdapter @unit', () => {
|
|
|
165
163
|
});
|
|
166
164
|
|
|
167
165
|
describe('Environment Detection', () => {
|
|
168
|
-
test('should
|
|
169
|
-
const
|
|
166
|
+
test('should respect DOCKER_NETWORK env hint via runtime config', () => {
|
|
167
|
+
const original = process.env.DOCKER_NETWORK;
|
|
168
|
+
process.env.DOCKER_NETWORK = 'true';
|
|
170
169
|
|
|
171
|
-
process.env.DOCKER_ENV = 'true';
|
|
172
170
|
const adapter1 = new InternalUrlAdapter();
|
|
173
|
-
expect(adapter1.
|
|
171
|
+
expect(adapter1.dockerNetwork).toBe(true);
|
|
174
172
|
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
if (originalEnv) process.env.DOCKER_ENV = originalEnv;
|
|
173
|
+
if (original === undefined) {
|
|
174
|
+
delete process.env.DOCKER_NETWORK;
|
|
175
|
+
} else {
|
|
176
|
+
process.env.DOCKER_NETWORK = original;
|
|
177
|
+
}
|
|
181
178
|
});
|
|
182
179
|
});
|
|
183
180
|
|
|
@@ -199,17 +196,15 @@ describe('InternalUrlAdapter @unit', () => {
|
|
|
199
196
|
services: {
|
|
200
197
|
'my-service': {
|
|
201
198
|
docker: 'my-container:3000',
|
|
202
|
-
local: '
|
|
199
|
+
local: '127.0.0.1:3000'
|
|
203
200
|
}
|
|
204
201
|
}
|
|
205
202
|
});
|
|
206
203
|
|
|
207
|
-
// Tests run inside Docker; force local-mode behavior for this adapter instance.
|
|
208
|
-
customAdapter.isRunningInDocker = jest.fn(() => false);
|
|
209
204
|
customAdapter.dockerNetwork = false;
|
|
210
205
|
const resolved = customAdapter.resolve('internal://my-service/api');
|
|
211
206
|
|
|
212
|
-
expect(resolved).toBe('http://
|
|
207
|
+
expect(resolved).toBe('http://127.0.0.1:3000/api');
|
|
213
208
|
});
|
|
214
209
|
});
|
|
215
210
|
});
|
|
Binary file
|