github.com/cs3org/reva/v2@v2.27.7/pkg/storage/fs/s3ng/s3ng_test.go (about)

     1  // Copyright 2018-2021 CERN
     2  //
     3  // Licensed under the Apache License, Version 2.0 (the "License");
     4  // you may not use this file except in compliance with the License.
     5  // You may obtain a copy of the License at
     6  //
     7  //     http://www.apache.org/licenses/LICENSE-2.0
     8  //
     9  // Unless required by applicable law or agreed to in writing, software
    10  // distributed under the License is distributed on an "AS IS" BASIS,
    11  // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    12  // See the License for the specific language governing permissions and
    13  // limitations under the License.
    14  //
    15  // In applying this license, CERN does not waive the privileges and immunities
    16  // granted to it by virtue of its status as an Intergovernmental Organization
    17  // or submit itself to any jurisdiction.
    18  
    19  package s3ng_test
    20  
    21  import (
    22  	"os"
    23  
    24  	"github.com/cs3org/reva/v2/pkg/storage/fs/s3ng"
    25  	"github.com/cs3org/reva/v2/tests/helpers"
    26  	"github.com/rs/zerolog"
    27  
    28  	. "github.com/onsi/ginkgo/v2"
    29  	. "github.com/onsi/gomega"
    30  )
    31  
    32  var _ = Describe("S3ng", func() {
    33  	var (
    34  		options map[string]interface{}
    35  		tmpRoot string
    36  	)
    37  
    38  	BeforeEach(func() {
    39  		tmpRoot, err := helpers.TempDir("reva-unit-tests-*-root")
    40  		Expect(err).ToNot(HaveOccurred())
    41  
    42  		options = map[string]interface{}{
    43  			"root":           tmpRoot,
    44  			"share_folder":   "/Shares",
    45  			"permissionssvc": "any",
    46  			"s3.endpoint":    "http://1.2.3.4:5000",
    47  			"s3.region":      "default",
    48  			"s3.bucket":      "the-bucket",
    49  			"s3.access_key":  "foo",
    50  			"s3.secret_key":  "bar",
    51  		}
    52  	})
    53  
    54  	AfterEach(func() {
    55  		if tmpRoot != "" {
    56  			os.RemoveAll(tmpRoot)
    57  		}
    58  	})
    59  
    60  	Describe("New", func() {
    61  		It("fails on missing s3 configuration", func() {
    62  			_, err := s3ng.New(map[string]interface{}{}, nil, &zerolog.Logger{})
    63  			Expect(err).To(MatchError("S3 configuration incomplete"))
    64  		})
    65  
    66  		It("works with complete configuration", func() {
    67  			_, err := s3ng.New(options, nil, &zerolog.Logger{})
    68  			Expect(err).ToNot(HaveOccurred())
    69  		})
    70  	})
    71  })