Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(dependencies): Autobump korkVersion #1776

Merged
merged 4 commits into from
Mar 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions gate-api-tck/gate-api-tck.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ apply from: "${project.rootDir}/gradle/kotlin-test.gradle"

dependencies {
implementation(project(":gate-web"))
implementation("io.spinnaker.kork:kork-jedis-test")
implementation("org.springframework.session:spring-session-data-redis")

api("org.springframework.boot:spring-boot-starter-test")
api("dev.minutest:minutest")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,20 @@ import com.netflix.spinnaker.gate.Main
import dev.minutest.TestContextBuilder
import dev.minutest.TestDescriptor
import org.springframework.boot.test.context.SpringBootTest
import org.springframework.boot.test.context.TestConfiguration
import org.springframework.test.context.TestContextManager
import org.springframework.test.context.TestPropertySource
import org.springframework.context.annotation.Bean
import com.netflix.spinnaker.kork.jedis.EmbeddedRedis
import org.springframework.context.annotation.Primary
import org.springframework.data.redis.connection.RedisStandaloneConfiguration
import org.springframework.data.redis.connection.jedis.JedisConnectionFactory
import org.springframework.session.data.redis.config.annotation.SpringSessionRedisConnectionFactory
import org.springframework.test.context.ContextConfiguration
import redis.clients.jedis.JedisPool

@SpringBootTest(classes = [Main::class])
@ContextConfiguration(classes = [GateFixtureConfiguration::class])
@TestPropertySource(properties = ["spring.config.location=classpath:gate-test-app.yml"])
abstract class GateFixture

Expand All @@ -39,3 +49,24 @@ inline fun <PF, reified F> TestContextBuilder<PF, F>.gateFixture(
}
}
}

@TestConfiguration
internal open class GateFixtureConfiguration {
@Bean(destroyMethod = "destroy")
fun embeddedRedis(): EmbeddedRedis {
return EmbeddedRedis.embed().also { redis -> redis.jedis.connect() }.also { redis -> redis.jedis.ping() }
}

@Bean
@Primary
@SpringSessionRedisConnectionFactory
fun jedisConnectionFactory(embeddedRedis: EmbeddedRedis): JedisConnectionFactory {
return JedisConnectionFactory(RedisStandaloneConfiguration(embeddedRedis.host, embeddedRedis.port))
}

@Bean
@Primary
fun jedis(embeddedRedis: EmbeddedRedis): JedisPool {
return embeddedRedis.getPool();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,20 @@ package com.netflix.spinnaker.gate.config

import com.netflix.spinnaker.fiat.shared.FiatPermissionEvaluator
import com.netflix.spinnaker.fiat.shared.FiatStatus
import org.springframework.context.ApplicationContext
import org.springframework.security.config.annotation.ObjectPostProcessor
import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder
import org.springframework.security.config.annotation.web.builders.HttpSecurity
import org.springframework.security.web.util.matcher.AnyRequestMatcher
import org.springframework.context.support.GenericApplicationContext
import spock.lang.Specification

import java.util.stream.Collectors

class AuthConfigTest extends Specification {

private GenericApplicationContext context = new GenericApplicationContext()

@SuppressWarnings("GroovyAccessibility")
def "test webhooks are unauthenticated by default"() {
given:
Expand All @@ -44,7 +49,7 @@ class AuthConfigTest extends Specification {
def httpSecurity = new HttpSecurity(
Mock(ObjectPostProcessor),
Mock(AuthenticationManagerBuilder),
[:]
getSharedObjects()
)

when:
Expand Down Expand Up @@ -79,7 +84,7 @@ class AuthConfigTest extends Specification {
def httpSecurity = new HttpSecurity(
Mock(ObjectPostProcessor),
Mock(AuthenticationManagerBuilder),
[:]
getSharedObjects()
)

when:
Expand All @@ -95,4 +100,11 @@ class AuthConfigTest extends Specification {
.collect(Collectors.toList())
filtered.size() == 1
}

private HashMap<Class<?>, Object> getSharedObjects(){
HashMap map = new HashMap<Class<?>, Object>()
context.refresh()
map.put(ApplicationContext.class, context)
return map;
}
}
2 changes: 2 additions & 0 deletions gate-plugins-test/gate-plugins-test.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ dependencies {

testImplementation("io.spinnaker.kork:kork-plugins")
testImplementation("io.spinnaker.kork:kork-plugins-tck")
testImplementation("io.spinnaker.kork:kork-jedis-test")
testImplementation("org.springframework.session:spring-session-data-redis")

testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine")
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,13 @@ import org.springframework.boot.test.context.TestConfiguration
import org.springframework.test.context.ContextConfiguration
import org.springframework.test.context.TestPropertySource
import org.springframework.test.web.servlet.MockMvc
import org.springframework.context.annotation.Bean
import com.netflix.spinnaker.kork.jedis.EmbeddedRedis
import org.springframework.context.annotation.Primary
import org.springframework.data.redis.connection.RedisStandaloneConfiguration
import org.springframework.data.redis.connection.jedis.JedisConnectionFactory
import org.springframework.session.data.redis.config.annotation.SpringSessionRedisConnectionFactory
import redis.clients.jedis.JedisPool

class GatePluginsFixture : PluginsTckFixture, GateTestService() {

Expand Down Expand Up @@ -75,4 +82,22 @@ class GatePluginsFixture : PluginsTckFixture, GateTestService() {
abstract class GateTestService

@TestConfiguration
internal open class PluginTestConfiguration
internal open class PluginTestConfiguration {
@Bean(destroyMethod = "destroy")
fun embeddedRedis(): EmbeddedRedis {
return EmbeddedRedis.embed().also { redis -> redis.jedis.connect() }.also { redis -> redis.jedis.ping() }
}

@Bean
@Primary
@SpringSessionRedisConnectionFactory
fun jedisConnectionFactory(embeddedRedis: EmbeddedRedis): JedisConnectionFactory {
return JedisConnectionFactory(RedisStandaloneConfiguration(embeddedRedis.host, embeddedRedis.port))
}

@Bean
@Primary
fun jedis(embeddedRedis: EmbeddedRedis): JedisPool {
return embeddedRedis.getPool();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ import static retrofit.Endpoints.newFixedEndpoint
class GateConfig extends RedisHttpSessionConfiguration {

private ServiceClientProvider serviceClientProvider
private ConfigureRedisAction configureRedisAction

@Value('${server.session.timeout-in-seconds:3600}')
void setSessionTimeout(int maxInactiveIntervalInSeconds) {
Expand All @@ -90,6 +91,10 @@ class GateConfig extends RedisHttpSessionConfiguration {
this.serviceClientProvider = serviceClientProvider
}

void setConfigureRedisAction(ConfigureRedisAction configureRedisAction){
this.configureRedisAction = configureRedisAction;
}

@Autowired
GateConfig(@Value('${server.session.timeout-in-seconds:3600}') int maxInactiveIntervalInSeconds) {
super.setMaxInactiveIntervalInSeconds(maxInactiveIntervalInSeconds)
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
enablePublishing=false
fiatVersion=1.43.0
includeProviders=basic,iap,ldap,oauth2,saml,x509
korkVersion=7.219.0
korkVersion=7.220.0
kotlinVersion=1.5.32
org.gradle.parallel=true
spinnakerGradleVersion=8.32.1
Expand Down