File tree 2 files changed +30
-0
lines changed
2 files changed +30
-0
lines changed Original file line number Diff line number Diff line change @@ -79,6 +79,10 @@ protected function createClient(array $config)
79
79
'endpoint ' => $ config ['endpoint ' ] ?? null ,
80
80
];
81
81
82
+ if (! empty ($ dynamoConfig ['endpoint ' ]) && preg_match ('#^https?://#i ' , $ dynamoConfig ['endpoint ' ]) === 0 ) {
83
+ $ dynamoConfig ['endpoint ' ] = "https:// " . $ dynamoConfig ['endpoint ' ];
84
+ }
85
+
82
86
if ($ key = $ config ['access_key ' ] ?? null ) {
83
87
$ config ['key ' ] = $ key ;
84
88
unset($ config ['access_key ' ]);
Original file line number Diff line number Diff line change @@ -96,4 +96,30 @@ public function it_can_forward_call_to_dynamodb_client()
96
96
'TableName ' => 'User '
97
97
]);
98
98
}
99
+
100
+ /** @test */
101
+ public function it_prepends_default_protocol_if_not_given ()
102
+ {
103
+ $ connection = new Connection (['endpoint ' => 'examples.com ' ]);
104
+ $ this ->assertEquals ($ connection ->getClient ()->getEndpoint ()->getScheme (), 'https ' );
105
+ $ this ->assertEquals ($ connection ->getClient ()->getEndpoint ()->getHost (), 'examples.com ' );
106
+ $ this ->assertEquals ($ this ->connection ->getClient ()->getEndpoint ()->getScheme (), 'https ' );
107
+ $ this ->assertEquals ($ this ->connection ->getClient ()->getEndpoint ()->getHost (), 'dynamodb.us-east-1.amazonaws.com ' );
108
+ }
109
+
110
+ /** @test */
111
+ public function it_dont_prepends_default_protocol_if_http_given ()
112
+ {
113
+ $ connection = new Connection (['endpoint ' => 'http://examples.com ' ]);
114
+ $ this ->assertEquals ($ connection ->getClient ()->getEndpoint ()->getScheme (), 'http ' );
115
+ $ this ->assertEquals ($ connection ->getClient ()->getEndpoint ()->getHost (), 'examples.com ' );
116
+ }
117
+
118
+ /** @test */
119
+ public function it_dont_prepends_default_protocol_if_https_given ()
120
+ {
121
+ $ connection = new Connection (['endpoint ' => 'https://examples.com ' ]);
122
+ $ this ->assertEquals ($ connection ->getClient ()->getEndpoint ()->getScheme (), 'https ' );
123
+ $ this ->assertEquals ($ connection ->getClient ()->getEndpoint ()->getHost (), 'examples.com ' );
124
+ }
99
125
}
You can’t perform that action at this time.
0 commit comments