diff --git a/CHANGELOG.md b/CHANGELOG.md index 3397c5ca..02ce471d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,7 +5,18 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). -## [Unreleased](https://github.com/fivetran/go-fivetran/compare/v0.7.12...HEAD) +## [Unreleased](https://github.com/fivetran/go-fivetran/compare/v0.7.13...HEAD) + +## [0.7.13](https://github.com/fivetran/go-fivetran/compare/v0.7.12...v0.7.13) + +## Added + +Added fields to support Azure Data Lake Storage: +- `DestinationConfig.storageAccountName` +- `DestinationConfig.containerName` +- `DestinationConfig.tenantId` +- `DestinationConfig.clientId` +- `DestinationConfig.secretValue` ## [0.7.12](https://github.com/fivetran/go-fivetran/compare/v0.7.11...v0.7.12) diff --git a/destinations/destination_config.go b/destinations/destination_config.go index 6c6a48de..13682c96 100644 --- a/destinations/destination_config.go +++ b/destinations/destination_config.go @@ -3,296 +3,346 @@ package destinations // DestinationConfig builds Destination Management, Destination Config. // Ref. https://fivetran.com/docs/rest-api/destinations/config type DestinationConfig struct { - host *string - port *int - database *string - auth *string - user *string - password *string - connectionType *string - tunnelHost *string - tunnelPort *string - tunnelUser *string - projectID *string - dataSetLocation *string - bucket *string - serverHostName *string - httpPath *string - personalAccessToken *string - createExternalTables *bool - externalLocation *string - authType *string - roleArn *string - secretKey *string - privateKey *string - clusterId *string - clusterRegion *string - role *string - isPrivateKeyEncrypted *bool - passphrase *string - catalog *string - fivetranRoleArn *string - prefixPath *string - region *string + host *string + port *int + database *string + auth *string + user *string + password *string + connectionType *string + tunnelHost *string + tunnelPort *string + tunnelUser *string + projectID *string + dataSetLocation *string + bucket *string + serverHostName *string + httpPath *string + personalAccessToken *string + createExternalTables *bool + externalLocation *string + authType *string + roleArn *string + secretKey *string + privateKey *string + clusterId *string + clusterRegion *string + role *string + isPrivateKeyEncrypted *bool + passphrase *string + catalog *string + fivetranRoleArn *string + prefixPath *string + region *string + storageAccountName *string + containerName *string + tenantId *string + clientId *string + secretValue *string } type destinationConfigRequest struct { - Host *string `json:"host,omitempty"` - Port *int `json:"port,omitempty"` - Database *string `json:"database,omitempty"` - Auth *string `json:"auth,omitempty"` - User *string `json:"user,omitempty"` - Password *string `json:"password,omitempty"` - ConnectionType *string `json:"connection_type,omitempty"` - TunnelHost *string `json:"tunnel_host,omitempty"` - TunnelPort *string `json:"tunnel_port,omitempty"` - TunnelUser *string `json:"tunnel_user,omitempty"` - ProjectID *string `json:"project_id,omitempty"` - DataSetLocation *string `json:"data_set_location,omitempty"` - Bucket *string `json:"bucket,omitempty"` - ServerHostName *string `json:"server_host_name,omitempty"` - HTTPPath *string `json:"http_path,omitempty"` - PersonalAccessToken *string `json:"personal_access_token,omitempty"` - CreateExternalTables *bool `json:"create_external_tables,omitempty"` - ExternalLocation *string `json:"external_location,omitempty"` - AuthType *string `json:"auth_type,omitempty"` - RoleArn *string `json:"role_arn,omitempty"` - SecretKey *string `json:"secret_key,omitempty"` - PrivateKey *string `json:"private_key,omitempty"` - ClusterId *string `json:"cluster_id,omitempty"` - ClusterRegion *string `json:"cluster_region,omitempty"` - Role *string `json:"role,omitempty"` - IsPrivateKeyEncrypted *bool `json:"is_private_key_encrypted,omitempty"` - Passphrase *string `json:"passphrase,omitempty"` - Catalog *string `json:"catalog,omitempty"` - FivetranRoleArn *string `json:"fivetran_role_arn,omitempty"` - PrefixPath *string `json:"prefix_path,omitempty"` - Region *string `json:"region,omitempty"` + Host *string `json:"host,omitempty"` + Port *int `json:"port,omitempty"` + Database *string `json:"database,omitempty"` + Auth *string `json:"auth,omitempty"` + User *string `json:"user,omitempty"` + Password *string `json:"password,omitempty"` + ConnectionType *string `json:"connection_type,omitempty"` + TunnelHost *string `json:"tunnel_host,omitempty"` + TunnelPort *string `json:"tunnel_port,omitempty"` + TunnelUser *string `json:"tunnel_user,omitempty"` + ProjectID *string `json:"project_id,omitempty"` + DataSetLocation *string `json:"data_set_location,omitempty"` + Bucket *string `json:"bucket,omitempty"` + ServerHostName *string `json:"server_host_name,omitempty"` + HTTPPath *string `json:"http_path,omitempty"` + PersonalAccessToken *string `json:"personal_access_token,omitempty"` + CreateExternalTables *bool `json:"create_external_tables,omitempty"` + ExternalLocation *string `json:"external_location,omitempty"` + AuthType *string `json:"auth_type,omitempty"` + RoleArn *string `json:"role_arn,omitempty"` + SecretKey *string `json:"secret_key,omitempty"` + PrivateKey *string `json:"private_key,omitempty"` + ClusterId *string `json:"cluster_id,omitempty"` + ClusterRegion *string `json:"cluster_region,omitempty"` + Role *string `json:"role,omitempty"` + IsPrivateKeyEncrypted *bool `json:"is_private_key_encrypted,omitempty"` + Passphrase *string `json:"passphrase,omitempty"` + Catalog *string `json:"catalog,omitempty"` + FivetranRoleArn *string `json:"fivetran_role_arn,omitempty"` + PrefixPath *string `json:"prefix_path,omitempty"` + Region *string `json:"region,omitempty"` + StorageAccountName *string `json:"storage_account_name,omitempty"` + ContainerName *string `json:"container_name,omitempty"` + TenantId *string `json:"tenant_id,omitempty"` + ClientId *string `json:"client_id,omitempty"` + SecretValue *string `json:"secret_value,omitempty"` } type DestinationConfigResponse struct { - Host string `json:"host"` - Port string `json:"port"` // Port is sent as `string` but returned as `int`. T-97508 - Database string `json:"database"` - Auth string `json:"auth"` - User string `json:"user"` - Password string `json:"password"` - ConnectionType string `json:"connection_type"` // ConnectionMethod is the REST API's response of ConnectionType. T-111758 - TunnelHost string `json:"tunnel_host"` - TunnelPort string `json:"tunnel_port"` - TunnelUser string `json:"tunnel_user"` - ProjectID string `json:"project_id"` - DataSetLocation string `json:"data_set_location"` - Location string `json:"location"` // Big Query returns `data_set_location` as `location` in response (will be fixed with migration to API V2) - Bucket string `json:"bucket"` - ServerHostName string `json:"server_host_name"` - HTTPPath string `json:"http_path"` - PersonalAccessToken string `json:"personal_access_token"` - CreateExternalTables string `json:"create_external_tables"` - ExternalLocation string `json:"external_location"` - AuthType string `json:"auth_type"` - RoleArn string `json:"role_arn"` - SecretKey string `json:"secret_key"` - PublicKey string `json:"public_key"` // Readonly field - PrivateKey string `json:"private_key"` - ClusterId string `json:"cluster_id"` - ClusterRegion string `json:"cluster_region"` - Role string `json:"role"` - IsPrivateKeyEncrypted string `json:"is_private_key_encrypted"` - Passphrase string `json:"passphrase"` - Catalog string `json:"catalog"` - FivetranRoleArn string `json:"fivetran_role_arn"` - PrefixPath string `json:"prefix_path"` - Region string `json:"region"` + Host string `json:"host"` + Port string `json:"port"` // Port is sent as `string` but returned as `int`. T-97508 + Database string `json:"database"` + Auth string `json:"auth"` + User string `json:"user"` + Password string `json:"password"` + ConnectionType string `json:"connection_type"` // ConnectionMethod is the REST API's response of ConnectionType. T-111758 + TunnelHost string `json:"tunnel_host"` + TunnelPort string `json:"tunnel_port"` + TunnelUser string `json:"tunnel_user"` + ProjectID string `json:"project_id"` + DataSetLocation string `json:"data_set_location"` + Location string `json:"location"` // Big Query returns `data_set_location` as `location` in response (will be fixed with migration to API V2) + Bucket string `json:"bucket"` + ServerHostName string `json:"server_host_name"` + HTTPPath string `json:"http_path"` + PersonalAccessToken string `json:"personal_access_token"` + CreateExternalTables string `json:"create_external_tables"` + ExternalLocation string `json:"external_location"` + AuthType string `json:"auth_type"` + RoleArn string `json:"role_arn"` + SecretKey string `json:"secret_key"` + PublicKey string `json:"public_key"` // Readonly field + PrivateKey string `json:"private_key"` + ClusterId string `json:"cluster_id"` + ClusterRegion string `json:"cluster_region"` + Role string `json:"role"` + IsPrivateKeyEncrypted string `json:"is_private_key_encrypted"` + Passphrase string `json:"passphrase"` + Catalog string `json:"catalog"` + FivetranRoleArn string `json:"fivetran_role_arn"` + PrefixPath string `json:"prefix_path"` + Region string `json:"region"` + StorageAccountName string `json:"storage_account_name"` + ContainerName string `json:"container_name"` + TenantId string `json:"tenant_id"` + ClientId string `json:"client_id"` + SecretValue string `json:"secret_value"` } func (dc *DestinationConfig) Request() *destinationConfigRequest { - return &destinationConfigRequest{ - Host: dc.host, - Port: dc.port, - Database: dc.database, - Auth: dc.auth, - User: dc.user, - Password: dc.password, - ConnectionType: dc.connectionType, - TunnelHost: dc.tunnelHost, - TunnelPort: dc.tunnelPort, - TunnelUser: dc.tunnelUser, - ProjectID: dc.projectID, - DataSetLocation: dc.dataSetLocation, - Bucket: dc.bucket, - ServerHostName: dc.serverHostName, - HTTPPath: dc.httpPath, - PersonalAccessToken: dc.personalAccessToken, - CreateExternalTables: dc.createExternalTables, - ExternalLocation: dc.externalLocation, - AuthType: dc.authType, - RoleArn: dc.roleArn, - SecretKey: dc.secretKey, - PrivateKey: dc.privateKey, - ClusterId: dc.clusterId, - ClusterRegion: dc.clusterRegion, - Role: dc.role, - IsPrivateKeyEncrypted: dc.isPrivateKeyEncrypted, - Passphrase: dc.passphrase, - Catalog: dc.catalog, - FivetranRoleArn: dc.fivetranRoleArn, - PrefixPath: dc.prefixPath, - Region: dc.region, - } + return &destinationConfigRequest{ + Host: dc.host, + Port: dc.port, + Database: dc.database, + Auth: dc.auth, + User: dc.user, + Password: dc.password, + ConnectionType: dc.connectionType, + TunnelHost: dc.tunnelHost, + TunnelPort: dc.tunnelPort, + TunnelUser: dc.tunnelUser, + ProjectID: dc.projectID, + DataSetLocation: dc.dataSetLocation, + Bucket: dc.bucket, + ServerHostName: dc.serverHostName, + HTTPPath: dc.httpPath, + PersonalAccessToken: dc.personalAccessToken, + CreateExternalTables: dc.createExternalTables, + ExternalLocation: dc.externalLocation, + AuthType: dc.authType, + RoleArn: dc.roleArn, + SecretKey: dc.secretKey, + PrivateKey: dc.privateKey, + ClusterId: dc.clusterId, + ClusterRegion: dc.clusterRegion, + Role: dc.role, + IsPrivateKeyEncrypted: dc.isPrivateKeyEncrypted, + Passphrase: dc.passphrase, + Catalog: dc.catalog, + FivetranRoleArn: dc.fivetranRoleArn, + PrefixPath: dc.prefixPath, + Region: dc.region, + StorageAccountName: dc.storageAccountName, + ContainerName: dc.containerName, + TenantId: dc.tenantId, + ClientId: dc.clientId, + SecretValue: dc.secretValue, + } } func (dc *DestinationConfig) Host(value string) *DestinationConfig { - dc.host = &value - return dc + dc.host = &value + return dc } func (dc *DestinationConfig) Port(value int) *DestinationConfig { - dc.port = &value - return dc + dc.port = &value + return dc } func (dc *DestinationConfig) Database(value string) *DestinationConfig { - dc.database = &value - return dc + dc.database = &value + return dc } func (dc *DestinationConfig) Auth(value string) *DestinationConfig { - dc.auth = &value - return dc + dc.auth = &value + return dc } func (dc *DestinationConfig) User(value string) *DestinationConfig { - dc.user = &value - return dc + dc.user = &value + return dc } func (dc *DestinationConfig) Password(value string) *DestinationConfig { - dc.password = &value - return dc + dc.password = &value + return dc } func (dc *DestinationConfig) ConnectionType(value string) *DestinationConfig { - dc.connectionType = &value - return dc + dc.connectionType = &value + return dc } func (dc *DestinationConfig) TunnelHost(value string) *DestinationConfig { - dc.tunnelHost = &value - return dc + dc.tunnelHost = &value + return dc } func (dc *DestinationConfig) TunnelPort(value string) *DestinationConfig { - dc.tunnelPort = &value - return dc + dc.tunnelPort = &value + return dc } func (dc *DestinationConfig) TunnelUser(value string) *DestinationConfig { - dc.tunnelUser = &value - return dc + dc.tunnelUser = &value + return dc } func (dc *DestinationConfig) ProjectID(value string) *DestinationConfig { - dc.projectID = &value - return dc + dc.projectID = &value + return dc } func (dc *DestinationConfig) DataSetLocation(value string) *DestinationConfig { - dc.dataSetLocation = &value - return dc + dc.dataSetLocation = &value + return dc } func (dc *DestinationConfig) Bucket(value string) *DestinationConfig { - dc.bucket = &value - return dc + dc.bucket = &value + return dc } func (dc *DestinationConfig) ServerHostName(value string) *DestinationConfig { - dc.serverHostName = &value - return dc + dc.serverHostName = &value + return dc } func (dc *DestinationConfig) HTTPPath(value string) *DestinationConfig { - dc.httpPath = &value - return dc + dc.httpPath = &value + return dc } func (dc *DestinationConfig) PersonalAccessToken(value string) *DestinationConfig { - dc.personalAccessToken = &value - return dc + dc.personalAccessToken = &value + return dc } func (dc *DestinationConfig) CreateExternalTables(value bool) *DestinationConfig { - dc.createExternalTables = &value - return dc + dc.createExternalTables = &value + return dc } func (dc *DestinationConfig) ExternalLocation(value string) *DestinationConfig { - dc.externalLocation = &value - return dc + dc.externalLocation = &value + return dc } func (dc *DestinationConfig) AuthType(value string) *DestinationConfig { - dc.authType = &value - return dc + dc.authType = &value + return dc } func (dc *DestinationConfig) RoleArn(value string) *DestinationConfig { - dc.roleArn = &value - return dc + dc.roleArn = &value + return dc } func (dc *DestinationConfig) SecretKey(value string) *DestinationConfig { - dc.secretKey = &value - return dc + dc.secretKey = &value + return dc } func (dc *DestinationConfig) PrivateKey(value string) *DestinationConfig { - dc.privateKey = &value - return dc + dc.privateKey = &value + return dc } func (dc *DestinationConfig) ClusterId(value string) *DestinationConfig { - dc.clusterId = &value - return dc + dc.clusterId = &value + return dc } func (dc *DestinationConfig) ClusterRegion(value string) *DestinationConfig { - dc.clusterRegion = &value - return dc + dc.clusterRegion = &value + return dc } func (dc *DestinationConfig) Role(value string) *DestinationConfig { - dc.role = &value - return dc + dc.role = &value + return dc } func (dc *DestinationConfig) IsPrivateKeyEncrypted(value bool) *DestinationConfig { - dc.isPrivateKeyEncrypted = &value - return dc + dc.isPrivateKeyEncrypted = &value + return dc } func (dc *DestinationConfig) Passphrase(value string) *DestinationConfig { - dc.passphrase = &value - return dc + dc.passphrase = &value + return dc } func (dc *DestinationConfig) Catalog(value string) *DestinationConfig { - dc.catalog = &value - return dc + dc.catalog = &value + return dc } func (dc *DestinationConfig) FivetranRoleArn(value string) *DestinationConfig { - dc.fivetranRoleArn = &value - return dc + dc.fivetranRoleArn = &value + return dc } func (dc *DestinationConfig) PrefixPath(value string) *DestinationConfig { - dc.prefixPath = &value - return dc + dc.prefixPath = &value + return dc } func (dc *DestinationConfig) Region(value string) *DestinationConfig { - dc.region = &value - return dc + dc.region = &value + return dc } + + +func (dc *DestinationConfig) StorageAccountName(value string) *DestinationConfig { + dc.storageAccountName = &value + return dc +} + + +func (dc *DestinationConfig) ContainerName(value string) *DestinationConfig { + dc.containerName = &value + return dc +} + + +func (dc *DestinationConfig) TenantId(value string) *DestinationConfig { + dc.tenantId = &value + return dc +} + + +func (dc *DestinationConfig) ClientId(value string) *DestinationConfig { + dc.clientId = &value + return dc +} + + +func (dc *DestinationConfig) SecretValue(value string) *DestinationConfig { + dc.secretValue = &value + return dc +} \ No newline at end of file diff --git a/tests/destination_create_mock_test.go b/tests/destination_create_mock_test.go index eda7a687..e6c25d91 100644 --- a/tests/destination_create_mock_test.go +++ b/tests/destination_create_mock_test.go @@ -1,69 +1,73 @@ package tests import ( - "context" - "fmt" - "net/http" - "strconv" - "testing" + "context" + "fmt" + "net/http" + "strconv" + "testing" - "github.com/fivetran/go-fivetran" - "github.com/fivetran/go-fivetran/destinations" - "github.com/fivetran/go-fivetran/tests/mock" + "github.com/fivetran/go-fivetran" + "github.com/fivetran/go-fivetran/destinations" + "github.com/fivetran/go-fivetran/tests/mock" ) const ( - SERVICE = "test_service" - ID = "test_id" - REGION = "GCP_US_EAST4" - TIME_ZONE = "-5" - SETUP_STATUS = "connected" - TEST_TITLE = "Test Title" - TEST_STATUS = "PASSED" - TEST_MESSAGE = "Test message" - HOST = "your.host" - PORT = 443 - DATABASE = "fivetran" - AUTH = "PASSWORD" - USER = "fivetran_user" - MASKED = "******" - CONNECTION_TYPE = "Directly" - TUNNEL_HOST = "tunnel.host" - TUNNEL_PORT = "334" - TUNNEL_USER = "tunnel_user" - PROJECT_ID = "project_id_value" - DATA_SET_LOCATION = "data_Set_location_value" - LOCATION = "data_Set_location_value" - BUCKET = "your-bucket" - SERVER_HOST_NAME = "server.host.name" - HTTP_PATH = "http.path" - CREATE_EXTERNAL_TABLES = true - EXTERNAL_LOCATION = "group_id" - AUTH_TYPE = "auth_type_value" - ROLE_ARN = "role:arn-xxx" - PUBLIC_KEY = "public_key_value" - CLUSTER_ID = "cluster_id_value" - CLUSTER_REGION = "cluster_region_value" - PASSWORD = "password" - PRIVATE_KEY = "private_key" - SECRET_KEY = "secret_key" - TRUST_CERTIFICATES = true - TRUST_FINGERPRINTS = true - RUN_SETUP_TESTS = true - PERSONAL_ACCESS_TOKEN = "PAT" - ROLE = "role" - PASSPHRASE = "passphrase" - IS_PRIVATE_KEY_ENCRYPTED = true - CATALOG = "catalog" - FIVETRAN_ROLE_ARN = "fivetran_role_arn" - PREFIX_PATH = "prefix_path" + SERVICE = "test_service" + ID = "test_id" + REGION = "GCP_US_EAST4" + TIME_ZONE = "-5" + SETUP_STATUS = "connected" + TEST_TITLE = "Test Title" + TEST_STATUS = "PASSED" + TEST_MESSAGE = "Test message" + HOST = "your.host" + PORT = 443 + DATABASE = "fivetran" + AUTH = "PASSWORD" + USER = "fivetran_user" + MASKED = "******" + CONNECTION_TYPE = "Directly" + TUNNEL_HOST = "tunnel.host" + TUNNEL_PORT = "334" + TUNNEL_USER = "tunnel_user" + PROJECT_ID = "project_id_value" + DATA_SET_LOCATION = "data_Set_location_value" + LOCATION = "data_Set_location_value" + BUCKET = "your-bucket" + SERVER_HOST_NAME = "server.host.name" + HTTP_PATH = "http.path" + CREATE_EXTERNAL_TABLES = true + EXTERNAL_LOCATION = "group_id" + AUTH_TYPE = "auth_type_value" + ROLE_ARN = "role:arn-xxx" + PUBLIC_KEY = "public_key_value" + CLUSTER_ID = "cluster_id_value" + CLUSTER_REGION = "cluster_region_value" + PASSWORD = "password" + PRIVATE_KEY = "private_key" + SECRET_KEY = "secret_key" + TRUST_CERTIFICATES = true + TRUST_FINGERPRINTS = true + RUN_SETUP_TESTS = true + PERSONAL_ACCESS_TOKEN = "PAT" + ROLE = "role" + PASSPHRASE = "passphrase" + IS_PRIVATE_KEY_ENCRYPTED = true + CATALOG = "catalog" + FIVETRAN_ROLE_ARN = "fivetran_role_arn" + PREFIX_PATH = "prefix_path" + STORAGE_ACCOUNT_NAME = "storage_account_name" + CONTAINER_NAME = "container_name" + TENANT_ID = "tenant_id" + CLIENT_ID = "client_id" + SECRET_VALUE = "secret_value" ) func TestNewDestinationCreateFullMappingMock(t *testing.T) { - // arrange - ftClient, mockClient := CreateTestClient() - handler := mockClient.When(http.MethodPost, "/v1/destinations").ThenCall( - + // arrange + ftClient, mockClient := CreateTestClient() + handler := mockClient.When(http.MethodPost, "/v1/destinations").ThenCall( func(req *http.Request) (*http.Response, error) { body := RequestBodyToJson(t, req) assertRequest(t, body) @@ -71,261 +75,287 @@ func TestNewDestinationCreateFullMappingMock(t *testing.T) { return response, nil }) - // act - response, err := ftClient.NewDestinationCreate(). - Service(SERVICE). - Region(REGION). - TimeZoneOffset(TIME_ZONE). - TrustCertificates(TRUST_CERTIFICATES). - TrustFingerprints(TRUST_FINGERPRINTS). - RunSetupTests(RUN_SETUP_TESTS). - GroupID(ID). - Config(prepareConfig()). - Do(context.Background()) + // act + response, err := ftClient.NewDestinationCreate(). + Service(SERVICE). + Region(REGION). + TimeZoneOffset(TIME_ZONE). + TrustCertificates(TRUST_CERTIFICATES). + TrustFingerprints(TRUST_FINGERPRINTS). + RunSetupTests(RUN_SETUP_TESTS). + GroupID(ID). + Config(prepareConfig()). + Do(context.Background()) - if err != nil { - t.Logf("%+v\n", response) - t.Error(err) - } + if err != nil { + t.Logf("%+v\n", response) + t.Error(err) + } - // assert - interactions := mockClient.Interactions() - assertEqual(t, len(interactions), 1) - assertEqual(t, interactions[0].Handler, handler) - assertEqual(t, handler.Interactions, 1) - assertResponse(t, response) + // assert + interactions := mockClient.Interactions() + assertEqual(t, len(interactions), 1) + assertEqual(t, interactions[0].Handler, handler) + assertEqual(t, handler.Interactions, 1) + assertResponse(t, response) } func prepareDestinationResponse() string { - return fmt.Sprintf( - `{ - "code":"Created", - "message":"Destination has been created", - "data":{ - "id": "%v", - "group_id": "%v", - "service": "%v", - "region": "%v", - "time_zone_offset": "%v", - "setup_status": "%v", - "setup_tests":[ - { - "title": "%v", - "status": "%v", - "message": "%v" - } - ], - "config":{ - "host": "%v", - "port": "%v", - "database": "%v", - "auth": "%v", - "user": "%v", - "password": "%v", - "connection_type": "%v", - "tunnel_host": "%v", - "tunnel_port": "%v", - "tunnel_user": "%v", - "project_id": "%v", - "data_set_location": "%v", - "location": "%v", - "bucket": "%v", - "server_host_name": "%v", - "http_path": "%v", - "personal_access_token": "%v", - "create_external_tables": "%v", - "external_location": "%v", - "auth_type": "%v", - "role_arn": "%v", - "secret_key": "%v", - "private_key": "%v", - "public_key": "%v", - "cluster_id": "%v", - "cluster_region": "%v", - "role": "%v", - "is_private_key_encrypted": "%v", - "passphrase": "%v", - "catalog": "%v", - "fivetran_role_arn": "%v", - "prefix_path": "%v", - "region": "%v" - } - } - }`, - ID, // id - ID, // group_id - SERVICE, - REGION, - TIME_ZONE, // time_zone_offset - SETUP_STATUS, - TEST_TITLE, - TEST_STATUS, - TEST_MESSAGE, - HOST, - PORT, - DATABASE, - AUTH, - USER, - MASKED, // password - CONNECTION_TYPE, - TUNNEL_HOST, - TUNNEL_PORT, - TUNNEL_USER, - PROJECT_ID, - DATA_SET_LOCATION, - LOCATION, - BUCKET, - SERVER_HOST_NAME, - HTTP_PATH, - MASKED, // personal_access_token - CREATE_EXTERNAL_TABLES, - EXTERNAL_LOCATION, - AUTH_TYPE, - ROLE_ARN, - MASKED, // secret_key - MASKED, // private_key - PUBLIC_KEY, - CLUSTER_ID, - CLUSTER_REGION, - ROLE, - IS_PRIVATE_KEY_ENCRYPTED, - PASSPHRASE, - CATALOG, - FIVETRAN_ROLE_ARN, - PREFIX_PATH, - REGION, - ) + return fmt.Sprintf( + `{ + "code":"Created", + "message":"Destination has been created", + "data":{ + "id": "%v", + "group_id": "%v", + "service": "%v", + "region": "%v", + "time_zone_offset": "%v", + "setup_status": "%v", + "setup_tests":[ + { + "title": "%v", + "status": "%v", + "message": "%v" + } + ], + "config":{ + "host": "%v", + "port": "%v", + "database": "%v", + "auth": "%v", + "user": "%v", + "password": "%v", + "connection_type": "%v", + "tunnel_host": "%v", + "tunnel_port": "%v", + "tunnel_user": "%v", + "project_id": "%v", + "data_set_location": "%v", + "location": "%v", + "bucket": "%v", + "server_host_name": "%v", + "http_path": "%v", + "personal_access_token": "%v", + "create_external_tables": "%v", + "external_location": "%v", + "auth_type": "%v", + "role_arn": "%v", + "secret_key": "%v", + "private_key": "%v", + "public_key": "%v", + "cluster_id": "%v", + "cluster_region": "%v", + "role": "%v", + "is_private_key_encrypted": "%v", + "passphrase": "%v", + "catalog": "%v", + "fivetran_role_arn": "%v", + "prefix_path": "%v", + "region": "%v", + "storage_account_name": "%v", + "container_name": "%v", + "tenant_id": "%v", + "client_id": "%v", + "secret_value": "%v" + } + } + }`, + ID, // id + ID, // group_id + SERVICE, + REGION, + TIME_ZONE, // time_zone_offset + SETUP_STATUS, + TEST_TITLE, + TEST_STATUS, + TEST_MESSAGE, + HOST, + PORT, + DATABASE, + AUTH, + USER, + MASKED, // password + CONNECTION_TYPE, + TUNNEL_HOST, + TUNNEL_PORT, + TUNNEL_USER, + PROJECT_ID, + DATA_SET_LOCATION, + LOCATION, + BUCKET, + SERVER_HOST_NAME, + HTTP_PATH, + MASKED, // personal_access_token + CREATE_EXTERNAL_TABLES, + EXTERNAL_LOCATION, + AUTH_TYPE, + ROLE_ARN, + MASKED, // secret_key + MASKED, // private_key + PUBLIC_KEY, + CLUSTER_ID, + CLUSTER_REGION, + ROLE, + IS_PRIVATE_KEY_ENCRYPTED, + PASSPHRASE, + CATALOG, + FIVETRAN_ROLE_ARN, + PREFIX_PATH, + REGION, + STORAGE_ACCOUNT_NAME, + CONTAINER_NAME, + TENANT_ID, + CLIENT_ID, + SECRET_VALUE, + ) } func prepareConfig() *destinations.DestinationConfig { - config := fivetran.NewDestinationConfig() - config.Host(HOST) - config.Port(PORT) - config.Database(DATABASE) - config.Auth(AUTH) - config.User(USER) - config.Password(PASSWORD) - config.ConnectionType(CONNECTION_TYPE) - config.TunnelHost(TUNNEL_HOST) - config.TunnelPort(TUNNEL_PORT) - config.TunnelUser(TUNNEL_USER) - config.ProjectID(PROJECT_ID) - config.Bucket(BUCKET) - config.ServerHostName(SERVER_HOST_NAME) - config.HTTPPath(HTTP_PATH) - config.PersonalAccessToken(PERSONAL_ACCESS_TOKEN) - config.CreateExternalTables(CREATE_EXTERNAL_TABLES) - config.ExternalLocation(EXTERNAL_LOCATION) - config.AuthType(AUTH_TYPE) - config.RoleArn(ROLE_ARN) - config.SecretKey(SECRET_KEY) - config.PrivateKey(PRIVATE_KEY) - config.ClusterId(CLUSTER_ID) - config.ClusterRegion(CLUSTER_REGION) - config.Role(ROLE) - config.IsPrivateKeyEncrypted(IS_PRIVATE_KEY_ENCRYPTED) - config.Passphrase(PASSPHRASE) - config.Catalog(CATALOG) - config.FivetranRoleArn(FIVETRAN_ROLE_ARN) - config.PrefixPath(PREFIX_PATH) - config.Region(REGION) - return config + config := fivetran.NewDestinationConfig() + config.Host(HOST) + config.Port(PORT) + config.Database(DATABASE) + config.Auth(AUTH) + config.User(USER) + config.Password(PASSWORD) + config.ConnectionType(CONNECTION_TYPE) + config.TunnelHost(TUNNEL_HOST) + config.TunnelPort(TUNNEL_PORT) + config.TunnelUser(TUNNEL_USER) + config.ProjectID(PROJECT_ID) + config.Bucket(BUCKET) + config.ServerHostName(SERVER_HOST_NAME) + config.HTTPPath(HTTP_PATH) + config.PersonalAccessToken(PERSONAL_ACCESS_TOKEN) + config.CreateExternalTables(CREATE_EXTERNAL_TABLES) + config.ExternalLocation(EXTERNAL_LOCATION) + config.AuthType(AUTH_TYPE) + config.RoleArn(ROLE_ARN) + config.SecretKey(SECRET_KEY) + config.PrivateKey(PRIVATE_KEY) + config.ClusterId(CLUSTER_ID) + config.ClusterRegion(CLUSTER_REGION) + config.Role(ROLE) + config.IsPrivateKeyEncrypted(IS_PRIVATE_KEY_ENCRYPTED) + config.Passphrase(PASSPHRASE) + config.Catalog(CATALOG) + config.FivetranRoleArn(FIVETRAN_ROLE_ARN) + config.PrefixPath(PREFIX_PATH) + config.Region(REGION) + config.StorageAccountName(STORAGE_ACCOUNT_NAME) + config.ContainerName(CONTAINER_NAME) + config.TenantId(TENANT_ID) + config.ClientId(CLIENT_ID) + config.SecretValue(SECRET_VALUE) + + return config } func assertRequest(t *testing.T, request map[string]interface{}) { - assertKey(t, "service", request, SERVICE) - assertKey(t, "region", request, REGION) - assertKey(t, "time_zone_offset", request, TIME_ZONE) - assertKey(t, "trust_certificates", request, TRUST_CERTIFICATES) - assertKey(t, "trust_fingerprints", request, TRUST_FINGERPRINTS) - assertKey(t, "run_setup_tests", request, RUN_SETUP_TESTS) - assertKey(t, "group_id", request, ID) + assertKey(t, "service", request, SERVICE) + assertKey(t, "region", request, REGION) + assertKey(t, "time_zone_offset", request, TIME_ZONE) + assertKey(t, "trust_certificates", request, TRUST_CERTIFICATES) + assertKey(t, "trust_fingerprints", request, TRUST_FINGERPRINTS) + assertKey(t, "run_setup_tests", request, RUN_SETUP_TESTS) + assertKey(t, "group_id", request, ID) - c, ok := request["config"] - assertEqual(t, ok, true) - config, ok := c.(map[string]interface{}) - assertEqual(t, ok, true) + c, ok := request["config"] + assertEqual(t, ok, true) + config, ok := c.(map[string]interface{}) + assertEqual(t, ok, true) - assertKey(t, "host", config, HOST) - assertKey(t, "port", config, float64(PORT)) // json marshalling stores all numbers as float64 - assertKey(t, "database", config, DATABASE) - assertKey(t, "auth", config, AUTH) - assertKey(t, "user", config, USER) - assertKey(t, "password", config, PASSWORD) - assertKey(t, "connection_type", config, CONNECTION_TYPE) - assertKey(t, "tunnel_host", config, TUNNEL_HOST) - assertKey(t, "tunnel_port", config, TUNNEL_PORT) - assertKey(t, "tunnel_user", config, TUNNEL_USER) - assertKey(t, "project_id", config, PROJECT_ID) - assertKey(t, "bucket", config, BUCKET) - assertKey(t, "server_host_name", config, SERVER_HOST_NAME) - assertKey(t, "http_path", config, HTTP_PATH) - assertKey(t, "personal_access_token", config, PERSONAL_ACCESS_TOKEN) - assertKey(t, "create_external_tables", config, CREATE_EXTERNAL_TABLES) - assertKey(t, "external_location", config, EXTERNAL_LOCATION) - assertKey(t, "auth_type", config, AUTH_TYPE) - assertKey(t, "role_arn", config, ROLE_ARN) - assertKey(t, "secret_key", config, SECRET_KEY) - assertKey(t, "private_key", config, PRIVATE_KEY) - assertKey(t, "cluster_id", config, CLUSTER_ID) - assertKey(t, "cluster_region", config, CLUSTER_REGION) - assertKey(t, "role", config, ROLE) - assertKey(t, "is_private_key_encrypted", config, IS_PRIVATE_KEY_ENCRYPTED) - assertKey(t, "passphrase", config, PASSPHRASE) - assertKey(t, "catalog", config, CATALOG) - assertKey(t, "fivetran_role_arn", config, FIVETRAN_ROLE_ARN) - assertKey(t, "prefix_path", config, PREFIX_PATH) - assertKey(t, "region", config, REGION) + assertKey(t, "host", config, HOST) + assertKey(t, "port", config, float64(PORT)) // json marshalling stores all numbers as float64 + assertKey(t, "database", config, DATABASE) + assertKey(t, "auth", config, AUTH) + assertKey(t, "user", config, USER) + assertKey(t, "password", config, PASSWORD) + assertKey(t, "connection_type", config, CONNECTION_TYPE) + assertKey(t, "tunnel_host", config, TUNNEL_HOST) + assertKey(t, "tunnel_port", config, TUNNEL_PORT) + assertKey(t, "tunnel_user", config, TUNNEL_USER) + assertKey(t, "project_id", config, PROJECT_ID) + assertKey(t, "bucket", config, BUCKET) + assertKey(t, "server_host_name", config, SERVER_HOST_NAME) + assertKey(t, "http_path", config, HTTP_PATH) + assertKey(t, "personal_access_token", config, PERSONAL_ACCESS_TOKEN) + assertKey(t, "create_external_tables", config, CREATE_EXTERNAL_TABLES) + assertKey(t, "external_location", config, EXTERNAL_LOCATION) + assertKey(t, "auth_type", config, AUTH_TYPE) + assertKey(t, "role_arn", config, ROLE_ARN) + assertKey(t, "secret_key", config, SECRET_KEY) + assertKey(t, "private_key", config, PRIVATE_KEY) + assertKey(t, "cluster_id", config, CLUSTER_ID) + assertKey(t, "cluster_region", config, CLUSTER_REGION) + assertKey(t, "role", config, ROLE) + assertKey(t, "is_private_key_encrypted", config, IS_PRIVATE_KEY_ENCRYPTED) + assertKey(t, "passphrase", config, PASSPHRASE) + assertKey(t, "catalog", config, CATALOG) + assertKey(t, "fivetran_role_arn", config, FIVETRAN_ROLE_ARN) + assertKey(t, "prefix_path", config, PREFIX_PATH) + assertKey(t, "region", config, REGION) + assertKey(t, "storage_account_name", config, STORAGE_ACCOUNT_NAME) + assertKey(t, "container_name", config, CONTAINER_NAME) + assertKey(t, "tenant_id", config, TENANT_ID) + assertKey(t, "client_id", config, CLIENT_ID) + assertKey(t, "secret_value", config, SECRET_VALUE) } func assertResponse(t *testing.T, response destinations.DestinationDetailsWithSetupTestsResponse) { - assertEqual(t, response.Code, "Created") - assertNotEmpty(t, response.Message) + assertEqual(t, response.Code, "Created") + assertNotEmpty(t, response.Message) - assertEqual(t, response.Data.GroupID, ID) - assertEqual(t, response.Data.ID, ID) - assertEqual(t, response.Data.Region, REGION) - assertEqual(t, response.Data.Service, SERVICE) - assertEqual(t, response.Data.SetupStatus, SETUP_STATUS) - assertEqual(t, response.Data.TimeZoneOffset, TIME_ZONE) + assertEqual(t, response.Data.GroupID, ID) + assertEqual(t, response.Data.ID, ID) + assertEqual(t, response.Data.Region, REGION) + assertEqual(t, response.Data.Service, SERVICE) + assertEqual(t, response.Data.SetupStatus, SETUP_STATUS) + assertEqual(t, response.Data.TimeZoneOffset, TIME_ZONE) - assertEqual(t, len(response.Data.SetupTests), 1) - assertEqual(t, response.Data.SetupTests[0].Message, TEST_MESSAGE) - assertEqual(t, response.Data.SetupTests[0].Status, TEST_STATUS) - assertEqual(t, response.Data.SetupTests[0].Title, TEST_TITLE) + assertEqual(t, len(response.Data.SetupTests), 1) + assertEqual(t, response.Data.SetupTests[0].Message, TEST_MESSAGE) + assertEqual(t, response.Data.SetupTests[0].Status, TEST_STATUS) + assertEqual(t, response.Data.SetupTests[0].Title, TEST_TITLE) - assertEqual(t, response.Data.Config.Auth, AUTH) - assertEqual(t, response.Data.Config.AuthType, AUTH_TYPE) - assertEqual(t, response.Data.Config.Bucket, BUCKET) - assertEqual(t, response.Data.Config.ClusterId, CLUSTER_ID) - assertEqual(t, response.Data.Config.ClusterRegion, CLUSTER_REGION) - assertEqual(t, response.Data.Config.ConnectionType, CONNECTION_TYPE) - assertEqual(t, response.Data.Config.CreateExternalTables, boolToStr(CREATE_EXTERNAL_TABLES)) // Inconsistent response - assertEqual(t, response.Data.Config.DataSetLocation, DATA_SET_LOCATION) - assertEqual(t, response.Data.Config.Database, DATABASE) - assertEqual(t, response.Data.Config.ExternalLocation, EXTERNAL_LOCATION) - assertEqual(t, response.Data.Config.HTTPPath, HTTP_PATH) - assertEqual(t, response.Data.Config.Host, HOST) - assertEqual(t, response.Data.Config.Password, MASKED) - assertEqual(t, response.Data.Config.PersonalAccessToken, MASKED) - assertEqual(t, response.Data.Config.Port, strconv.Itoa(PORT)) - assertEqual(t, response.Data.Config.PrivateKey, MASKED) - assertEqual(t, response.Data.Config.ProjectID, PROJECT_ID) - assertEqual(t, response.Data.Config.PublicKey, PUBLIC_KEY) - assertEqual(t, response.Data.Config.RoleArn, ROLE_ARN) - assertEqual(t, response.Data.Config.SecretKey, MASKED) - assertEqual(t, response.Data.Config.ServerHostName, SERVER_HOST_NAME) - assertEqual(t, response.Data.Config.TunnelHost, TUNNEL_HOST) - assertEqual(t, response.Data.Config.TunnelPort, TUNNEL_PORT) - assertEqual(t, response.Data.Config.TunnelUser, TUNNEL_USER) - assertEqual(t, response.Data.Config.User, USER) - assertEqual(t, response.Data.Config.Location, LOCATION) - assertEqual(t, response.Data.Config.Role, ROLE) - assertEqual(t, response.Data.Config.IsPrivateKeyEncrypted, boolToStr(IS_PRIVATE_KEY_ENCRYPTED)) - assertEqual(t, response.Data.Config.Passphrase, PASSPHRASE) - assertEqual(t, response.Data.Config.Catalog, CATALOG) - assertEqual(t, response.Data.Config.FivetranRoleArn, FIVETRAN_ROLE_ARN) - assertEqual(t, response.Data.Config.PrefixPath, PREFIX_PATH) - assertEqual(t, response.Data.Config.Region, REGION) + assertEqual(t, response.Data.Config.Auth, AUTH) + assertEqual(t, response.Data.Config.AuthType, AUTH_TYPE) + assertEqual(t, response.Data.Config.Bucket, BUCKET) + assertEqual(t, response.Data.Config.ClusterId, CLUSTER_ID) + assertEqual(t, response.Data.Config.ClusterRegion, CLUSTER_REGION) + assertEqual(t, response.Data.Config.ConnectionType, CONNECTION_TYPE) + assertEqual(t, response.Data.Config.CreateExternalTables, boolToStr(CREATE_EXTERNAL_TABLES)) // Inconsistent response + assertEqual(t, response.Data.Config.DataSetLocation, DATA_SET_LOCATION) + assertEqual(t, response.Data.Config.Database, DATABASE) + assertEqual(t, response.Data.Config.ExternalLocation, EXTERNAL_LOCATION) + assertEqual(t, response.Data.Config.HTTPPath, HTTP_PATH) + assertEqual(t, response.Data.Config.Host, HOST) + assertEqual(t, response.Data.Config.Password, MASKED) + assertEqual(t, response.Data.Config.PersonalAccessToken, MASKED) + assertEqual(t, response.Data.Config.Port, strconv.Itoa(PORT)) + assertEqual(t, response.Data.Config.PrivateKey, MASKED) + assertEqual(t, response.Data.Config.ProjectID, PROJECT_ID) + assertEqual(t, response.Data.Config.PublicKey, PUBLIC_KEY) + assertEqual(t, response.Data.Config.RoleArn, ROLE_ARN) + assertEqual(t, response.Data.Config.SecretKey, MASKED) + assertEqual(t, response.Data.Config.ServerHostName, SERVER_HOST_NAME) + assertEqual(t, response.Data.Config.TunnelHost, TUNNEL_HOST) + assertEqual(t, response.Data.Config.TunnelPort, TUNNEL_PORT) + assertEqual(t, response.Data.Config.TunnelUser, TUNNEL_USER) + assertEqual(t, response.Data.Config.User, USER) + assertEqual(t, response.Data.Config.Location, LOCATION) + assertEqual(t, response.Data.Config.Role, ROLE) + assertEqual(t, response.Data.Config.IsPrivateKeyEncrypted, boolToStr(IS_PRIVATE_KEY_ENCRYPTED)) + assertEqual(t, response.Data.Config.Passphrase, PASSPHRASE) + assertEqual(t, response.Data.Config.Catalog, CATALOG) + assertEqual(t, response.Data.Config.FivetranRoleArn, FIVETRAN_ROLE_ARN) + assertEqual(t, response.Data.Config.PrefixPath, PREFIX_PATH) + assertEqual(t, response.Data.Config.Region, REGION) + assertEqual(t, response.Data.Config.StorageAccountName, STORAGE_ACCOUNT_NAME) + assertEqual(t, response.Data.Config.ContainerName, CONTAINER_NAME) + assertEqual(t, response.Data.Config.TenantId, TENANT_ID) + assertEqual(t, response.Data.Config.ClientId, CLIENT_ID) + assertEqual(t, response.Data.Config.SecretValue, SECRET_VALUE) }