-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
447 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -26,6 +26,8 @@ _testmain.go | |
# This project's binaries | ||
sql-runner | ||
*.tmp | ||
coverage.out | ||
coverage.html | ||
|
||
# Vagrant | ||
.vagrant/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
#!/bin/bash | ||
|
||
# Copyright (c) 2015-2016 Snowplow Analytics Ltd. All rights reserved. | ||
# | ||
# This program is licensed to you under the Apache License Version 2.0, | ||
# and you may not use this file except in compliance with the Apache License Version 2.0. | ||
# You may obtain a copy of the Apache License Version 2.0 at http://www.apache.org/licenses/LICENSE-2.0. | ||
# | ||
# Unless required by applicable law or agreed to in writing, | ||
# software distributed under the Apache License Version 2.0 is distributed on an | ||
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the Apache License Version 2.0 for the specific language governing permissions and limitations there under. | ||
|
||
set -e | ||
|
||
|
||
|
||
# ----------------------------------------------------------------------------- | ||
# CONSTANTS | ||
# ----------------------------------------------------------------------------- | ||
|
||
home=${HOME} | ||
aws_dir=${home}/.aws | ||
creds_file=${aws_dir}/credentials | ||
|
||
|
||
|
||
# ----------------------------------------------------------------------------- | ||
# EXECUTION | ||
# ----------------------------------------------------------------------------- | ||
|
||
mkdir -p ${aws_dir} | ||
touch ${creds_file} | ||
|
||
echo "[default]" >> ${creds_file} | ||
echo "aws_access_key_id=some-aws-key" >> ${creds_file} | ||
echo "aws_secret_access_key=some-aws-secret" >> ${creds_file} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
// | ||
// Copyright (c) 2015-2016 Snowplow Analytics Ltd. All rights reserved. | ||
// | ||
// This program is licensed to you under the Apache License Version 2.0, | ||
// and you may not use this file except in compliance with the Apache License Version 2.0. | ||
// You may obtain a copy of the Apache License Version 2.0 at http://www.apache.org/licenses/LICENSE-2.0. | ||
// | ||
// Unless required by applicable law or agreed to in writing, | ||
// software distributed under the Apache License Version 2.0 is distributed on an | ||
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the Apache License Version 2.0 for the specific language governing permissions and limitations there under. | ||
// | ||
package main | ||
|
||
import ( | ||
"github.com/stretchr/testify/assert" | ||
"os" | ||
"testing" | ||
) | ||
|
||
func TestAwsEnvCredentials(t *testing.T) { | ||
assert := assert.New(t) | ||
|
||
str, err := awsEnvCredentials() | ||
assert.NotNil(err) | ||
assert.NotNil(str) | ||
assert.Equal("EnvAccessKeyNotFound: AWS_ACCESS_KEY_ID or AWS_ACCESS_KEY not found in environment", err.Error()) | ||
assert.Equal("CREDENTIALS 'aws_access_key_id=;aws_secret_access_key='", str) | ||
|
||
os.Setenv("AWS_ACCESS_KEY_ID", "some-aws-key") | ||
os.Setenv("AWS_SECRET_ACCESS_KEY", "some-aws-secret") | ||
|
||
str, err = awsEnvCredentials() | ||
assert.NotNil(str) | ||
assert.Nil(err) | ||
assert.Equal("CREDENTIALS 'aws_access_key_id=some-aws-key;aws_secret_access_key=some-aws-secret'", str) | ||
} | ||
|
||
func TestAwsProfileCredentials(t *testing.T) { | ||
assert := assert.New(t) | ||
|
||
str, err := awsProfileCredentials("fake-profile") | ||
assert.NotNil(err) | ||
assert.NotNil(str) | ||
assert.Equal("CREDENTIALS 'aws_access_key_id=;aws_secret_access_key='", str) | ||
|
||
str, err = awsProfileCredentials("default") | ||
assert.NotNil(str) | ||
assert.Nil(err) | ||
assert.Equal("CREDENTIALS 'aws_access_key_id=some-aws-key;aws_secret_access_key=some-aws-secret'", str) | ||
} | ||
|
||
func TestAwsChainCredentials(t *testing.T) { | ||
assert := assert.New(t) | ||
|
||
os.Setenv("AWS_ACCESS_KEY_ID", "some-aws-key") | ||
os.Setenv("AWS_SECRET_ACCESS_KEY", "some-aws-secret") | ||
|
||
str, err := awsChainCredentials("fake-profile") | ||
assert.NotNil(str) | ||
assert.Nil(err) | ||
assert.Equal("CREDENTIALS 'aws_access_key_id=some-aws-key;aws_secret_access_key=some-aws-secret'", str) | ||
|
||
str, err = awsChainCredentials("default") | ||
assert.NotNil(str) | ||
assert.Nil(err) | ||
assert.Equal("CREDENTIALS 'aws_access_key_id=some-aws-key;aws_secret_access_key=some-aws-secret'", str) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
// | ||
// Copyright (c) 2015-2016 Snowplow Analytics Ltd. All rights reserved. | ||
// | ||
// This program is licensed to you under the Apache License Version 2.0, | ||
// and you may not use this file except in compliance with the Apache License Version 2.0. | ||
// You may obtain a copy of the Apache License Version 2.0 at http://www.apache.org/licenses/LICENSE-2.0. | ||
// | ||
// Unless required by applicable law or agreed to in writing, | ||
// software distributed under the Apache License Version 2.0 is distributed on an | ||
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the Apache License Version 2.0 for the specific language governing permissions and limitations there under. | ||
// | ||
package main | ||
|
||
import ( | ||
"github.com/stretchr/testify/assert" | ||
"testing" | ||
) | ||
|
||
func TestPutGetDelStringValueFromConsul_Failure(t *testing.T) { | ||
assert := assert.New(t) | ||
|
||
err := PutStringValueToConsul("localhost", "somekey", "somevalue") | ||
assert.NotNil(err) | ||
|
||
str, err := GetStringValueFromConsul("localhost", "somekey") | ||
assert.Equal("", str) | ||
assert.NotNil(err) | ||
|
||
err = DeleteValueFromConsul("localhost", "somekey") | ||
assert.NotNil(err) | ||
} | ||
|
||
func TestPutGetDelStringValueFromConsul_Success(t *testing.T) { | ||
assert := assert.New(t) | ||
|
||
err := PutStringValueToConsul("localhost:8500", "somekey", "somevalue") | ||
assert.Nil(err) | ||
|
||
str, err := GetStringValueFromConsul("localhost:8500", "somekey") | ||
assert.Nil(err) | ||
assert.NotNil(str) | ||
assert.Equal("somevalue", str) | ||
|
||
err = DeleteValueFromConsul("localhost:8500", "somekey") | ||
assert.Nil(err) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
// | ||
// Copyright (c) 2015-2016 Snowplow Analytics Ltd. All rights reserved. | ||
// | ||
// This program is licensed to you under the Apache License Version 2.0, | ||
// and you may not use this file except in compliance with the Apache License Version 2.0. | ||
// You may obtain a copy of the Apache License Version 2.0 at http://www.apache.org/licenses/LICENSE-2.0. | ||
// | ||
// Unless required by applicable law or agreed to in writing, | ||
// software distributed under the Apache License Version 2.0 is distributed on an | ||
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the Apache License Version 2.0 for the specific language governing permissions and limitations there under. | ||
// | ||
package main | ||
|
||
import ( | ||
"github.com/stretchr/testify/assert" | ||
"testing" | ||
) | ||
|
||
func TestLoadLocalFile(t *testing.T) { | ||
assert := assert.New(t) | ||
|
||
bytes, err := loadLocalFile("/this/path/does/not/exist") | ||
assert.Nil(bytes) | ||
assert.NotNil(err) | ||
assert.Equal("open /this/path/does/not/exist: no such file or directory", err.Error()) | ||
|
||
bytes, err = loadLocalFile("../VERSION") | ||
assert.NotNil(bytes) | ||
assert.Nil(err) | ||
assert.Equal(CLI_VERSION, string(bytes)) | ||
} |
Oops, something went wrong.