Skip to content

Commit 26b746a

Browse files
pandheradavidh44
authored andcommitted
Adding GenerateAuthenticationTokenRequestTestClass and addressing nits
1 parent c22e382 commit 26b746a

File tree

3 files changed

+51
-24
lines changed

3 files changed

+51
-24
lines changed

services/axdbfrontend/src/main/java/software/amazon/awssdk/services/axdbfrontend/model/Action.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,13 @@
2323
*/
2424
@SdkPublicApi
2525
public enum Action implements Serializable {
26+
/**
27+
* The action of connecting to an AxdbFrontend database using DbConnect
28+
*/
2629
DB_CONNECT("DbConnect"),
30+
/**
31+
* The action of connecting to an AxdbFrontend database using DbConnectSuperuser
32+
*/
2733
DB_CONNECT_SUPERUSER("DbConnectSuperuser");
2834

2935
private final String action;
@@ -36,7 +42,7 @@ public String getAction() {
3642
return action;
3743
}
3844

39-
public static Action variant(String value) {
45+
public static Action fromValue(String value) {
4046
for (Action action : Action.values()) {
4147
if (value.equalsIgnoreCase(action.name())) {
4248
return action;

services/axdbfrontend/src/test/java/software/amazon/awssdk/services/axdbfrontend/DefaultAxdbFrontendUtilitiesTest.java

Lines changed: 16 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
import java.time.ZoneId;
2323
import java.time.ZonedDateTime;
2424
import java.util.function.Consumer;
25-
import nl.jqno.equalsverifier.EqualsVerifier;
2625
import org.junit.jupiter.api.Test;
2726
import software.amazon.awssdk.auth.credentials.AwsBasicCredentials;
2827
import software.amazon.awssdk.auth.credentials.AwsCredentialsProvider;
@@ -41,36 +40,30 @@ public class DefaultAxdbFrontendUtilitiesTest {
4140
private final Clock fixedClock = Clock.fixed(ZonedDateTime.of(2024, 11, 7, 17, 39, 33, 0, utcZone).toInstant(), utcZone);
4241

4342
@Test
44-
void equalsHashcode() {
45-
EqualsVerifier.forClass(GenerateAuthenticationTokenRequest.class)
46-
.withNonnullFields("hostname", "region", "action", "expiresIn", "credentialsProvider")
47-
.verify();
48-
}
49-
@Test
50-
public void testTokenGenerationWithBuilderDefaultsUsingAwsCredentialsProvider() {
43+
public void tokenGenerationWithBuilderDefaultsUsingAwsCredentialsProvider_isSuccessful() {
5144
AwsCredentialsProvider credentialsProvider = StaticCredentialsProvider.create(
5245
AwsBasicCredentials.create("access_key", "secret_key")
5346
);
5447
DefaultBuilder utilitiesBuilder = (DefaultBuilder) AxdbFrontendUtilities.builder()
5548
.credentialsProvider(credentialsProvider)
5649
.region(Region.US_EAST_1);
5750

58-
testTokenGenerationWithBuilderDefaults(utilitiesBuilder);
51+
tokenGenerationWithBuilderDefaults(utilitiesBuilder);
5952
}
6053

6154
@Test
62-
public void testTokenGenerationWithBuilderDefaultsUsingIdentityProvider() {
55+
public void tokenGenerationWithBuilderDefaultsUsingIdentityProvider_isSuccessful() {
6356
IdentityProvider<AwsCredentialsIdentity> credentialsProvider = StaticCredentialsProvider.create(
6457
AwsBasicCredentials.create("access_key", "secret_key")
6558
);
6659
DefaultBuilder utilitiesBuilder = (DefaultBuilder) AxdbFrontendUtilities.builder()
6760
.credentialsProvider(credentialsProvider)
6861
.region(Region.US_EAST_1);
6962

70-
testTokenGenerationWithBuilderDefaults(utilitiesBuilder);
63+
tokenGenerationWithBuilderDefaults(utilitiesBuilder);
7164
}
7265

73-
private void testTokenGenerationWithBuilderDefaults(DefaultBuilder utilitiesBuilder) {
66+
private void tokenGenerationWithBuilderDefaults(DefaultBuilder utilitiesBuilder) {
7467
DefaultAxdbFrontendUtilities AxdbFrontendUtilities = new DefaultAxdbFrontendUtilities(utilitiesBuilder, fixedClock);
7568
Action action = Action.DB_CONNECT_SUPERUSER;
7669

@@ -88,34 +81,34 @@ private void testTokenGenerationWithBuilderDefaults(DefaultBuilder utilitiesBuil
8881
}
8982

9083
@Test
91-
public void testTokenGenerationWithOverriddenCredentialsUsingAwsCredentialsProvider() {
84+
public void tokenGenerationWithOverriddenCredentialsUsingAwsCredentialsProvider_isSuccessful() {
9285
AwsCredentialsProvider credentialsProvider = StaticCredentialsProvider.create(
9386
AwsBasicCredentials.create("foo", "bar")
9487
);
9588
DefaultBuilder utilitiesBuilder = (DefaultBuilder) AxdbFrontendUtilities.builder()
9689
.credentialsProvider(credentialsProvider)
9790
.region(Region.US_EAST_1);
98-
testTokenGenerationWithOverriddenCredentials(utilitiesBuilder, builder -> {
91+
tokenGenerationWithOverriddenCredentials(utilitiesBuilder, builder -> {
9992
builder.credentialsProvider(StaticCredentialsProvider.create(
10093
AwsBasicCredentials.create("access_key", "secret_key")));
10194
});
10295
}
10396

10497
@Test
105-
public void testTokenGenerationWithOverriddenCredentialsUsingIdentityProvider() {
98+
public void tokenGenerationWithOverriddenCredentialsUsingIdentityProvider_isSuccessful() {
10699
IdentityProvider<AwsCredentialsIdentity> credentialsProvider = StaticCredentialsProvider.create(
107100
AwsBasicCredentials.create("foo", "bar")
108101
);
109102
DefaultBuilder utilitiesBuilder = (DefaultBuilder) AxdbFrontendUtilities.builder()
110103
.credentialsProvider(credentialsProvider)
111104
.region(Region.US_EAST_1);
112-
testTokenGenerationWithOverriddenCredentials(utilitiesBuilder, builder -> {
105+
tokenGenerationWithOverriddenCredentials(utilitiesBuilder, builder -> {
113106
builder.credentialsProvider((IdentityProvider<AwsCredentialsIdentity>) StaticCredentialsProvider.create(
114107
AwsBasicCredentials.create("access_key", "secret_key")));
115108
});
116109
}
117110

118-
private void testTokenGenerationWithOverriddenCredentials(DefaultBuilder utilitiesBuilder,
111+
private void tokenGenerationWithOverriddenCredentials(DefaultBuilder utilitiesBuilder,
119112
Consumer<GenerateAuthenticationTokenRequest.Builder> credsBuilder) {
120113
DefaultAxdbFrontendUtilities AxdbFrontendUtilities = new DefaultAxdbFrontendUtilities(utilitiesBuilder, fixedClock);
121114
Action action = Action.DB_CONNECT_SUPERUSER;
@@ -135,7 +128,7 @@ private void testTokenGenerationWithOverriddenCredentials(DefaultBuilder utiliti
135128
}
136129

137130
@Test
138-
public void testTokenGenerationWithOverriddenRegion() {
131+
public void tokenGenerationWithOverriddenRegion_isSuccessful() {
139132
AwsCredentialsProvider credentialsProvider = StaticCredentialsProvider.create(
140133
AwsBasicCredentials.create("access_key", "secret_key")
141134
);
@@ -161,7 +154,7 @@ public void testTokenGenerationWithOverriddenRegion() {
161154
}
162155

163156
@Test
164-
public void testMissingRegionThrowsException() {
157+
public void missingRegion_throwsException() {
165158
AwsCredentialsProvider credentialsProvider = StaticCredentialsProvider.create(
166159
AwsBasicCredentials.create("access_key", "secret_key")
167160
);
@@ -179,7 +172,7 @@ public void testMissingRegionThrowsException() {
179172
}
180173

181174
@Test
182-
public void testMissingCredentialsThrowsException() {
175+
public void missingCredentials_throwsException() {
183176
DefaultBuilder utilitiesBuilder = (DefaultBuilder) AxdbFrontendUtilities.builder()
184177
.region(Region.US_WEST_2);
185178

@@ -194,7 +187,7 @@ public void testMissingCredentialsThrowsException() {
194187
}
195188

196189
@Test
197-
public void testMissingHostnameThrowsException() {
190+
public void missingHostname_throwsException() {
198191
AwsCredentialsProvider credentialsProvider = StaticCredentialsProvider.create(
199192
AwsBasicCredentials.create("access_key", "secret_key")
200193
);
@@ -211,7 +204,7 @@ public void testMissingHostnameThrowsException() {
211204
}
212205

213206
@Test
214-
public void testMissingActionThrowsException() {
207+
public void missingAction_throwsException() {
215208
AwsCredentialsProvider credentialsProvider = StaticCredentialsProvider.create(
216209
AwsBasicCredentials.create("access_key", "secret_key")
217210
);
@@ -228,7 +221,7 @@ public void testMissingActionThrowsException() {
228221
}
229222

230223
@Test
231-
public void testTokenGenerationWithCustomExpiry() {
224+
public void tokenGenerationWithCustomExpiry_isSuccessful() {
232225
AwsCredentialsProvider credentialsProvider = StaticCredentialsProvider.create(
233226
AwsBasicCredentials.create("access_key", "secret_key")
234227
);
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
/*
2+
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License").
5+
* You may not use this file except in compliance with the License.
6+
* A copy of the License is located at
7+
*
8+
* http://aws.amazon.com/apache2.0
9+
*
10+
* or in the "license" file accompanying this file. This file is distributed
11+
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
12+
* express or implied. See the License for the specific language governing
13+
* permissions and limitations under the License.
14+
*/
15+
package software.amazon.awssdk.services.axdbfrontend;
16+
17+
import nl.jqno.equalsverifier.EqualsVerifier;
18+
import org.junit.jupiter.api.Test;
19+
import software.amazon.awssdk.services.axdbfrontend.model.GenerateAuthenticationTokenRequest;
20+
21+
public class GenerateAuthenticationTokenRequestTest {
22+
@Test
23+
void equalsHashcode() {
24+
EqualsVerifier.forClass(GenerateAuthenticationTokenRequest.class)
25+
.withNonnullFields("hostname", "region", "action")
26+
.verify();
27+
}
28+
}

0 commit comments

Comments
 (0)