diff --git a/Dockerfile b/Dockerfile index 547bfb257..a11000a10 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM 020413372491.dkr.ecr.us-east-1.amazonaws.com/tools/gdc-java-11-jre-centos9:202607101511.b527cf7b +FROM 020413372491.dkr.ecr.us-east-1.amazonaws.com/tools/gdc-java-11-jre:202609300803.5ae07065-f44 ARG RVM_VERSION=stable ARG JRUBY_VERSION=9.4.12.1 @@ -6,12 +6,12 @@ ARG JRUBY_VERSION=9.4.12.1 LABEL image_name="GDC LCM Bricks" LABEL maintainer="LCM " LABEL git_repository_url="https://github.com/gooddata/gooddata-ruby/" -LABEL parent_image="020413372491.dkr.ecr.us-east-1.amazonaws.com/tools/gdc-java-11-jre-centos9:202607101511.b527cf7b" +LABEL parent_image="020413372491.dkr.ecr.us-east-1.amazonaws.com/tools/gdc-java-11-jre:202609300803.5ae07065-f44" # which is required by RVM -RUN yum install -y gcc gcc-c++ which patch make unzip gnupg git maven procps gzip \ +RUN yum install -y gcc gcc-c++ which patch make unzip gnupg git maven procps gzip gawk bzip2 \ && yum clean all \ - && rm -rf /var/cache/yum + && rm -rf /var/cache/libdnf5 # Install + verify RVM with gpg (https://rvm.io/rvm/security) RUN curl -sSL https://rvm.io/mpapis.asc | gpg --import - \ diff --git a/DockerfileOldImage b/DockerfileOldImage index 9d1e7921a..7bde5e660 100644 --- a/DockerfileOldImage +++ b/DockerfileOldImage @@ -1,4 +1,4 @@ -FROM 020413372491.dkr.ecr.us-east-1.amazonaws.com/tools/gdc-java-11-jre-centos9:202607101511.b527cf7b +FROM 020413372491.dkr.ecr.us-east-1.amazonaws.com/tools/gdc-java-11-jre:202609300803.5ae07065-f44 ARG RVM_VERSION=stable @@ -8,12 +8,12 @@ ARG JRUBY_VERSION=9.2.20.0 LABEL image_name="GDC LCM Bricks" LABEL maintainer="LCM " LABEL git_repository_url="https://github.com/gooddata/gooddata-ruby/" -LABEL parent_image="020413372491.dkr.ecr.us-east-1.amazonaws.com/tools/gdc-java-11-jre-centos9:202607101511.b527cf7b" +LABEL parent_image="020413372491.dkr.ecr.us-east-1.amazonaws.com/tools/gdc-java-11-jre:202609300803.5ae07065-f44" # which is required by RVM -RUN yum install -y gcc gcc-c++ diffutils curl-minimal which patch make git maven procps \ +RUN yum install -y gcc gcc-c++ diffutils curl-minimal which patch make gnupg git maven procps gawk bzip2 \ && yum clean all \ - && rm -rf /var/cache/yum + && rm -rf /var/cache/libdnf5 # Install + verify RVM with gpg (https://rvm.io/rvm/security) RUN curl -sSL https://rvm.io/mpapis.asc | gpg --import - \ diff --git a/VERSION b/VERSION index f05c78f23..1d8d36163 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -3.7.109 +3.7.111 diff --git a/lib/gooddata/cloud_resources/redshift/redshift_client.rb b/lib/gooddata/cloud_resources/redshift/redshift_client.rb index 65500b8e5..09ddf2abd 100644 --- a/lib/gooddata/cloud_resources/redshift/redshift_client.rb +++ b/lib/gooddata/cloud_resources/redshift/redshift_client.rb @@ -74,14 +74,23 @@ def connect full_url = build_url(@url, @database) GoodData.logger.info "Setting up connection to Redshift #{full_url}" + # The driver defaults 'user' to the JVM's user.name and reads it before UID, + # so 'user' must be set explicitly or UID is ignored. prop = java.util.Properties.new if @authentication['basic'] - prop.setProperty('UID', @authentication['basic']['userName']) - prop.setProperty('PWD', @authentication['basic']['password']) + user = @authentication['basic']['userName'] + password = @authentication['basic']['password'] + prop.setProperty('user', user) + prop.setProperty('UID', user) + prop.setProperty('password', password) + prop.setProperty('PWD', password) else + db_user = @authentication['iam']['dbUser'] prop.setProperty('AccessKeyID', @authentication['iam']['accessKeyId']) prop.setProperty('SecretAccessKey', @authentication['iam']['secretAccessKey']) - prop.setProperty('DbUser', @authentication['iam']['dbUser']) + prop.setProperty('DbUser', db_user) + prop.setProperty('user', db_user) + prop.setProperty('UID', db_user) end @connection = com.amazon.redshift.jdbc42.Driver.new.connect(full_url, prop) diff --git a/spec/unit/cloud_resources/redshift/redshift_client_spec.rb b/spec/unit/cloud_resources/redshift/redshift_client_spec.rb new file mode 100644 index 000000000..466d93770 --- /dev/null +++ b/spec/unit/cloud_resources/redshift/redshift_client_spec.rb @@ -0,0 +1,70 @@ +# encoding: UTF-8 +# +# Copyright (c) 2010-2026 GoodData Corporation. All rights reserved. +# This source code is licensed under the BSD-style license found in the +# LICENSE file in the root directory of this source tree. + +if RUBY_PLATFORM =~ /java/ + require 'gooddata/cloud_resources/redshift/redshift_client' + + describe GoodData::CloudResources::RedshiftClient do + let(:driver) { double('driver') } + let(:driver_class) { double('driver_class', new: driver) } + let(:options) do + { + 'redshift_client' => { + 'connection' => { + 'url' => 'jdbc:redshift://redshift.example.com:5439', + 'database' => 'db', + 'authentication' => authentication + } + } + } + end + + # Driver jars are not on the classpath in unit tests, so stub the Java package chain + before do + allow(Java).to receive_message_chain('com.amazon.redshift.jdbc42.Driver').and_return(driver_class) + end + + subject do + client = described_class.new(options) + allow(client).to receive_message_chain('com.amazon.redshift.jdbc42.Driver').and_return(driver_class) + client + end + + def connect_properties + received = nil + allow(driver).to receive(:connect) { |_url, props| received = props } + subject.connect + received + end + + context 'with basic authentication' do + let(:authentication) { { 'basic' => { 'userName' => 'basic_user', 'password' => 'secret' } } } + + it 'sets user and password to the configured values' do + props = connect_properties + expect(props.getProperty('user')).to eq 'basic_user' + expect(props.getProperty('UID')).to eq 'basic_user' + expect(props.getProperty('password')).to eq 'secret' + expect(props.getProperty('PWD')).to eq 'secret' + end + end + + context 'with IAM authentication' do + let(:authentication) do + { 'iam' => { 'accessKeyId' => 'key_id', 'secretAccessKey' => 'secret_key', 'dbUser' => 'iam_user' } } + end + + it 'sets user to the configured dbUser' do + props = connect_properties + expect(props.getProperty('user')).to eq 'iam_user' + expect(props.getProperty('UID')).to eq 'iam_user' + expect(props.getProperty('DbUser')).to eq 'iam_user' + expect(props.getProperty('AccessKeyID')).to eq 'key_id' + expect(props.getProperty('SecretAccessKey')).to eq 'secret_key' + end + end + end +end