Commit 29ac24eb authored by Lu Xu's avatar Lu Xu 👀

Publish backend-url and change username to admin for Theia

See merge request !937
parents 618653e5 f993d86f
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
[instance] [instance]
filename = instance.cfg.in filename = instance.cfg.in
md5sum = 4f119df2b2d71e5ec1fd04051fd8fff8 md5sum = e56a6722e4f0bc958f6b61f13174e852
[yarn.lock] [yarn.lock]
filename = yarn.lock filename = yarn.lock
......
...@@ -4,8 +4,8 @@ ...@@ -4,8 +4,8 @@
"additionalProperties": false, "additionalProperties": false,
"properties": { "properties": {
"autorun": { "autorun": {
"title": "autorun", "title": "Automatically Run Sofware/Instance",
"description": "State of the autorun service", "description": "The option used to pilot automatic build and run of software and instances hosted inside Theia. When 'running', build and run is done automatically in the background. When 'stopped' build and run processes are stopped and need to be run manually. When 'disabled', the user can manage it directly in the local supervisord. ",
"type": "string", "type": "string",
"enum": [ "enum": [
"running", "running",
......
...@@ -13,6 +13,10 @@ ...@@ -13,6 +13,10 @@
"password": { "password": {
"description": "Theia password", "description": "Theia password",
"type": "string" "type": "string"
},
"backend-url": {
"description": "Theia Backend URL",
"type": "string"
} }
}, },
"type": "object" "type": "object"
......
...@@ -7,6 +7,7 @@ theia-environment-parts = ...@@ -7,6 +7,7 @@ theia-environment-parts =
slapos-repository slapos-repository
runner-link runner-link
settings.json settings.json
request-script
theia-parts = theia-parts =
frontend-reload frontend-reload
...@@ -41,6 +42,7 @@ recipe = slapos.cookbook:publish ...@@ -41,6 +42,7 @@ recipe = slapos.cookbook:publish
url = $${apache-frontend:connection-secure_access} url = $${apache-frontend:connection-secure_access}
username = $${frontend-instance-password:username} username = $${frontend-instance-password:username}
password = $${frontend-instance-password:passwd} password = $${frontend-instance-password:passwd}
backend-url = $${frontend-instance:url}
[directory] [directory]
...@@ -136,7 +138,7 @@ return = domain secure_access ...@@ -136,7 +138,7 @@ return = domain secure_access
[frontend-instance-password] [frontend-instance-password]
recipe = slapos.cookbook:generate.password recipe = slapos.cookbook:generate.password
username = node username = admin
bytes = 12 bytes = 12
[frontend-instance-port] [frontend-instance-port]
...@@ -524,3 +526,18 @@ template = ...@@ -524,3 +526,18 @@ template =
recipe = slapos.cookbook:symbolic.link recipe = slapos.cookbook:symbolic.link
target-directory = $${directory:project} target-directory = $${directory:project}
link-binary = $${directory:runner} link-binary = $${directory:runner}
[request-script]
recipe = slapos.recipe.template:jinja2
rendered = $${directory:project}/$${:_buildout_section_name_}.sh
mode = 0700
template =
inline:#!/bin/sh
software_name=html5as-base #replace the software name
software_release_uri=~/srv/project/slapos/software/$software_name/software.cfg
# slapos supply is used to add the software to the software list to be supplied to a node.
slapos supply $software_release_uri slaprunner
# slapos request the allocation of an instance to the master.
# slapos request also gets status and parameters of the instance if it has any
# (slapos request is meant to be run multiple time until you get the status).
slapos request $software_name'_1' $software_release_uri
...@@ -55,6 +55,22 @@ class TestTheia(SlapOSInstanceTestCase): ...@@ -55,6 +55,22 @@ class TestTheia(SlapOSInstanceTestCase):
def setUp(self): def setUp(self):
self.connection_parameters = self.computer_partition.getConnectionParameterDict() self.connection_parameters = self.computer_partition.getConnectionParameterDict()
def test_backend_http_get(self):
resp = requests.get(self.connection_parameters['backend-url'], verify=False)
self.assertEqual(requests.codes.unauthorized, resp.status_code)
# with login/password, this is allowed
parsed_url = urlparse(self.connection_parameters['backend-url'])
authenticated_url = parsed_url._replace(
netloc='{}:{}@[{}]:{}'.format(
self.connection_parameters['username'],
self.connection_parameters['password'],
parsed_url.hostname,
parsed_url.port,
)).geturl()
resp = requests.get(authenticated_url, verify=False)
self.assertEqual(requests.codes.ok, resp.status_code)
def test_http_get(self): def test_http_get(self):
resp = requests.get(self.connection_parameters['url'], verify=False) resp = requests.get(self.connection_parameters['url'], verify=False)
self.assertEqual(requests.codes.unauthorized, resp.status_code) self.assertEqual(requests.codes.unauthorized, resp.status_code)
...@@ -152,6 +168,15 @@ class TestTheia(SlapOSInstanceTestCase): ...@@ -152,6 +168,15 @@ class TestTheia(SlapOSInstanceTestCase):
]) ])
self.assertTrue(os.path.exists(test_file)) self.assertTrue(os.path.exists(test_file))
def test_theia_request_script(self):
script_path = os.path.join(
self.computer_partition_root_path,
'srv',
'project',
'request-script.sh',
)
self.assertTrue(os.path.exists(script_path))
class TestTheiaEmbeddedSlapOSShutdown(SlapOSInstanceTestCase): class TestTheiaEmbeddedSlapOSShutdown(SlapOSInstanceTestCase):
__partition_reference__ = 'T' # for sockets in included slapos __partition_reference__ = 'T' # for sockets in included slapos
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment