Skip to content

Commit f2370b9

Browse files
authored
Merge branch 'master' into pr-osparc-security-strip-user-and-password
2 parents cae27a9 + 14e38d4 commit f2370b9

File tree

14 files changed

+270
-96
lines changed

14 files changed

+270
-96
lines changed
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
from pydantic import SecretStr
2+
3+
4+
def _mask(value):
5+
"""
6+
Mask the password, showing only the first and last characters
7+
or *** if very short passwords
8+
"""
9+
if len(value) > 2:
10+
masked_value = value[0] + "*" * (len(value) - 2) + value[-1]
11+
else:
12+
# In case of very short passwords
13+
masked_value = "*" * len(value)
14+
return masked_value
15+
16+
17+
def _hash(value):
18+
"""Uses hash number to mask the password"""
19+
return f"hash:{hash(value)}"
20+
21+
22+
class Secret4TestsStr(SecretStr):
23+
"""Prints a hint of the secret
24+
TIP: Can be handy for testing
25+
"""
26+
27+
def _display(self) -> str | bytes:
28+
# SEE overrides _SecretBase._display
29+
value = self.get_secret_value()
30+
return _mask(value) if value else ""
31+
32+
33+
assert str(Secret4TestsStr("123456890")) == "1*******0"
34+
assert "1*******0" in repr(Secret4TestsStr("123456890"))

services/static-webserver/client/source/class/osparc/CookiePolicy.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ qx.Class.define("osparc.CookiePolicy", {
6666
return link;
6767
},
6868

69-
getZMTEULALink: function(linkText = "end users license agreement (EULA)") {
69+
getZMTEULALink: function(linkText = "end-users license agreement (EULA)") {
7070
const color = qx.theme.manager.Color.getInstance().resolve("text");
7171
const link = `<a href='https://zurichmedtech.github.io/s4l-manual/#/docs/licensing/copyright_Sim4Life?id=zurich-medtech-ag-zmt' style='color: ${color}' target='_blank''>${linkText}</a>`;
7272
return link;

services/static-webserver/client/source/class/osparc/auth/ui/RequestAccount.js

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -129,14 +129,21 @@ qx.Class.define("osparc.auth.ui.RequestAccount", {
129129
rich: true
130130
});
131131
country.add(cItem);
132-
})
132+
});
133+
// preselect
133134
fetch("https://ipapi.co/json")
134135
.then(res => res.json())
135136
.then(data => {
136137
const countryFound = country.getSelectables().find(c => c.getModel().toUpperCase() === data.country_code.toUpperCase());
137138
if (countryFound) {
138139
country.setSelection([countryFound])
139140
}
141+
})
142+
.catch(err => {
143+
console.error(err);
144+
const emptyItem = new qx.ui.form.ListItem("", null, "");
145+
country.add(emptyItem);
146+
country.setSelection([emptyItem]);
140147
});
141148
this._form.add(country, this.tr("Country"), null, "country");
142149

