forked from cyberark/conjur-spring-boot-sdk
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
@ConjurPropertySource Not only applied to the properties of a class. F…
…ixes cyberark#75
- Loading branch information
1 parent
7118a99
commit 0c60d82
Showing
1 changed file
with
53 additions
and
0 deletions.
There are no files selected for viewing
53 changes: 53 additions & 0 deletions
53
src/test/java/com/cyberark/conjur/springboot/core/env/ConjurPropertySourceTest.java
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 |
---|---|---|
@@ -0,0 +1,53 @@ | ||
package com.cyberark.conjur.springboot.core.env; | ||
|
||
import com.cyberark.conjur.sdk.ApiException; | ||
import com.cyberark.conjur.sdk.endpoint.SecretsApi; | ||
import com.cyberark.conjur.springboot.annotations.ConjurPropertySource; | ||
import org.junit.jupiter.api.Test; | ||
|
||
import org.springframework.beans.factory.annotation.Value; | ||
import org.springframework.boot.autoconfigure.SpringBootApplication; | ||
import org.springframework.boot.test.context.SpringBootTest; | ||
import org.springframework.boot.test.mock.mockito.MockBean; | ||
import org.springframework.context.annotation.Configuration; | ||
|
||
import static org.mockito.ArgumentMatchers.any; | ||
import static org.mockito.Mockito.times; | ||
import static org.mockito.Mockito.verify; | ||
|
||
/** | ||
* @author bnasslahsen | ||
*/ | ||
@SpringBootTest | ||
public class ConjurPropertySourceTest { | ||
|
||
|
||
@MockBean | ||
private SecretsApi secretsApi; | ||
|
||
@Test | ||
public void testGetSecretCallsCount() throws ApiException { | ||
// Verify the number of times the method was called | ||
verify(secretsApi, times(3)).getSecret(any(), any(), | ||
any()); | ||
} | ||
|
||
@SpringBootApplication | ||
static class ConjurPropertySourceTestApp { | ||
|
||
@ConjurPropertySource("db/") | ||
@Configuration | ||
class ConjurPropertySourceConfiguration { | ||
|
||
@Value("${dbpassWord}") | ||
private byte[] dbpassWord; | ||
|
||
@Value("${dbuserName}") | ||
private byte[] dbuserName; | ||
|
||
@Value("${key}") | ||
private byte[] key; | ||
} | ||
} | ||
|
||
} |