Skip to content

Commit

Permalink
Merge pull request #66 from NethServer/fixAction
Browse files Browse the repository at this point in the history
create the web folder with create-vhost NethServer/dev#6925
  • Loading branch information
stephdl authored May 17, 2024
2 parents a7a710b + 4b46418 commit 347bfdd
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 8 deletions.
2 changes: 2 additions & 0 deletions imageroot/actions/create-vhost/10base
Original file line number Diff line number Diff line change
Expand Up @@ -89,3 +89,5 @@ headers = {

conn.request("POST", "/api/v2/users", payload, headers)

## create the directory for the user with podman exec
subprocess.run(["podman", "exec", "sftpgo", "mkdir", "/srv/sftpgo/data/"+str(NextFpmPort)])
3 changes: 1 addition & 2 deletions imageroot/actions/destroy-vhost/validate-input.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,5 @@
"title": "port",
"description": "The port of the phpfpm pool"
}
}
}
}
}
12 changes: 10 additions & 2 deletions imageroot/actions/update-vhost/validate-input.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@
"lets_encrypt": false,
"http2https": true,
"Indexes": "disabled",
"status": "enabled"
"status": "enabled",
"Port": 9001
}
],
"type": "object",
Expand All @@ -35,7 +36,8 @@
"MaxExecutionTime",
"MaxFileUploads",
"Indexes",
"status"
"status",
"Port"
],
"properties": {
"ServerNames": {
Expand Down Expand Up @@ -115,6 +117,12 @@
"type": "boolean",
"title": "HTTP to HTTPS redirection",
"description": "Redirect all the HTTP requests to HTTPS"
},
"port": {
"type": "integer",
"minimum": 9001,
"title": "port",
"description": "The port of the phpfpm pool"
}
}
}
33 changes: 29 additions & 4 deletions tests/webserver.robot
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,15 @@ Backend URL is reachable
... return_rc=True return_stdout=False
Should Be Equal As Integers ${rc} 0

VirtualHost foo.com URL is reachable
${rc} = Execute Command curl -H "Host: foo.com" -f ${backend_url}
... return_rc=True return_stdout=False
Should Be Equal As Integers ${rc} 0

VirtualHost john.com URL is reachable
${rc} = Execute Command curl -H "Host: john.com" -f ${backend_url}
... return_rc=True return_stdout=False
Should Be Equal As Integers ${rc} 0

*** Test Cases ***
Check if webserver is installed correctly
Expand All @@ -34,16 +43,32 @@ Retrieve webserver backend URL
Check if webserver works as expected
Retry test Backend URL is reachable

Check if vhost can be created
${rc} = Execute Command api-cli run module/${module_id}/create-vhost --data '{"PhpVersion":"8.2","ServerNames":["foo.com","john.com"],"MemoryLimit":512,"AllowUrlfOpen":"enabled","UploadMaxFilesize":4,"PostMaxSize":8,"MaxExecutionTime":0,"MaxFileUploads":20,"lets_encrypt":false,"http2https":true,"Indexes":"enabled","status":"enabled"}'
Check if vhost 9001 can be created
${rc} = Execute Command api-cli run module/${module_id}/create-vhost --data '{"PhpVersion":"8.2","ServerNames":["foo.com"],"MemoryLimit":512,"AllowUrlfOpen":"disabled","UploadMaxFilesize":4,"PostMaxSize":8,"MaxExecutionTime":0,"MaxFileUploads":20,"lets_encrypt":false,"http2https":false,"Indexes":"disabled","status":"enabled"}'
... return_rc=True return_stdout=False
Should Be Equal As Integers ${rc} 0

Check if vhost can be updated
${rc} = Execute Command api-cli run module/${module_id}/update-vhost --data '{"PhpVersion":"8.2","ServerNames":["foo.com","john.com"],"Port":9001,"MemoryLimit":512,"AllowUrlfOpen":"enabled","UploadMaxFilesize":4,"PostMaxSize":8,"MaxExecutionTime":0,"MaxFileUploads":20,"lets_encrypt":false,"http2https":true,"Indexes":"enabled","status":"enabled"}'
Check if vhost 9001 can be updated
${rc} = Execute Command api-cli run module/${module_id}/update-vhost --data '{"PhpVersion":"8.2","ServerNames":["foo.com","john.com"],"Port":9001,"MemoryLimit":1024,"AllowUrlfOpen":"enabled","UploadMaxFilesize":8,"PostMaxSize":16,"MaxExecutionTime":100,"MaxFileUploads":40,"lets_encrypt":true,"http2https":true,"Indexes":"enabled","status":"enabled"}'
... return_rc=True return_stdout=False
Should Be Equal As Integers ${rc} 0

Retrieve virtualhost foo.com backend URL
# Assuming the test is running on a single node cluster
${response} = Run task module/traefik1/get-route {"instance":"${module_id}-foo.com"}
Set Suite Variable ${backend_url} ${response['url']}

Check if virtualhost foo.com works as expected
Retry test VirtualHost foo.com URL is reachable

Retrieve virtualhost john.com backend URL
# Assuming the test is running on a single node cluster
${response} = Run task module/traefik1/get-route {"instance":"${module_id}-john.com"}
Set Suite Variable ${backend_url} ${response['url']}

Check if virtualhost john.com works as expected
Retry test VirtualHost john.com URL is reachable

Check if vhost can be destroyed
${rc} = Execute Command api-cli run module/${module_id}/destroy-vhost --data '{"ServerNames": ["foo.com","john.com"],"port": 9001}'
... return_rc=True return_stdout=False
Expand Down

0 comments on commit 347bfdd

Please sign in to comment.