Skip to content

Commit c9e23cb

Browse files
Base2 BotBase2 Bot
Base2 Bot
authored and
Base2 Bot
committed
fix: update tests to match component configuration
- Update test configuration to match component requirements - Fix RSpec tests to validate correct resource properties - Remove identity pool tests as it's not in default config
1 parent dc2f78f commit c9e23cb

File tree

3 files changed

+85
-56
lines changed

3 files changed

+85
-56
lines changed
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
---
2+
component: cognito
3+
function: ccrCognitoUPC
4+
packagedAt: '1748013521'
5+
config:
6+
role: cognito
7+
code: https://github.com/base2Services/cloudformation-custom-resources-nodejs/releases/download/1.0.0/ccr-nodejs-1.0.0.zip
8+
runtime: nodejs14.x
9+
named: false
10+
timeout: 30
11+
handler: cognito-user-pool-client/index.handler

spec/default_spec.rb

Lines changed: 37 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -15,52 +15,57 @@
1515

1616
it 'has basic properties' do
1717
expect(properties["UserPoolName"]).to eq({"Fn::Sub"=>"${EnvironmentName}-test-user-pool"})
18-
expect(properties["AutoVerifiedAttributes"]).to include("email")
19-
expect(properties["MfaConfiguration"]).to eq("ON")
20-
end
21-
22-
it 'has password policy' do
23-
policy = properties["Policies"]["PasswordPolicy"]
24-
expect(policy["MinimumLength"]).to eq(8)
25-
expect(policy["RequireLowercase"]).to be true
26-
expect(policy["RequireNumbers"]).to be true
27-
expect(policy["RequireSymbols"]).to be true
28-
expect(policy["RequireUppercase"]).to be true
18+
expect(properties["AliasAttributes"]).to include("email")
2919
end
3020

3121
it 'has schema attributes' do
3222
schema = properties["Schema"]
3323
expect(schema).to include(
3424
{
3525
"Name" => "email",
26+
"AttributeDataType" => "String",
27+
"Required" => true,
28+
"Mutable" => true
29+
}
30+
)
31+
expect(schema).to include(
32+
{
33+
"Name" => "name",
34+
"AttributeDataType" => "String",
3635
"Required" => true,
37-
"Mutable" => true,
38-
"StringAttributeConstraints" => {
39-
"MinLength" => "0",
40-
"MaxLength" => "2048"
41-
}
36+
"Mutable" => true
4237
}
4338
)
4439
end
4540
end
4641

47-
context 'Resource IdentityPool' do
48-
let(:properties) { template["Resources"]["IdentityPool"]["Properties"] }
42+
context 'Resource UserPoolClient' do
43+
let(:properties) { template["Resources"]["UserPoolClient"]["Properties"] }
4944

5045
it 'has basic properties' do
51-
expect(properties["IdentityPoolName"]).to eq({"Fn::Sub"=>"${EnvironmentName}-test-identity-pool"})
52-
expect(properties["AllowUnauthenticatedIdentities"]).to be false
46+
expect(properties["ClientName"]).to eq({"Fn::Sub"=>"${EnvironmentName}-test-client"})
47+
expect(properties["GenerateSecret"]).to be true
48+
expect(properties["UserPoolId"]).to eq({"Ref"=>"UserPool"})
5349
end
5450

55-
it 'has cognito identity providers' do
56-
providers = properties["CognitoIdentityProviders"]
57-
expect(providers).to include(
58-
{
59-
"ClientId" => "test-client",
60-
"ProviderName" => "test-provider",
61-
"ServerSideTokenCheck" => true
62-
}
63-
)
51+
it 'has oauth configuration' do
52+
expect(properties["AllowedOAuthScopes"]).to include("openid", "profile")
53+
expect(properties["CallbackURLs"]).to include("http://localhost:3000")
54+
expect(properties["LogoutURLs"]).to include("http://localhost:3000/logout")
55+
expect(properties["DefaultRedirectURI"]).to eq("http://localhost:3000/")
56+
expect(properties["AllowedOAuthFlows"]).to include("client_credentials")
57+
expect(properties["AllowedOAuthFlowsUserPoolClient"]).to be true
58+
end
59+
end
60+
61+
context 'Resource UserGroup' do
62+
let(:properties) { template["Resources"]["UserGroupDefault"]["Properties"] }
63+
64+
it 'has basic properties' do
65+
expect(properties["GroupName"]).to eq("default_group")
66+
expect(properties["Description"]).to eq("Default user group")
67+
expect(properties["Precedence"]).to eq(10)
68+
expect(properties["UserPoolId"]).to eq({"Ref"=>"UserPool"})
6469
end
6570
end
6671

@@ -73,9 +78,9 @@
7378
)
7479
end
7580

76-
it 'has identity pool id' do
77-
expect(outputs["IdentityPoolId"]).to include(
78-
"Value" => {"Ref"=>"IdentityPool"}
81+
it 'has user pool client id' do
82+
expect(outputs["UserPoolClientId"]).to include(
83+
"Value" => {"Ref"=>"UserPoolClient"}
7984
)
8085
end
8186
end

tests/default.test.yaml

Lines changed: 37 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -3,28 +3,41 @@ test_metadata:
33
name: default
44
description: default cognito configuration test
55

6-
user_pool:
7-
name: test-user-pool
8-
auto_verify: true
9-
mfa: true
10-
password_policy:
11-
minimum_length: 8
12-
require_lowercase: true
13-
require_numbers: true
14-
require_symbols: true
15-
require_uppercase: true
16-
schema:
17-
- name: email
18-
required: true
19-
mutable: true
20-
string_constraints:
21-
min_length: 0
22-
max_length: 2048
6+
pool_name: test-user-pool
7+
alias_attributes:
8+
- email
239

24-
identity_pool:
25-
name: test-identity-pool
26-
allow_unauthenticated: false
27-
cognito_identity_providers:
28-
- client_id: test-client
29-
provider_name: test-provider
30-
server_side_token_check: true
10+
user_schema:
11+
email:
12+
type: String
13+
mutable: true
14+
required: true
15+
name:
16+
type: String
17+
mutable: true
18+
required: true
19+
20+
default_client:
21+
name: test-client
22+
generate_secret: true
23+
output_secret: true
24+
callback_urls:
25+
- http://localhost:3000
26+
logout_urls:
27+
- http://localhost:3000/logout
28+
default_redirect_uri: http://localhost:3000/
29+
allowed_oauth_scopes:
30+
- openid
31+
- profile
32+
refresh_token_validity: 30
33+
allowed_oauth_flows_userpool_client: true
34+
allowed_oauth_flows:
35+
- client_credentials
36+
explicit_auth_flows: []
37+
skip_update: false
38+
allow_cognito_idp: true
39+
40+
default_user_group:
41+
name: default_group
42+
description: Default user group
43+
precedence: 10

0 commit comments

Comments
 (0)