summaryrefslogtreecommitdiffstats
path: root/api4/system_test.go
diff options
context:
space:
mode:
authorCarlos Tadeu Panato Junior <ctadeu@gmail.com>2018-03-01 00:12:11 +0100
committerJoram Wilander <jwawilander@gmail.com>2018-02-28 23:12:11 +0000
commit6e024c45b50d31c20eb0d509263d3e0f888847de (patch)
treed5f2832be27e721b3669c4fc536e96c4187345bb /api4/system_test.go
parentd2b70b8671bd267e4b955e3da2ee0670daba5f2c (diff)
downloadchat-6e024c45b50d31c20eb0d509263d3e0f888847de.tar.gz
chat-6e024c45b50d31c20eb0d509263d3e0f888847de.tar.bz2
chat-6e024c45b50d31c20eb0d509263d3e0f888847de.zip
[PLT-8186] add support for ec2 instance profile authentication (#8243)
Diffstat (limited to 'api4/system_test.go')
-rw-r--r--api4/system_test.go64
1 files changed, 64 insertions, 0 deletions
diff --git a/api4/system_test.go b/api4/system_test.go
index 01b4934ae..e39486b77 100644
--- a/api4/system_test.go
+++ b/api4/system_test.go
@@ -1,7 +1,9 @@
package api4
import (
+ "fmt"
"net/http"
+ "os"
"strings"
"testing"
@@ -466,3 +468,65 @@ func TestGetAnalyticsOld(t *testing.T) {
_, resp = Client.GetAnalyticsOld("", th.BasicTeam.Id)
CheckUnauthorizedStatus(t, resp)
}
+
+func TestS3TestConnection(t *testing.T) {
+ th := Setup().InitBasic().InitSystemAdmin()
+ defer th.TearDown()
+ Client := th.Client
+
+ s3Host := os.Getenv("CI_HOST")
+ if s3Host == "" {
+ s3Host = "dockerhost"
+ }
+
+ s3Port := os.Getenv("CI_MINIO_PORT")
+ if s3Port == "" {
+ s3Port = "9001"
+ }
+
+ s3Endpoint := fmt.Sprintf("%s:%s", s3Host, s3Port)
+ config := model.Config{
+ FileSettings: model.FileSettings{
+ DriverName: model.NewString(model.IMAGE_DRIVER_S3),
+ AmazonS3AccessKeyId: model.MINIO_ACCESS_KEY,
+ AmazonS3SecretAccessKey: model.MINIO_SECRET_KEY,
+ AmazonS3Bucket: "",
+ AmazonS3Endpoint: "",
+ AmazonS3SSL: model.NewBool(false),
+ },
+ }
+
+ _, resp := Client.TestS3Connection(&config)
+ CheckForbiddenStatus(t, resp)
+
+ _, resp = th.SystemAdminClient.TestS3Connection(&config)
+ CheckBadRequestStatus(t, resp)
+ if resp.Error.Message != "S3 Bucket is required" {
+ t.Fatal("should return error - missing s3 bucket")
+ }
+
+ config.FileSettings.AmazonS3Bucket = model.MINIO_BUCKET
+ _, resp = th.SystemAdminClient.TestS3Connection(&config)
+ CheckBadRequestStatus(t, resp)
+ if resp.Error.Message != "S3 Endpoint is required" {
+ t.Fatal("should return error - missing s3 endpoint")
+ }
+
+ config.FileSettings.AmazonS3Endpoint = s3Endpoint
+ _, resp = th.SystemAdminClient.TestS3Connection(&config)
+ CheckBadRequestStatus(t, resp)
+ if resp.Error.Message != "S3 Region is required" {
+ t.Fatal("should return error - missing s3 region")
+ }
+
+ config.FileSettings.AmazonS3Region = "us-east-1"
+ _, resp = th.SystemAdminClient.TestS3Connection(&config)
+ CheckOKStatus(t, resp)
+
+ config.FileSettings.AmazonS3Bucket = "Wrong_bucket"
+ _, resp = th.SystemAdminClient.TestS3Connection(&config)
+ CheckInternalErrorStatus(t, resp)
+ if resp.Error.Message != "Error checking if bucket exists." {
+ t.Fatal("should return error ")
+ }
+}