|
|
|
@ -1,5 +1,5 @@ |
|
|
|
/* |
|
|
|
/* |
|
|
|
* Copyright 2002-2024 the original author or authors. |
|
|
|
* Copyright 2002-2025 the original author or authors. |
|
|
|
* |
|
|
|
* |
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License"); |
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License"); |
|
|
|
* you may not use this file except in compliance with the License. |
|
|
|
* you may not use this file except in compliance with the License. |
|
|
|
@ -58,7 +58,7 @@ public class AuthorizationProxyConfigurationTests { |
|
|
|
@Test |
|
|
|
@Test |
|
|
|
public void proxyWhenNotPreAuthorizedThenDenies() { |
|
|
|
public void proxyWhenNotPreAuthorizedThenDenies() { |
|
|
|
this.spring.register(DefaultsConfig.class).autowire(); |
|
|
|
this.spring.register(DefaultsConfig.class).autowire(); |
|
|
|
Toaster toaster = (Toaster) this.proxyFactory.proxy(new Toaster()); |
|
|
|
Toaster toaster = this.proxyFactory.proxy(new Toaster()); |
|
|
|
assertThatExceptionOfType(AccessDeniedException.class).isThrownBy(toaster::makeToast) |
|
|
|
assertThatExceptionOfType(AccessDeniedException.class).isThrownBy(toaster::makeToast) |
|
|
|
.withMessage("Access Denied"); |
|
|
|
.withMessage("Access Denied"); |
|
|
|
assertThatExceptionOfType(AccessDeniedException.class).isThrownBy(toaster::extractBread) |
|
|
|
assertThatExceptionOfType(AccessDeniedException.class).isThrownBy(toaster::extractBread) |
|
|
|
@ -69,7 +69,7 @@ public class AuthorizationProxyConfigurationTests { |
|
|
|
@Test |
|
|
|
@Test |
|
|
|
public void proxyWhenPreAuthorizedThenAllows() { |
|
|
|
public void proxyWhenPreAuthorizedThenAllows() { |
|
|
|
this.spring.register(DefaultsConfig.class).autowire(); |
|
|
|
this.spring.register(DefaultsConfig.class).autowire(); |
|
|
|
Toaster toaster = (Toaster) this.proxyFactory.proxy(new Toaster()); |
|
|
|
Toaster toaster = this.proxyFactory.proxy(new Toaster()); |
|
|
|
toaster.makeToast(); |
|
|
|
toaster.makeToast(); |
|
|
|
assertThat(toaster.extractBread()).isEqualTo("yummy"); |
|
|
|
assertThat(toaster.extractBread()).isEqualTo("yummy"); |
|
|
|
} |
|
|
|
} |
|
|
|
@ -77,7 +77,7 @@ public class AuthorizationProxyConfigurationTests { |
|
|
|
@Test |
|
|
|
@Test |
|
|
|
public void proxyReactiveWhenNotPreAuthorizedThenDenies() { |
|
|
|
public void proxyReactiveWhenNotPreAuthorizedThenDenies() { |
|
|
|
this.spring.register(ReactiveDefaultsConfig.class).autowire(); |
|
|
|
this.spring.register(ReactiveDefaultsConfig.class).autowire(); |
|
|
|
Toaster toaster = (Toaster) this.proxyFactory.proxy(new Toaster()); |
|
|
|
Toaster toaster = this.proxyFactory.proxy(new Toaster()); |
|
|
|
Authentication user = TestAuthentication.authenticatedUser(); |
|
|
|
Authentication user = TestAuthentication.authenticatedUser(); |
|
|
|
StepVerifier |
|
|
|
StepVerifier |
|
|
|
.create(toaster.reactiveMakeToast().contextWrite(ReactiveSecurityContextHolder.withAuthentication(user))) |
|
|
|
.create(toaster.reactiveMakeToast().contextWrite(ReactiveSecurityContextHolder.withAuthentication(user))) |
|
|
|
@ -90,7 +90,7 @@ public class AuthorizationProxyConfigurationTests { |
|
|
|
@Test |
|
|
|
@Test |
|
|
|
public void proxyReactiveWhenPreAuthorizedThenAllows() { |
|
|
|
public void proxyReactiveWhenPreAuthorizedThenAllows() { |
|
|
|
this.spring.register(ReactiveDefaultsConfig.class).autowire(); |
|
|
|
this.spring.register(ReactiveDefaultsConfig.class).autowire(); |
|
|
|
Toaster toaster = (Toaster) this.proxyFactory.proxy(new Toaster()); |
|
|
|
Toaster toaster = this.proxyFactory.proxy(new Toaster()); |
|
|
|
Authentication admin = TestAuthentication.authenticatedAdmin(); |
|
|
|
Authentication admin = TestAuthentication.authenticatedAdmin(); |
|
|
|
StepVerifier |
|
|
|
StepVerifier |
|
|
|
.create(toaster.reactiveMakeToast().contextWrite(ReactiveSecurityContextHolder.withAuthentication(admin))) |
|
|
|
.create(toaster.reactiveMakeToast().contextWrite(ReactiveSecurityContextHolder.withAuthentication(admin))) |
|
|
|
|