@@ -321,7 +328,7 @@ qx.Class.define("osparc.auth.ui.RequestAccount", {
321328

322329
// Eula link
323330
if (osparc.product.Utils.getProductName() !== "osparc") {
324-
const eulaLink = osparc.CookiePolicy.getZMTEULALink("end users license agreement (EULA)");
331+
const eulaLink = osparc.CookiePolicy.getZMTEULALink("end-users license agreement (EULA)");
325332
const eulaText = "I accept the " + eulaLink + " and I will use the product in accordance with it";
326333
const eula = new qx.ui.form.CheckBox().set({
327334
required: true,

services/static-webserver/client/source/class/osparc/node/slideshow/BaseNodeView.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -235,20 +235,20 @@ qx.Class.define("osparc.node.slideshow.BaseNodeView", {
235235
}
236236
const desc = this.getNode().getSlideshowInstructions();
237237
if (desc) {
238-
const descView = new osparc.ui.markdown.Markdown().set({
238+
const markdownInstructions = new osparc.ui.markdown.Markdown().set({
239239
value: desc,
240240
padding: 3,
241241
font: "text-14"
242242
});
243-
const scrollContainer = new qx.ui.container.Scroll();
244-
scrollContainer.add(descView);
245243
const title = this.tr("Instructions") + " - " + this.getNode().getLabel();
246-
const width = 500;
247-
const height = 500;
248-
const win = this.__instructionsWindow = osparc.ui.window.Window.popUpInWindow(scrollContainer, title, width, height).set({
244+
const width = 600;
245+
const minHeight = 200;
246+
const win = this.__instructionsWindow = osparc.ui.window.Window.popUpInWindow(markdownInstructions, title, width, minHeight).set({
249247
modal: false,
250248
clickAwayClose: false
251249
});
250+
markdownInstructions.addListener("resized", () => win.center());
251+
252252
win.getContentElement().setStyles({
253253
"border-color": qx.theme.manager.Color.getInstance().resolve("strong-main")
254254
});

services/static-webserver/client/source/class/osparc/product/TIPTeaser.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,11 @@ qx.Class.define("osparc.product.TIPTeaser", {
3535
});
3636

3737
this.getChildControl("teaser-text");
38+
39+
osparc.utils.Utils.setIdToWidget(this, "tipTeaserWindow");
40+
41+
const closeBtn = this.getChildControl("close-button");
42+
osparc.utils.Utils.setIdToWidget(closeBtn, "tipTeaserWindowCloseBtn");
3843
},
3944

4045
statics: {

services/static-webserver/client/source/class/osparc/product/quickStart/tis/Slides.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ qx.Class.define("osparc.product.quickStart.tis.Slides", {
2626
footerLinks: function() {
2727
const footerLinks = [];
2828

29-
const videoText = osparc.utils.Utils.createHTMLLink("TIP video", "https://youtu.be/-ZE6yOJ3ipw");
29+
const videoText = osparc.utils.Utils.createHTMLLink("TIP videos", "https://www.youtube.com/playlist?list=PLcJQYcVCSqDu5gXnJj-_vS_spGhZOe-jF");
3030
const videoLabel = new qx.ui.basic.Label(videoText).set({
3131
textAlign: "center",
3232
rich : true

services/static-webserver/client/source/class/osparc/ui/markdown/Markdown.js

Lines changed: 48 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,10 @@ qx.Class.define("osparc.ui.markdown.Markdown", {
7171
}
7272
},
7373

74+
events: {
75+
"resized": "qx.event.type.Event",
76+
},
77+
7478
members: {
7579
__loadMarked: null,
7680
/**
@@ -138,7 +142,26 @@ qx.Class.define("osparc.ui.markdown.Markdown", {
138142
} else {
139143
this.setMinHeight(elemHeight);
140144
}
145+
146+
const elemMaxWidth = this.__getChildrenElementMaxWidth(domElement.children);
147+
if (this.getMaxWidth() && elemMaxWidth > this.getMaxWidth()) {
148+
this.setWidth(elemMaxWidth);
149+
} else {
150+
this.setMinWidth(elemMaxWidth);
151+
}
141152
}
153+
this.fireEvent("resized");
154+
},
155+
156+
__getDomElement: function() {
157+
if (!this.getContentElement || this.getContentElement() === null) {
158+
return null;
159+
}
160+
const domElement = this.getContentElement().getDomElement();
161+
if (domElement) {
162+
return domElement;
163+
}
164+
return null;
142165
},
143166

144167
__getChildrenElementHeight: function(children) {
@@ -155,23 +178,37 @@ qx.Class.define("osparc.ui.markdown.Markdown", {
155178
if (this.getNoMargin()) {
156179
element.style.marginTop = 0;
157180
element.style.marginBottom = 0;
158-
const size = qx.bom.element.Dimension.getSize(element);
181+
const size = this.__getElementSize(element);
159182
return size.height;
160183
}
161-
const size = qx.bom.element.Dimension.getSize(element);
184+
const size = this.__getElementSize(element);
162185
// add padding
163-
return size.height + 15;
186+
return size.height + 20;
164187
},
165188

166-
__getDomElement: function() {
167-
if (!this.getContentElement || this.getContentElement() === null) {
168-
return null;
189+
__getChildrenElementMaxWidth: function(children) {
190+
let maxWidth = 0;
191+
for (let i=0; i < children.length; i++) {
192+
maxWidth = Math.max(this.__getElementWidth(children[i]), maxWidth);
169193
}
170-
const domElement = this.getContentElement().getDomElement();
171-
if (domElement) {
172-
return domElement;
194+
return maxWidth;
195+
},
196+
197+
__getElementWidth: function(element) {
198+
const size = this.__getElementSize(element);
199+
return size.width;
200+
},
201+
202+
__getElementSize: function(element) {
203+
if (
204+
element &&
205+
element.children &&
206+
element.children.length &&
207+
element.children[0].localName === "img"
208+
) {
209+
return qx.bom.element.Dimension.getSize(element.children[0]);
173210
}
174-
return null;
175-
}
211+
return qx.bom.element.Dimension.getSize(element);
212+
},
176213
}
177214
});

tests/e2e-playwright/.gitignore

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
test-results
1+
.e2e-playwright-*.txt
22
assets
33
report.html
4-
.e2e-playwright-*.txt
54
report.xml
5+
test-results

tests/e2e-playwright/Makefile

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,13 +117,17 @@ CLASSIC_TIP_INPUT_FILE := .e2e-playwright-classictip-env.txt
117117
$(SLEEPERS_INPUT_FILE) $(JUPYTER_LAB_INPUT_FILE) $(CLASSIC_TIP_INPUT_FILE) $(S4L_INPUT_FILE):
118118
@read -p "Enter your product URL: " PRODUCT_URL; \
119119
read -p "Is the product billable [y/n]: " BILLABLE; \
120+
read -p "Is the product lite [y/n]: " IS_LITE; \
120121
read -p "Is the test running in autoscaled deployment [y/n]: " AUTOSCALED; \
121122
read -p "Enter your username: " USER_NAME; \
122123
read -s -p "Enter your password: " PASSWORD; echo ""; \
123124
echo "--product-url=$$PRODUCT_URL --user-name=$$USER_NAME --password=$$PASSWORD" > $@; \
124125
if [ "$$BILLABLE" = "y" ]; then \
125126
echo "--product-billable" >> $@; \
126127
fi; \
128+
if [ "$$IS_LITE" = "y" ]; then \
129+
echo "--product-lite" >> $@; \
130+
fi; \
127131
if [ "$$AUTOSCALED" = "y" ]; then \
128132
echo "--autoscaled" >> $@; \
129133
fi; \
@@ -183,4 +187,4 @@ define run_test_on_chrome
183187
endef
184188

185189
clean:
186-
@rm -rf $(SLEEPERS_INPUT_FILE) $(JUPYTER_LAB_INPUT_FILE) $(CLASSIC_TIP_INPUT_FILE)
190+
-@rm -rf $(SLEEPERS_INPUT_FILE) $(JUPYTER_LAB_INPUT_FILE) $(CLASSIC_TIP_INPUT_FILE)

tests/e2e-playwright/README.md

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,36 @@
1+
2+
3+
## Usage
4+
15
### Auto generate new test
2-
`playwright codegen sim4life.io`
6+
```
7+
playwright codegen sim4life.io
8+
```
39

410
### Run test locally with headed mode
511
```
612
pytest -s tests/sim4life.py --headed --browser chromium --product-billable --product-url https://sim4life.io/ --user-name YOUR_USERNAME --password YOUR_PASSWORD --service-key sim4life-8-0-0-dy
713
```
814

915
### Check test results output
10-
`playwright show-trace test-results/tests-sim4life-py-test-billable-sim4life-chromium/trace.zip`
16+
```
17+
playwright show-trace test-results/tests-sim4life-py-test-billable-sim4life-chromium/trace.zip
18+
```
1119

1220
### Run debug mode
13-
`PWDEBUG=1 pytest -s tests/sim4life.py`
21+
```
22+
PWDEBUG=1 pytest -s tests/sim4life.py
23+
```
1424

1525
### Run test in different browsers
16-
`pytest -s tests/sim4life.py --tracing on --html=report.html --browser chromium --browser firefox`
26+
```
27+
pytest -s tests/sim4life.py --tracing on --html=report.html --browser chromium --browser firefox
28+
```
1729

18-
### or in chrome/msedge
19-
`pytest -s tests/sim4life.py --tracing on --html=report.html --browser-channel chrome`
30+
### or in chrome/ms-edge
31+
```
32+
pytest -s tests/sim4life.py --tracing on --html=report.html --browser-channel chrome
33+
```
2034

21-
### Runs in CI
35+
## e2e CI
2236
- https://git.speag.com/oSparc/e2e-backend

0 commit comments

Comments
 (0)