Skip to content

Commit

Permalink
✅fix clone tests due to myapp ui changes
Browse files Browse the repository at this point in the history
  • Loading branch information
TarradeMarc committed Jul 4, 2024
1 parent a4d7066 commit 3a873c1
Show file tree
Hide file tree
Showing 6 changed files with 50 additions and 2 deletions.
8 changes: 8 additions & 0 deletions clone/myapp.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ const homepage=`
${'CLONE'.split('').map(letter => `<span class="letter">${letter}</span>`).join('')}
</div>
<div align="center"><button type="button" onclick="window.location.href='/login'">Login</button></div>
<div class="label">CLONE</div>
<script src="/script.js"></script>
`

Expand All @@ -44,6 +45,12 @@ body {
height: 100vh;
}
.label {
position: absolute;
right: 0;
bottom: 0;
}
.header {
background-color: #282c34;
color: white;
Expand Down Expand Up @@ -128,6 +135,7 @@ const dashboard = `
<p>3%</p>
</div>
</div>
<div class="label">CLONE</div>
</div>
</div>
`
Expand Down
8 changes: 8 additions & 0 deletions exhaust/myapp.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ const homepage=`
${'EXHAUST'.split('').map(letter => `<span class="letter">${letter}</span>`).join('')}
</div>
<div align="center"><button type="button" onclick="window.location.href='/login'">Login</button></div>
<div class="label">EXHAUST</div>
<script src="/script.js"></script>
`;

Expand All @@ -39,6 +40,12 @@ body {
margin-top: 100px;
}
.label {
position: absolute;
right: 0;
bottom: 0;
}
.dashboard {
display: flex;
height: 100vh;
Expand Down Expand Up @@ -128,6 +135,7 @@ const dashboard = `
<p>3%</p>
</div>
</div>
<div class="label">EXHAUST</div>
</div>
</div>
`
Expand Down
15 changes: 14 additions & 1 deletion tests/docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
version: '3'
services:

myapp:
Expand All @@ -20,6 +19,7 @@ services:
- myapp
- fluent
- clone
- exhaust
logging:
driver: fluentd

Expand All @@ -35,4 +35,17 @@ services:
clone:
container_name: clone
image: clonetest
depends_on:
- fluent
logging:
driver: fluentd

exhaust:
container_name: exhaust
build: exhaust
image: exhausttest
depends_on:
- fluent
logging:
driver: fluentd

10 changes: 10 additions & 0 deletions tests/exhaustDockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
FROM node:21-alpine
WORKDIR /usr/app
RUN npm install express
RUN npm install body-parser
RUN npm install cookie-parser
ADD myapp.js /usr/app/myapp.js
ADD files/script.js /usr/app/files/script.js
USER nobody
EXPOSE 4000
CMD [ "node", "myapp.js" ]
3 changes: 3 additions & 0 deletions tests/runTests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,15 @@ docker build -f myappDockerfile -t myapptest ../myapp/
docker build -f configmanagerDockerfile -t configmanagertest ../configmanager/
docker build -f proxyDockerfile -t proxytest ../proxy/
docker build -f cloneDockerfile -t clonetest ../clone/
docker build -f exhaustDockerfile -t exhausttest ../exhaust/

# Delete possible container conflicts
docker rm -f myapp
docker rm -f configmanager
docker rm -f proxy
docker rm -f clone
docker rm -f exhaust
docker rm -f fluentbit

# Start the application in demo mode
docker-compose up -d
Expand Down
8 changes: 7 additions & 1 deletion tests/tests/respond-clone.sh
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,12 @@ config='
# Configure global config
globalconfig='
{
"alert": {
"session": {
"in": "cookie",
"key": "SESSION"
}
},
"blocklistReload": 1
}
'
Expand All @@ -51,7 +57,7 @@ start_time=$(date +%s.%N)
tempfile=$(bash ./uuidgen.sh)

# Call it once first to trigger the alert and get blocklisted
curl -v -H "x-cloud-active-defense: ACTIVE" -s http://localhost:8000/ &>/dev/null
curl -v -H "x-cloud-active-defense: ACTIVE" --cookie SESSION=c32272b9-99d8-4687-b57e-a606952ae870 -s http://localhost:8000/ &>/dev/null

# Wait a little for the delay option
sleep 5
Expand Down

0 comments on commit 3a873c1

Please sign in to comment.