-
Notifications
You must be signed in to change notification settings - Fork 69
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(mark): removing mark of deleted resources, comments (#123)
- Loading branch information
Showing
4 changed files
with
106 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -30,6 +30,7 @@ import org.junit.jupiter.api.Assertions.* | |
import org.junit.jupiter.api.Test | ||
object AllowListExclusionPolicyTest { | ||
private val front50ApplicationCache: InMemoryCache<Application> = mock() | ||
|
||
@Test | ||
fun `should exclude based on composite key if not in Allow List`() { | ||
val exclusions = listOf( | ||
|
@@ -67,6 +68,7 @@ object AllowListExclusionPolicyTest { | |
filteredResources.first().resourceId shouldMatch equalTo("testapp-v001") | ||
} | ||
} | ||
|
||
@Test | ||
fun `should exclude if not Allow List`() { | ||
val exclusions = listOf( | ||
|
@@ -104,4 +106,50 @@ object AllowListExclusionPolicyTest { | |
filteredResources.first().resourceId shouldMatch equalTo("testapp-v001") | ||
} | ||
} | ||
|
||
@Test | ||
fun `should include if in one of the allow lists`() { | ||
val exclusions = listOf( | ||
Exclusion() | ||
.withType(ExclusionType.Allowlist.toString()) | ||
.withAttributes( | ||
listOf( | ||
Attribute() | ||
.withKey("swabbieResourceOwner") | ||
.withValue( | ||
listOf("[email protected]", "[email protected]") | ||
), | ||
Attribute() | ||
.withKey("name") | ||
.withValue( | ||
listOf("pattern:^grpc.*\$") | ||
) | ||
) | ||
) | ||
) | ||
whenever(front50ApplicationCache.get()) doReturn | ||
setOf( | ||
Application(name = "testapp", email = "[email protected]"), | ||
Application(name = "important", email = "[email protected]"), | ||
Application(name = "random", email = "[email protected]") | ||
) | ||
val resources = listOf( | ||
TestResource("testapp-v001") | ||
.withDetail("swabbieResourceOwner", "[email protected]"), | ||
TestResource("grpclab-v001") | ||
.withDetail("swabbieResourceOwner", "[email protected]"), | ||
TestResource("test-v001") | ||
.withDetail("swabbieResourceOwner", "[email protected]") | ||
) | ||
resources.filter { | ||
AllowListExclusionPolicy(front50ApplicationCache, mock()).apply(it, exclusions) == null | ||
}.let { filteredResources -> | ||
filteredResources.size shouldMatch equalTo(2) | ||
filteredResources.map { it.resourceId }.let { | ||
assertTrue( it.contains("grpclab-v001"), "Allow List by pattern") | ||
assertTrue( it.contains("testapp-v001"), "Allow List by owner") | ||
} | ||
filteredResources.first().resourceId shouldMatch equalTo("testapp-v001") | ||
} | ||
} | ||
} |