Skip to content

Commit

Permalink
API: disable webonchain (#1287)
Browse files Browse the repository at this point in the history
  • Loading branch information
Thykof authored Dec 8, 2023
1 parent f89be7c commit c68a324
Show file tree
Hide file tree
Showing 7 changed files with 33 additions and 1 deletion.
7 changes: 6 additions & 1 deletion api/test/robot_tests/web_on_chain/web_on_chain.robot
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ Suite Teardown Close All Browsers

*** Test Cases ***
PUT /websiteUploader/prepare
Pass Execution Web On Chain is disabled temporary
[Documentation] Prepare a website for creation.
${zip}= Get File For Streaming Upload ${CURDIR}/${TEST_ZIP_FILE}
Expand All @@ -33,6 +34,7 @@ PUT /websiteUploader/prepare
Set Global Variable ${WEBSITE_ADDRESS} ${response.json()['address']}

POST /websiteUploader/upload
Pass Execution Web On Chain is disabled temporary
[Documentation] Upload the content of the website to the blockchain.
${zip}= Get File For Streaming Upload ${CURDIR}/${TEST_ZIP_FILE}
Expand All @@ -47,12 +49,14 @@ POST /websiteUploader/upload
Should Be Equal As Strings ${response.json()['address']} ${WEBSITE_ADDRESS}

GET /my/domains/{nickname}
Pass Execution Web On Chain is disabled temporary
${response}= GET
... ${API_URL}/my/domains/${WALLET_NICKNAME}
... expected_status=${STATUS_OK}
Should Contain ${response.text} ${website_url}

POST /cmd/executeFunction To remove the dns entry
Pass Execution Web On Chain is disabled temporary
${argument}= keywords.String To Arg ${website_url}
${data}= Create Dictionary
... nickname=${WALLET_NICKNAME}
Expand All @@ -65,7 +69,8 @@ POST /cmd/executeFunction To remove the dns entry
... json=${data}
... expected_status=${STATUS_OK}

GET /all/domains
GET /all/domains
Pass Execution Web On Chain is disabled temporary
${response}= GET
... ${API_URL}/all/domains
... expected_status=${STATUS_OK}
7 changes: 7 additions & 0 deletions int/api/utils/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,3 +84,10 @@ func NewInternalServerErrorResponder(err error) *CustomResponder {
map[string]string{"Content-Type": "text/html"},
http.StatusInternalServerError)
}

func NewGoneResponder() *CustomResponder {
return NewCustomResponder(
[]byte("410 Gone"),
map[string]string{"Content-Type": "text/html"},
http.StatusGone)
}
4 changes: 4 additions & 0 deletions int/api/websites/all.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"github.com/go-openapi/runtime/middleware"
"github.com/massalabs/station/api/swagger/server/models"
"github.com/massalabs/station/api/swagger/server/restapi/operations"
"github.com/massalabs/station/int/api/utils"
"github.com/massalabs/station/int/config"
"github.com/massalabs/station/pkg/convert"
"github.com/massalabs/station/pkg/dnshelper"
Expand All @@ -32,6 +33,9 @@ type registryHandler struct {
}

func (h *registryHandler) Handle(_ operations.AllDomainsGetterParams) middleware.Responder {
//nolint:revive
return utils.NewGoneResponder()

results, err := Registry(h.config)
if err != nil {
return operations.NewMyDomainsGetterInternalServerError().
Expand Down
4 changes: 4 additions & 0 deletions int/api/websites/my.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"github.com/go-openapi/runtime/middleware"
"github.com/massalabs/station/api/swagger/server/models"
"github.com/massalabs/station/api/swagger/server/restapi/operations"
"github.com/massalabs/station/int/api/utils"
"github.com/massalabs/station/int/config"
"github.com/massalabs/station/pkg/my"
"github.com/massalabs/station/pkg/node"
Expand All @@ -18,6 +19,9 @@ type domainsHandler struct {
}

func (h *domainsHandler) Handle(params operations.MyDomainsGetterParams) middleware.Responder {
//nolint:revive
return utils.NewGoneResponder()

client := node.NewClient(h.config.NodeURL)

myDomainNames, err := my.Domains(*h.config, client, params.Nickname)
Expand Down
4 changes: 4 additions & 0 deletions int/api/websites/prepare.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
"github.com/go-openapi/runtime/middleware"
"github.com/massalabs/station/api/swagger/server/models"
"github.com/massalabs/station/api/swagger/server/restapi/operations"
"github.com/massalabs/station/int/api/utils"
"github.com/massalabs/station/int/config"
sendOperation "github.com/massalabs/station/pkg/node/sendoperation"
"github.com/massalabs/station/pkg/onchain/website"
Expand Down Expand Up @@ -39,6 +40,9 @@ func listFileName(zipReader *zip.Reader) []string {
}

func (h *websitePrepare) Handle(params operations.WebsiteUploaderPrepareParams) middleware.Responder {
//nolint:revive
return utils.NewGoneResponder()

archive, errorResponse := readAndCheckArchive(params.Zipfile)
if errorResponse != nil {
return errorResponse
Expand Down
4 changes: 4 additions & 0 deletions int/api/websites/upload.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"github.com/go-openapi/runtime/middleware"
"github.com/massalabs/station/api/swagger/server/models"
"github.com/massalabs/station/api/swagger/server/restapi/operations"
"github.com/massalabs/station/int/api/utils"
"github.com/massalabs/station/int/config"
sendOperation "github.com/massalabs/station/pkg/node/sendoperation"
"github.com/massalabs/station/pkg/onchain/website"
Expand All @@ -18,6 +19,9 @@ type websiteUploadHandler struct {
}

func (h *websiteUploadHandler) Handle(params operations.WebsiteUploaderUploadParams) middleware.Responder {
//nolint:revive
return utils.NewGoneResponder()

archive, errorResponse := readAndCheckArchive(params.Zipfile)
if errorResponse != nil {
return errorResponse
Expand Down
4 changes: 4 additions & 0 deletions int/api/websites/uploadMissed.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"github.com/go-openapi/runtime/middleware"
"github.com/massalabs/station/api/swagger/server/models"
"github.com/massalabs/station/api/swagger/server/restapi/operations"
"github.com/massalabs/station/int/api/utils"
"github.com/massalabs/station/int/config"
sendOperation "github.com/massalabs/station/pkg/node/sendoperation"
"github.com/massalabs/station/pkg/onchain/website"
Expand All @@ -18,6 +19,9 @@ type uploadMissedChunkHandler struct {
}

func (h *uploadMissedChunkHandler) Handle(params operations.WebsiteUploadMissingChunksParams) middleware.Responder {
//nolint:revive
return utils.NewGoneResponder()

archive, errorResponse := readAndCheckArchive(params.Zipfile)
if errorResponse != nil {
return errorResponse
Expand Down

0 comments on commit c68a324

Please sign in to comment.