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