Commit 48d0b1d2 authored by Jérome Perrin's avatar Jérome Perrin

software/theia: serve a public folder

like webrunner is doing
parent 73e4e19f
......@@ -15,7 +15,7 @@
[instance]
filename = instance.cfg.in
md5sum = 83e638fca1762c197ec5847c2deec98f
md5sum = 202f809fd759e9a507db7c7d33caae48
[yarn.lock]
filename = yarn.lock
......
......@@ -50,8 +50,10 @@ template = inline:
tls {
alpn http/1.1
}
root $${directory:frontend-static}
browse
proxy / $${theia-instance:base-url} {
# transparent
except public
}
proxy /services $${theia-instance:base-url} {
websocket
......@@ -190,3 +192,5 @@ pidfiles = $${:var}/run
services = $${:etc}/service
project = $${:srv}/project
slapos = $${:srv}/slapos
frontend-static = $${:srv}/frontend-static
frontend-static-public = $${:frontend-static}/public
......@@ -31,7 +31,7 @@ import textwrap
import logging
import tempfile
import time
from six.moves.urllib.parse import urlparse
from six.moves.urllib.parse import urlparse, urljoin
import pexpect
import requests
......@@ -54,16 +54,27 @@ class TestTheia(SlapOSInstanceTestCase):
# with login/password, this is allowed
parsed_url = urlparse(self.connection_parameters['url'])
resp = requests.get(
parsed_url._replace(
netloc='{}:{}@[{}]:{}'.format(
self.connection_parameters['username'],
self.connection_parameters['password'],
parsed_url.hostname,
parsed_url.port)).geturl(),
verify=False)
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)
# there's a public folder to serve file
with open('{}/srv/frontend-static/public/test_file'.format(
self.computer_partition_root_path), 'w') as f:
f.write("hello")
resp = requests.get(urljoin(authenticated_url, '/public/'), verify=False)
self.assertIn('test_file', resp.text)
resp = requests.get(
urljoin(authenticated_url, '/public/test_file'), verify=False)
self.assertEqual('hello', resp.text)
def test_theia_slapos(self):
# Make sure we can use the shell and the integrated slapos command
process = pexpect.spawnu(
......
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