Skip to content

Commit

Permalink
Merge pull request #8 from fireflycons/dev
Browse files Browse the repository at this point in the history
Fixes #7
  • Loading branch information
fireflycons authored Mar 11, 2019
2 parents 76e62ec + 6e0fa46 commit a0404af
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 4 deletions.
2 changes: 1 addition & 1 deletion PSCloudFormation/PSCloudFormation.psd1
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
RootModule = 'PSCloudFormation.psm1'

# Version number of this module.
ModuleVersion = '0.3.0'
ModuleVersion = '0.3.1'

# Supported PSEditions
# CompatiblePSEditions = @()
Expand Down
3 changes: 2 additions & 1 deletion PSCloudFormation/Private/Get-CloudFormationBucket.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ function Get-CloudFormationBucket
US = 'us-east-1'

}
$bucketName = "cf-templates-pscloudformation-$(Get-CurrentRegion -CredentialArguments $CredentialArguments)"

$bucketName = "cf-templates-pscloudformation-$(Get-CurrentRegion -CredentialArguments $CredentialArguments)-$((Get-STSCallerIdentity).Account)"

try
{
Expand Down
19 changes: 17 additions & 2 deletions tests/PSCloudFormation.Private.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -339,9 +339,16 @@ InModuleScope 'PSCloudFormation' {
It 'Should return bucket details if bucket exists' {

$region = 'us-east-1'
$expectedBucketName = "cf-templates-pscloudformation-$($region)"
$expectedBucketName = "cf-templates-pscloudformation-$($region)-000000000000"
$expectedBucketUrl = [uri]"https://s3.$($region).amazonaws.com/$expectedBucketName"

Mock -CommandName Get-STSCallerIdentity -MockWith {

New-Object PSObject -Property @{
Account = '000000000000'
}
}

Mock -CommandName Get-S3BucketLocation -MockWith {

New-Object PSObject -Property @{
Expand All @@ -350,17 +357,25 @@ InModuleScope 'PSCloudFormation' {
}

$result = Get-CloudFormationBucket -CredentialArguments @{ Region = $region }
Assert-MockCalled -CommandName Get-STSCallerIdentity -Times 1
$result.BucketName | Should Be $expectedBucketName
$result.BucketUrl | Should Be $expectedBucketUrl
}

It 'Should create bucket if bucket does not exist' {

$region = 'us-east-1'
$expectedBucketName = "cf-templates-pscloudformation-$($region)"
$expectedBucketName = "cf-templates-pscloudformation-$($region)-000000000000"
$expectedBucketUrl = [uri]"https://s3.$($region).amazonaws.com/$expectedBucketName"
$script:callCount = 0

Mock -CommandName Get-STSCallerIdentity -MockWith {

New-Object PSObject -Property @{
Account = '000000000000'
}
}

Mock -CommandName Get-S3BucketLocation -MockWith {

if ($script:callCount++ -eq 0)
Expand Down

0 comments on commit a0404af

Please sign in to comment.