-
Notifications
You must be signed in to change notification settings - Fork 46
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
99 additions
and
2 deletions.
There are no files selected for viewing
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
41 changes: 40 additions & 1 deletion
41
src/test/java/com/github/vaibhavsinha/kong/RetrofitAclServiceTest.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 |
---|---|---|
@@ -1,7 +1,46 @@ | ||
package com.github.vaibhavsinha.kong; | ||
|
||
import com.github.vaibhavsinha.kong.model.admin.consumer.Consumer; | ||
import com.github.vaibhavsinha.kong.model.plugin.security.acl.Acl; | ||
import com.github.vaibhavsinha.kong.model.plugin.security.acl.AclList; | ||
import org.junit.After; | ||
import org.junit.Before; | ||
import org.junit.Test; | ||
|
||
import java.util.UUID; | ||
|
||
import static org.junit.Assert.assertEquals; | ||
|
||
/** | ||
* Created by dvilela on 10/22/17. | ||
*/ | ||
public class RetrofitAclServiceTest { | ||
public class RetrofitAclServiceTest extends BaseTest { | ||
|
||
private Consumer consumer; | ||
|
||
@Before | ||
public void createConsumer() throws Exception { | ||
consumer = new Consumer(); | ||
String id = UUID.randomUUID().toString(); | ||
consumer.setCustomId(id); | ||
|
||
consumer = kongClient.getConsumerService().createConsumer(consumer); | ||
} | ||
|
||
@After | ||
public void deleteConsumer() throws Exception { | ||
kongClient.getConsumerService().deleteConsumer(consumer.getId()); | ||
} | ||
|
||
@Test | ||
public void testAssociateAndListAcls() throws Exception { | ||
kongClient.getAclService().associateConsumer(consumer.getId(), "default"); | ||
|
||
AclList list = kongClient.getAclService().listAcls(consumer.getId(), 1L, null); | ||
|
||
Acl acl = list.getData().get(0); | ||
assertEquals(consumer.getId(), acl.getConsumerId()); | ||
assertEquals("default", acl.getGroup()); | ||
} | ||
|
||
} |
58 changes: 58 additions & 0 deletions
58
src/test/java/com/github/vaibhavsinha/kong/RetrofitJwtServiceTest.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,58 @@ | ||
package com.github.vaibhavsinha.kong; | ||
|
||
import com.github.vaibhavsinha.kong.model.admin.consumer.Consumer; | ||
import com.github.vaibhavsinha.kong.model.plugin.authentication.jwt.JwtCredential; | ||
import com.github.vaibhavsinha.kong.model.plugin.authentication.jwt.JwtCredentialList; | ||
import org.junit.AfterClass; | ||
import org.junit.BeforeClass; | ||
import org.junit.FixMethodOrder; | ||
import org.junit.Test; | ||
import org.junit.runners.MethodSorters; | ||
|
||
import java.util.UUID; | ||
|
||
import static org.junit.Assert.assertEquals; | ||
|
||
/** | ||
* Created by dvilela on 10/22/17. | ||
*/ | ||
@FixMethodOrder(MethodSorters.NAME_ASCENDING) | ||
public class RetrofitJwtServiceTest extends BaseTest { | ||
|
||
private static Consumer consumer; | ||
|
||
@BeforeClass | ||
public static void createConsumer() throws Exception { | ||
Consumer c = new Consumer(); | ||
c.setCustomId(UUID.randomUUID().toString()); | ||
consumer = kongClient.getConsumerService().createConsumer(c); | ||
} | ||
|
||
@AfterClass | ||
public static void deleteConsumer() throws Exception { | ||
kongClient.getConsumerService().deleteConsumer(consumer.getId()); | ||
} | ||
|
||
@Test | ||
public void test01_addCredentialTest() throws Exception { | ||
JwtCredential credential = kongClient.getJwtService().addCredentials(consumer.getId(), new JwtCredential()); | ||
assertEquals(consumer.getId(), credential.getConsumerId()); | ||
} | ||
|
||
@Test | ||
public void test02_listCredentialsTest() throws Exception { | ||
JwtCredentialList list = kongClient.getJwtService().listCredentials(consumer.getId(), null, null); | ||
JwtCredential credential = list.getData().get(0); | ||
assertEquals(consumer.getId(), credential.getConsumerId()); | ||
} | ||
|
||
@Test | ||
public void test03_deleteCredentialTest() throws Exception { | ||
JwtCredentialList list = kongClient.getJwtService().listCredentials(consumer.getId(), null, null); | ||
JwtCredential credential = list.getData().get(0); | ||
kongClient.getJwtService().deleteCredentials(consumer.getId(), credential.getId()); | ||
JwtCredentialList list2 = kongClient.getJwtService().listCredentials(consumer.getId(), null, null); | ||
assertEquals(0L, (long) list2.getTotal()); | ||
} | ||
|
||
} |