Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
M
mockup-service
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
12
Issues
12
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
cepharum
mockup-service
Commits
07cb315d
Commit
07cb315d
authored
Jul 18, 2019
by
Thomas Urban
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fixing CI issue
parent
6706df85
Pipeline
#2043
passed with stage
in 25 seconds
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
31 additions
and
6 deletions
+31
-6
lib/services/abstract.js
lib/services/abstract.js
+23
-1
lib/services/http.js
lib/services/http.js
+2
-3
test/http/basics.spec.js
test/http/basics.spec.js
+6
-2
No files found.
lib/services/abstract.js
View file @
07cb315d
...
...
@@ -88,6 +88,8 @@ class AbstractService extends EventEmitter {
running
=
true
;
stopped
=
null
;
return
{
address
,
port
};
}
);
}
},
...
...
@@ -124,7 +126,7 @@ class AbstractService extends EventEmitter {
},
/**
* Exposes address
of running service
.
* Exposes address
running service is listening on
.
*
* @name AbstractService#address
* @property {string}
...
...
@@ -134,6 +136,26 @@ class AbstractService extends EventEmitter {
get
:
()
=>
address
,
},
/**
* Exposes address available for accessing the running service.
*
* @name AbstractService#remoteAddress
* @property {string}
* @readonly
*/
remoteAddress
:
{
get
()
{
switch
(
address
)
{
case
"
::
"
:
case
"
0.0.0.0
"
:
return
"
127.0.0.1
"
;
default
:
return
address
;
}
},
},
/**
* Exposes TCP/UDP port of running service.
*
...
...
lib/services/http.js
View file @
07cb315d
...
...
@@ -101,7 +101,6 @@ class HttpService extends AbstractService {
server
.
once
(
"
listening
"
,
()
=>
{
const
info
=
server
.
address
();
console
.
log
(
"
event
"
,
info
);
resolve
(
{
address
:
info
.
address
,
port
:
info
.
port
,
...
...
@@ -139,7 +138,7 @@ class HttpService extends AbstractService {
query
(
method
,
path
,
headers
=
{},
body
=
null
)
{
return
new
Promise
(
(
resolve
,
reject
)
=>
{
const
request
=
Http
.
request
(
{
host
:
this
.
a
ddress
,
host
:
this
.
remoteA
ddress
,
port
:
this
.
port
,
method
,
path
,
...
...
@@ -172,7 +171,7 @@ class HttpService extends AbstractService {
/** @inheritDoc */
get
url
()
{
return
`http://
${
this
.
a
ddress
}
:
${
this
.
port
}
`
;
return
`http://
${
this
.
remoteA
ddress
}
:
${
this
.
port
}
`
;
}
}
...
...
test/http/basics.spec.js
View file @
07cb315d
...
...
@@ -105,13 +105,17 @@ EOM
`
);
describe
(
"
Mock-up service for HTTP
"
,
()
=>
{
before
(
()
=>
Mock
.
start
()
.
then
(
info
=>
{
console
.
log
(
"
started
"
,
info
);
return
info
;
}
)
);
before
(
()
=>
Mock
.
start
()
);
after
(
()
=>
Mock
.
stop
()
);
it
(
"
is exposing
its address
"
,
()
=>
{
it
(
"
is exposing
address it is listening on
"
,
()
=>
{
Mock
.
address
.
should
.
be
.
String
();
}
);
it
(
"
is exposing its address for use from a client's point of view
"
,
()
=>
{
Mock
.
remoteAddress
.
should
.
be
.
String
();
}
);
it
(
"
is exposing its port
"
,
()
=>
{
Mock
.
port
.
should
.
be
.
Number
().
which
.
is
.
greaterThan
(
0
).
and
.
lessThan
(
65536
);
}
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment