Remove ent checks from oss test

This commit is contained in:
freddygv 2021-09-16 14:53:28 -06:00
parent bf7a1358d6
commit fc8fc060a7
1 changed files with 21 additions and 94 deletions

View File

@ -18,39 +18,11 @@ func TestAuthorizeIntentionTarget(t *testing.T) {
match bool match bool
}{ }{
// Source match type // Source match type
{
name: "matching source target and namespace, but not partition",
target: "db",
targetNS: structs.IntentionDefaultNamespace,
targetAP: "foo",
ixn: &structs.Intention{
SourceName: "db",
SourceNS: structs.IntentionDefaultNamespace,
SourcePartition: "not-foo",
},
matchType: structs.IntentionMatchSource,
auth: false,
match: false,
},
{
name: "match exact source, not matching namespace",
target: "web",
targetNS: structs.IntentionDefaultNamespace,
ixn: &structs.Intention{
SourceName: "db",
SourceNS: "different",
},
matchType: structs.IntentionMatchSource,
auth: false,
match: false,
},
{ {
name: "match exact source, not matching name", name: "match exact source, not matching name",
target: "web", target: "web",
targetNS: structs.IntentionDefaultNamespace,
ixn: &structs.Intention{ ixn: &structs.Intention{
SourceName: "db", SourceName: "db",
SourceNS: structs.IntentionDefaultNamespace,
}, },
matchType: structs.IntentionMatchSource, matchType: structs.IntentionMatchSource,
auth: false, auth: false,
@ -59,10 +31,8 @@ func TestAuthorizeIntentionTarget(t *testing.T) {
{ {
name: "match exact source, allow", name: "match exact source, allow",
target: "web", target: "web",
targetNS: structs.IntentionDefaultNamespace,
ixn: &structs.Intention{ ixn: &structs.Intention{
SourceName: "web", SourceName: "web",
SourceNS: structs.IntentionDefaultNamespace,
Action: structs.IntentionActionAllow, Action: structs.IntentionActionAllow,
}, },
matchType: structs.IntentionMatchSource, matchType: structs.IntentionMatchSource,
@ -72,18 +42,15 @@ func TestAuthorizeIntentionTarget(t *testing.T) {
{ {
name: "match exact source, deny", name: "match exact source, deny",
target: "web", target: "web",
targetNS: structs.IntentionDefaultNamespace,
ixn: &structs.Intention{ ixn: &structs.Intention{
SourceName: "web", SourceName: "web",
SourceNS: structs.IntentionDefaultNamespace,
Action: structs.IntentionActionDeny,
}, },
matchType: structs.IntentionMatchSource, matchType: structs.IntentionMatchSource,
auth: false, auth: false,
match: true, match: true,
}, },
{ {
name: "match exact sourceNS for wildcard service, deny", name: "match wildcard service, deny",
target: "web", target: "web",
targetNS: structs.IntentionDefaultNamespace, targetNS: structs.IntentionDefaultNamespace,
ixn: &structs.Intention{ ixn: &structs.Intention{
@ -96,12 +63,10 @@ func TestAuthorizeIntentionTarget(t *testing.T) {
match: true, match: true,
}, },
{ {
name: "match exact sourceNS for wildcard service, allow", name: "match wildcard service, allow",
target: "web", target: "web",
targetNS: structs.IntentionDefaultNamespace,
ixn: &structs.Intention{ ixn: &structs.Intention{
SourceName: structs.WildcardSpecifier, SourceName: structs.WildcardSpecifier,
SourceNS: structs.IntentionDefaultNamespace,
Action: structs.IntentionActionAllow, Action: structs.IntentionActionAllow,
}, },
matchType: structs.IntentionMatchSource, matchType: structs.IntentionMatchSource,
@ -110,39 +75,11 @@ func TestAuthorizeIntentionTarget(t *testing.T) {
}, },
// Destination match type // Destination match type
{
name: "matching destination target and namespace, but not partition",
target: "db",
targetNS: structs.IntentionDefaultNamespace,
targetAP: "foo",
ixn: &structs.Intention{
SourceName: "db",
SourceNS: structs.IntentionDefaultNamespace,
SourcePartition: "not-foo",
},
matchType: structs.IntentionMatchDestination,
auth: false,
match: false,
},
{
name: "match exact destination, not matching namespace",
target: "web",
targetNS: structs.IntentionDefaultNamespace,
ixn: &structs.Intention{
DestinationName: "db",
DestinationNS: "different",
},
matchType: structs.IntentionMatchDestination,
auth: false,
match: false,
},
{ {
name: "match exact destination, not matching name", name: "match exact destination, not matching name",
target: "web", target: "web",
targetNS: structs.IntentionDefaultNamespace,
ixn: &structs.Intention{ ixn: &structs.Intention{
DestinationName: "db", DestinationName: "db",
DestinationNS: structs.IntentionDefaultNamespace,
}, },
matchType: structs.IntentionMatchDestination, matchType: structs.IntentionMatchDestination,
auth: false, auth: false,
@ -151,10 +88,8 @@ func TestAuthorizeIntentionTarget(t *testing.T) {
{ {
name: "match exact destination, allow", name: "match exact destination, allow",
target: "web", target: "web",
targetNS: structs.IntentionDefaultNamespace,
ixn: &structs.Intention{ ixn: &structs.Intention{
DestinationName: "web", DestinationName: "web",
DestinationNS: structs.IntentionDefaultNamespace,
Action: structs.IntentionActionAllow, Action: structs.IntentionActionAllow,
}, },
matchType: structs.IntentionMatchDestination, matchType: structs.IntentionMatchDestination,
@ -164,10 +99,8 @@ func TestAuthorizeIntentionTarget(t *testing.T) {
{ {
name: "match exact destination, deny", name: "match exact destination, deny",
target: "web", target: "web",
targetNS: structs.IntentionDefaultNamespace,
ixn: &structs.Intention{ ixn: &structs.Intention{
DestinationName: "web", DestinationName: "web",
DestinationNS: structs.IntentionDefaultNamespace,
Action: structs.IntentionActionDeny, Action: structs.IntentionActionDeny,
}, },
matchType: structs.IntentionMatchDestination, matchType: structs.IntentionMatchDestination,
@ -175,12 +108,10 @@ func TestAuthorizeIntentionTarget(t *testing.T) {
match: true, match: true,
}, },
{ {
name: "match exact destinationNS for wildcard service, deny", name: "match wildcard service, deny",
target: "web", target: "web",
targetNS: structs.IntentionDefaultNamespace,
ixn: &structs.Intention{ ixn: &structs.Intention{
DestinationName: structs.WildcardSpecifier, DestinationName: structs.WildcardSpecifier,
DestinationNS: structs.IntentionDefaultNamespace,
Action: structs.IntentionActionDeny, Action: structs.IntentionActionDeny,
}, },
matchType: structs.IntentionMatchDestination, matchType: structs.IntentionMatchDestination,
@ -188,12 +119,10 @@ func TestAuthorizeIntentionTarget(t *testing.T) {
match: true, match: true,
}, },
{ {
name: "match exact destinationNS for wildcard service, allow", name: "match wildcard service, allow",
target: "web", target: "web",
targetNS: structs.IntentionDefaultNamespace,
ixn: &structs.Intention{ ixn: &structs.Intention{
DestinationName: structs.WildcardSpecifier, DestinationName: structs.WildcardSpecifier,
DestinationNS: structs.IntentionDefaultNamespace,
Action: structs.IntentionActionAllow, Action: structs.IntentionActionAllow,
}, },
matchType: structs.IntentionMatchDestination, matchType: structs.IntentionMatchDestination,
@ -203,10 +132,8 @@ func TestAuthorizeIntentionTarget(t *testing.T) {
{ {
name: "unknown match type", name: "unknown match type",
target: "web", target: "web",
targetNS: structs.IntentionDefaultNamespace,
ixn: &structs.Intention{ ixn: &structs.Intention{
DestinationName: structs.WildcardSpecifier, DestinationName: structs.WildcardSpecifier,
DestinationNS: structs.IntentionDefaultNamespace,
Action: structs.IntentionActionAllow, Action: structs.IntentionActionAllow,
}, },
matchType: structs.IntentionMatchType("unknown"), matchType: structs.IntentionMatchType("unknown"),