Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
K
k3s
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jacklull
k3s
Commits
be7c0bdc
Commit
be7c0bdc
authored
Aug 08, 2017
by
Zeqing Zhang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add testcase for aws china region
parent
6a1b3132
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
54 additions
and
0 deletions
+54
-0
aws_credentials_test.go
pkg/credentialprovider/aws/aws_credentials_test.go
+54
-0
No files found.
pkg/credentialprovider/aws/aws_credentials_test.go
View file @
be7c0bdc
...
...
@@ -59,6 +59,7 @@ func (p *testTokenGetter) GetAuthorizationToken(input *ecr.GetAuthorizationToken
func
TestEcrProvide
(
t
*
testing
.
T
)
{
registry
:=
"123456789012.dkr.ecr.lala-land-1.amazonaws.com"
otherRegistries
:=
[]
string
{
"123456789012.dkr.ecr.cn-foo-1.amazonaws.com.cn"
,
"private.registry.com"
,
"gcr.io"
,
}
...
...
@@ -107,3 +108,56 @@ func TestEcrProvide(t *testing.T) {
}
}
}
func
TestChinaEcrProvide
(
t
*
testing
.
T
)
{
registry
:=
"123456789012.dkr.ecr.cn-foo-1.amazonaws.com.cn"
otherRegistries
:=
[]
string
{
"123456789012.dkr.ecr.lala-land-1.amazonaws.com"
,
"private.registry.com"
,
"gcr.io"
,
}
image
:=
"foo/bar"
provider
:=
newEcrProvider
(
"cn-foo-1"
,
&
testTokenGetter
{
user
:
user
,
password
:
password
,
endpoint
:
registry
,
})
keyring
:=
&
credentialprovider
.
BasicDockerKeyring
{}
keyring
.
Add
(
provider
.
Provide
())
// Verify that we get the expected username/password combo for
// an ECR image name.
fullImage
:=
path
.
Join
(
registry
,
image
)
creds
,
ok
:=
keyring
.
Lookup
(
fullImage
)
if
!
ok
{
t
.
Errorf
(
"Didn't find expected URL: %s"
,
fullImage
)
return
}
if
len
(
creds
)
>
1
{
t
.
Errorf
(
"Got more hits than expected: %s"
,
creds
)
}
val
:=
creds
[
0
]
if
user
!=
val
.
Username
{
t
.
Errorf
(
"Unexpected username value, want: _token, got: %s"
,
val
.
Username
)
}
if
password
!=
val
.
Password
{
t
.
Errorf
(
"Unexpected password value, want: %s, got: %s"
,
password
,
val
.
Password
)
}
if
email
!=
val
.
Email
{
t
.
Errorf
(
"Unexpected email value, want: %s, got: %s"
,
email
,
val
.
Email
)
}
// Verify that we get an error for other images.
for
_
,
otherRegistry
:=
range
otherRegistries
{
fullImage
=
path
.
Join
(
otherRegistry
,
image
)
creds
,
ok
=
keyring
.
Lookup
(
fullImage
)
if
ok
{
t
.
Errorf
(
"Unexpectedly found image: %s"
,
fullImage
)
return
}
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment