satellite/admin: add missing test assert to project geofence tests
the existing test was missing a case where deleting the geofencing should set the placement back to default. this also changes EveryCountry to DefaultPlacement, as the former is deprecated. Change-Id: I29f4f1c3ae1d05e8f5ecaa03a70ac4f17574a475
This commit is contained in:
parent
95958a3c5c
commit
7b50ece931
@ -49,9 +49,9 @@ func parsePlacementConstraint(regionCode string) (storj.PlacementConstraint, err
|
|||||||
case "NR":
|
case "NR":
|
||||||
return storj.NR, nil
|
return storj.NR, nil
|
||||||
case "":
|
case "":
|
||||||
return storj.EveryCountry, fmt.Errorf("missing region parameter")
|
return storj.DefaultPlacement, fmt.Errorf("missing region parameter")
|
||||||
default:
|
default:
|
||||||
return storj.EveryCountry, fmt.Errorf("unrecognized region parameter: %s", regionCode)
|
return storj.DefaultPlacement, fmt.Errorf("unrecognized region parameter: %s", regionCode)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -103,7 +103,7 @@ func (server *Server) createGeofenceForBucket(w http.ResponseWriter, r *http.Req
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (server *Server) deleteGeofenceForBucket(w http.ResponseWriter, r *http.Request) {
|
func (server *Server) deleteGeofenceForBucket(w http.ResponseWriter, r *http.Request) {
|
||||||
server.updateBucket(w, r, storj.EveryCountry)
|
server.updateBucket(w, r, storj.DefaultPlacement)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (server *Server) getBucketInfo(w http.ResponseWriter, r *http.Request) {
|
func (server *Server) getBucketInfo(w http.ResponseWriter, r *http.Request) {
|
||||||
|
@ -83,9 +83,11 @@ func TestAdminProjectGeofenceAPI(t *testing.T) {
|
|||||||
|
|
||||||
project, err := sat.DB.Console().Projects().Get(ctx, testCase.project)
|
project, err := sat.DB.Console().Projects().Get(ctx, testCase.project)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
require.Equal(t, storj.DefaultPlacement, project.DefaultPlacement)
|
||||||
|
|
||||||
expected, err := json.Marshal(project)
|
expected, err := json.Marshal(project)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
assertGet(ctx, t, baseURL, string(expected), sat.Config.Console.AuthToken)
|
assertGet(ctx, t, baseURL, string(expected), sat.Config.Console.AuthToken)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -803,7 +803,7 @@ func (server *Server) createGeofenceForAccount(w http.ResponseWriter, r *http.Re
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (server *Server) deleteGeofenceForAccount(w http.ResponseWriter, r *http.Request) {
|
func (server *Server) deleteGeofenceForAccount(w http.ResponseWriter, r *http.Request) {
|
||||||
server.setGeofenceForUser(w, r, storj.EveryCountry)
|
server.setGeofenceForUser(w, r, storj.DefaultPlacement)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (server *Server) setGeofenceForUser(w http.ResponseWriter, r *http.Request, placement storj.PlacementConstraint) {
|
func (server *Server) setGeofenceForUser(w http.ResponseWriter, r *http.Request, placement storj.PlacementConstraint) {
|
||||||
|
@ -42,7 +42,7 @@ func TestUserGet(t *testing.T) {
|
|||||||
|
|
||||||
link := "http://" + address.String() + "/api/users/" + project.Owner.Email
|
link := "http://" + address.String() + "/api/users/" + project.Owner.Email
|
||||||
expectedBody := `{` +
|
expectedBody := `{` +
|
||||||
fmt.Sprintf(`"user":{"id":"%s","fullName":"User uplink0_0","email":"%s","projectLimit":%d,"placement":%d},`, project.Owner.ID, project.Owner.Email, projLimit, storj.EveryCountry) +
|
fmt.Sprintf(`"user":{"id":"%s","fullName":"User uplink0_0","email":"%s","projectLimit":%d,"placement":%d},`, project.Owner.ID, project.Owner.Email, projLimit, storj.DefaultPlacement) +
|
||||||
fmt.Sprintf(`"projects":[{"id":"%s","name":"uplink0_0","description":"","ownerId":"%s"}]}`, project.ID, project.Owner.ID)
|
fmt.Sprintf(`"projects":[{"id":"%s","name":"uplink0_0","description":"","ownerId":"%s"}]}`, project.ID, project.Owner.ID)
|
||||||
|
|
||||||
assertReq(ctx, t, link, http.MethodGet, "", http.StatusOK, expectedBody, planet.Satellites[0].Config.Console.AuthToken)
|
assertReq(ctx, t, link, http.MethodGet, "", http.StatusOK, expectedBody, planet.Satellites[0].Config.Console.AuthToken)
|
||||||
@ -529,7 +529,7 @@ func TestSetUsersGeofence(t *testing.T) {
|
|||||||
assertReq(ctx, t, link, http.MethodDelete, "", http.StatusOK, "", planet.Satellites[0].Config.Console.AuthToken)
|
assertReq(ctx, t, link, http.MethodDelete, "", http.StatusOK, "", planet.Satellites[0].Config.Console.AuthToken)
|
||||||
updatedUser, err = db.Console().Users().Get(ctx, project.Owner.ID)
|
updatedUser, err = db.Console().Users().Get(ctx, project.Owner.ID)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
require.Equal(t, storj.EveryCountry, updatedUser.DefaultPlacement)
|
require.Equal(t, storj.DefaultPlacement, updatedUser.DefaultPlacement)
|
||||||
})
|
})
|
||||||
|
|
||||||
t.Run("Same Placement", func(t *testing.T) {
|
t.Run("Same Placement", func(t *testing.T) {
|
||||||
|
Loading…
Reference in New Issue
Block a user