fix(http): remove org parameter and add client tests
parent
29a1eb4714
commit
235836f4c4
|
@ -448,6 +448,13 @@ func TestService_handleDeleteAuthorization(t *testing.T) {
|
|||
|
||||
func initAuthorizationService(f platformtesting.AuthorizationFields, t *testing.T) (platform.AuthorizationService, func()) {
|
||||
t.Helper()
|
||||
if t.Name() == "TestAuthorizationService_FindAuthorizations/find_authorization_by_token" {
|
||||
/*
|
||||
TODO(goller): need a secure way to communicate get
|
||||
authorization by token string via headers or something
|
||||
*/
|
||||
t.Skip("TestAuthorizationService_FindAuthorizations/find_authorization_by_token skipped because user tokens cannot be queried")
|
||||
}
|
||||
|
||||
svc := inmem.NewService()
|
||||
svc.IDGenerator = f.IDGenerator
|
||||
|
@ -487,10 +494,16 @@ func TestAuthorizationService_FindAuthorizationByID(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestAuthorizationService_FindAuthorizationByToken(t *testing.T) {
|
||||
/*
|
||||
TODO(goller): need a secure way to communicate get
|
||||
authorization by token string via headers or something
|
||||
*/
|
||||
t.Skip()
|
||||
platformtesting.FindAuthorizationByToken(initAuthorizationService, t)
|
||||
}
|
||||
|
||||
func TestAuthorizationService_FindAuthorizations(t *testing.T) {
|
||||
// TODO: skip "find authorization by token
|
||||
platformtesting.FindAuthorizations(initAuthorizationService, t)
|
||||
}
|
||||
|
||||
|
|
|
@ -94,23 +94,24 @@ type postBucketRequest struct {
|
|||
Bucket *platform.Bucket
|
||||
}
|
||||
|
||||
func (b postBucketRequest) Validate() error {
|
||||
// TODO(goller): hey leo, is this ok?
|
||||
if b.Bucket.Organization == "" && len(b.Bucket.OrganizationID) == 0 {
|
||||
return fmt.Errorf("bucket requires an organization")
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func decodePostBucketRequest(ctx context.Context, r *http.Request) (*postBucketRequest, error) {
|
||||
b := &platform.Bucket{}
|
||||
|
||||
queryParams := r.URL.Query()
|
||||
orgName := queryParams.Get("org")
|
||||
if orgName == "" {
|
||||
return nil, errors.New("The \"org\" is required via query param.")
|
||||
}
|
||||
|
||||
if err := json.NewDecoder(r.Body).Decode(b); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
b.Organization = orgName
|
||||
|
||||
return &postBucketRequest{
|
||||
req := &postBucketRequest{
|
||||
Bucket: b,
|
||||
}, nil
|
||||
}
|
||||
return req, req.Validate()
|
||||
}
|
||||
|
||||
// handleGetBucket is the HTTP handler for the GET /v1/buckets/:id route.
|
||||
|
|
|
@ -312,7 +312,6 @@ func TestService_handlePostBucket(t *testing.T) {
|
|||
},
|
||||
"id": "020f755c3c082000",
|
||||
"organizationID": "30",
|
||||
"organization": "30",
|
||||
"name": "hello",
|
||||
"retentionPeriod": 0
|
||||
}
|
||||
|
@ -589,8 +588,6 @@ func TestService_handlePatchBucket(t *testing.T) {
|
|||
}
|
||||
|
||||
func initBucketService(f platformtesting.BucketFields, t *testing.T) (platform.BucketService, func()) {
|
||||
t.Helper()
|
||||
|
||||
svc := inmem.NewService()
|
||||
svc.IDGenerator = f.IDGenerator
|
||||
|
||||
|
|
|
@ -29,7 +29,7 @@ type Error struct {
|
|||
|
||||
// Error implements the error interface.
|
||||
func (e Error) Error() string {
|
||||
return fmt.Sprintf("%v (error reference code: %d)", e.Err, e.Reference)
|
||||
return e.Err
|
||||
}
|
||||
|
||||
// Errorf constructs an Error with the given reference code and format.
|
||||
|
@ -40,6 +40,7 @@ func Errorf(ref int, format string, i ...interface{}) error {
|
|||
}
|
||||
}
|
||||
|
||||
// New creates a new error with a message and error code.
|
||||
func New(msg string, ref ...int) error {
|
||||
refCode := InternalError
|
||||
if len(ref) == 1 {
|
||||
|
|
Loading…
Reference in New Issue