mirror of
https://github.com/GNS3/gns3-server
synced 2024-11-12 19:38:57 +00:00
Generated compute name include the username when it's exists
This commit is contained in:
parent
d469a2060d
commit
6162d7e431
@ -103,7 +103,14 @@ class Compute:
|
||||
elif self._id == "local":
|
||||
self._name = "Local"
|
||||
else:
|
||||
self._name = "{}://{}:{}".format(self._protocol, self._host, self._port)
|
||||
if self._user:
|
||||
user = self._user
|
||||
# Due to random user generated by 1.4 it's common to have a very long user
|
||||
if len(user) > 14:
|
||||
user = user[:11] + "..."
|
||||
self._name = "{}://{}@{}:{}".format(self._protocol, user, self._host, self._port)
|
||||
else:
|
||||
self._name = "{}://{}:{}".format(self._protocol, self._host, self._port)
|
||||
|
||||
@property
|
||||
def connected(self):
|
||||
|
@ -47,7 +47,8 @@ def test_name():
|
||||
assert c.name == "Local"
|
||||
c = Compute("world", protocol="https", host="example.com", port=84, controller=MagicMock(), name="hello")
|
||||
assert c.name == "hello"
|
||||
|
||||
c = Compute("world", protocol="https", host="example.com", port=84, controller=MagicMock(),user="azertyuiopqsdfghjklkm")
|
||||
assert c.name == "https://azertyuiopq...@example.com:84"
|
||||
|
||||
def test_compute_local(compute):
|
||||
"""
|
||||
|
@ -64,7 +64,7 @@ def test_load(controller, controller_config_path, async_run):
|
||||
"port": 8000,
|
||||
"protocol": "http",
|
||||
"user": "admin",
|
||||
"name": "http://localhost:8000"
|
||||
"name": "http://admin@localhost:8000"
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user