Skip to content

Commit

Permalink
Add deployment auth method unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
evgiz committed Feb 7, 2025
1 parent 5527f41 commit 36bdd30
Showing 1 changed file with 51 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import com.yahoo.config.provision.ZoneEndpoint;
import com.yahoo.config.provision.ZoneEndpoint.AccessType;
import com.yahoo.config.provision.ZoneEndpoint.AllowedUrn;
import com.yahoo.config.provision.zone.AuthMethod;
import com.yahoo.test.ManualClock;
import org.junit.Test;

Expand Down Expand Up @@ -1204,6 +1205,56 @@ public void emptyEndpoints() {
ClusterSpec.Id.from("cluster")));
}

@Test
public void zoneEndpointTokenAuthentication() {
var spec = DeploymentSpec.fromXml("""
<deployment>
<instance id='default'>
<endpoints>
<endpoint type='private' container-id='c0' auth-method='token'>
<region>us-east</region>
</endpoint>
</endpoints>
</instance>
</deployment>""");
var zone = from(prod, RegionName.from("us-east"));
var zoneEndpoint = spec.requireInstance("default").zoneEndpoints().get(ClusterSpec.Id.from("c0")).get(zone);
assertEquals(new ZoneEndpoint(true, true, List.of(AuthMethod.token), List.of()), zoneEndpoint);
}

@Test
public void defaultMtlsAuthenticationOnPrivateZoneEndpoint() {
var spec = DeploymentSpec.fromXml("""
<deployment>
<instance id='default'>
<endpoints>
<endpoint type='private' container-id='c0'>
<region>us-east</region>
</endpoint>
</endpoints>
</instance>
</deployment>""");
var zone = from(prod, RegionName.from("us-east"));
var zoneEndpoint = spec.requireInstance("default").zoneEndpoints().get(ClusterSpec.Id.from("c0")).get(zone);
assertEquals(new ZoneEndpoint(true, true, List.of(AuthMethod.mtls), List.of()), zoneEndpoint);
}

@Test
public void illegalTokenAuthenticationSettingOnNonPrivateZoneEndpoint() {
assertThrows(
IllegalArgumentException.class,
() -> DeploymentSpec.fromXml("""
<deployment>
<instance id='default'>
<endpoints>
<endpoint type='zone' container-id='c0' auth-method='token'>
<region>us-east</region>
</endpoint>
</endpoints>
</instance>
</deployment>"""));
}

@Test
public void someEndpoints() {
var spec = DeploymentSpec.fromXml("""
Expand Down

0 comments on commit 36bdd30

Please sign in to comment.