test(target): validate ipv6 address for tcp targets (#5076)
This commit is contained in:
1 parent
a77d04edbb
commit
bd03c99f89
1 file changed
+61
-5
@@ -71,12 +71,12 @@ func TestRepository_CreateTarget(t *testing.T) {
|
||||
wantErr: false,
|
||||
},
|
||||
{
|
||||
name: "with-address",
|
||||
name: "with-ipv4-address",
|
||||
args: args{
|
||||
target: func() target.Target {
|
||||
target, err := target.New(ctx, tcp.Subtype, proj.PublicId,
|
||||
target.WithName("with-address"),
|
||||
target.WithDescription("with-address"),
|
||||
target.WithName("with-ipv4-address"),
|
||||
target.WithDescription("with-ipv4-address"),
|
||||
target.WithDefaultPort(80),
|
||||
target.WithAddress("8.8.8.8"))
|
||||
require.NoError(t, err)
|
||||
@@ -85,6 +85,36 @@ func TestRepository_CreateTarget(t *testing.T) {
|
||||
},
|
||||
wantErr: false,
|
||||
},
|
||||
{
|
||||
name: "with-abbreviated-ipv6-address",
|
||||
args: args{
|
||||
target: func() target.Target {
|
||||
target, err := target.New(ctx, tcp.Subtype, proj.PublicId,
|
||||
target.WithName("with-abbreviated-ipv6-address"),
|
||||
target.WithDescription("with-abbreviated-ipv6-address"),
|
||||
target.WithDefaultPort(80),
|
||||
target.WithAddress("2001:4860:4860::8888"))
|
||||
require.NoError(t, err)
|
||||
return target
|
||||
}(),
|
||||
},
|
||||
wantErr: false,
|
||||
},
|
||||
{
|
||||
name: "with-ipv6-address",
|
||||
args: args{
|
||||
target: func() target.Target {
|
||||
target, err := target.New(ctx, tcp.Subtype, proj.PublicId,
|
||||
target.WithName("with-ipv6-address"),
|
||||
target.WithDescription("with-ipv6-address"),
|
||||
target.WithDefaultPort(80),
|
||||
target.WithAddress("2001:4860:4860:0:0:0:0:8888"))
|
||||
require.NoError(t, err)
|
||||
return target
|
||||
}(),
|
||||
},
|
||||
wantErr: false,
|
||||
},
|
||||
{
|
||||
name: "with-address-whitespace",
|
||||
args: args{
|
||||
@@ -360,9 +390,9 @@ func TestRepository_UpdateTcpTarget(t *testing.T) {
|
||||
},
|
||||
|
||||
{
|
||||
name: "valid-address",
|
||||
name: "valid-ipv4-address",
|
||||
args: args{
|
||||
name: "valid-address" + id,
|
||||
name: "valid-ipv4-address" + id,
|
||||
fieldMaskPaths: []string{"Name", "Address"},
|
||||
ProjectId: proj.PublicId,
|
||||
address: "8.8.8.8",
|
||||
@@ -372,6 +402,32 @@ func TestRepository_UpdateTcpTarget(t *testing.T) {
|
||||
wantRowsUpdate: 1,
|
||||
wantHostSources: false,
|
||||
},
|
||||
{
|
||||
name: "valid-abbreviated-ipv6-address",
|
||||
args: args{
|
||||
name: "valid-abbreviated-ipv6-address" + id,
|
||||
fieldMaskPaths: []string{"Name", "Address"},
|
||||
ProjectId: proj.PublicId,
|
||||
address: "2001:4860:4860::8888",
|
||||
},
|
||||
newProjectId: proj.PublicId,
|
||||
wantErr: false,
|
||||
wantRowsUpdate: 1,
|
||||
wantHostSources: false,
|
||||
},
|
||||
{
|
||||
name: "valid-ipv6-address",
|
||||
args: args{
|
||||
name: "valid-ipv6-address" + id,
|
||||
fieldMaskPaths: []string{"Name", "Address"},
|
||||
ProjectId: proj.PublicId,
|
||||
address: "2001:4860:4860:0:0:0:0:8888",
|
||||
},
|
||||
newProjectId: proj.PublicId,
|
||||
wantErr: false,
|
||||
wantRowsUpdate: 1,
|
||||
wantHostSources: false,
|
||||
},
|
||||
{
|
||||
name: "null-address",
|
||||
args: args{
|
||||
|
||||
Reference in new issue
Block a user