-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(CO-1133): fix amavis ldap attrs definition (#533)
* fix: do not include amavis attributes in zimbraAccount schema * chore: re-generate ZAttrAccount * fix(test): do not close the soap client after execute so we can read big body * test: add GetInfo handler tests * refactor: simplify SoapUtils * refactor: use HttpClient instead of CloseableHttpClient
- Loading branch information
1 parent
2708e4d
commit 5f75ce3
Showing
5 changed files
with
115 additions
and
144 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
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
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
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
85 changes: 85 additions & 0 deletions
85
store/src/test/java/com/zimbra/cs/service/account/GetInfoTest.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,85 @@ | ||
package com.zimbra.cs.service.account; | ||
|
||
import static org.junit.jupiter.api.Assertions.*; | ||
|
||
import com.zextras.mailbox.soap.SoapTestSuite; | ||
import com.zextras.mailbox.util.MailboxTestUtil; | ||
import com.zimbra.common.account.ZAttrProvisioning; | ||
import com.zimbra.cs.account.Account; | ||
import com.zimbra.cs.account.Provisioning; | ||
import com.zimbra.soap.account.message.GetInfoRequest; | ||
import org.apache.http.HttpStatus; | ||
import org.apache.http.util.EntityUtils; | ||
import org.junit.jupiter.api.BeforeAll; | ||
import org.junit.jupiter.api.BeforeEach; | ||
import org.junit.jupiter.api.Tag; | ||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.params.ParameterizedTest; | ||
import org.junit.jupiter.params.provider.ValueSource; | ||
|
||
@Tag("api") | ||
class GetInfoTest extends SoapTestSuite { | ||
|
||
private static MailboxTestUtil.AccountCreator.Factory accountCreatorFactory; | ||
private static Provisioning provisioning; | ||
private Account account; | ||
|
||
@BeforeAll | ||
static void init() throws Exception { | ||
provisioning = Provisioning.getInstance(); | ||
accountCreatorFactory = new MailboxTestUtil.AccountCreator.Factory(provisioning); | ||
} | ||
|
||
@BeforeEach | ||
void setUp() throws Exception { | ||
account = accountCreatorFactory.get().create(); | ||
} | ||
|
||
@Test | ||
void getAllSections() throws Exception { | ||
final var request = new GetInfoRequest(); | ||
|
||
final var response = getSoapClient().executeSoap(account, request); | ||
|
||
assertEquals(HttpStatus.SC_OK, response.getStatusLine().getStatusCode()); | ||
} | ||
|
||
@ParameterizedTest | ||
@ValueSource( | ||
strings = { | ||
"mbox", | ||
"prefs", | ||
"attrs", | ||
"zimlets", | ||
"props", | ||
"idents", | ||
"sigs", | ||
"dsrcs", | ||
"children" | ||
}) | ||
void getSpecificSection(String section) throws Exception { | ||
final var request = new GetInfoRequest().addSection(section); | ||
|
||
final var response = getSoapClient().executeSoap(account, request); | ||
|
||
assertEquals(HttpStatus.SC_OK, response.getStatusLine().getStatusCode()); | ||
} | ||
|
||
@Test | ||
void attributesSectionProvidesAmavisLists() throws Exception { | ||
final var account = | ||
accountCreatorFactory | ||
.get() | ||
.withAttribute(ZAttrProvisioning.A_amavisWhitelistSender, "foo1@bar.com") | ||
.withAttribute(ZAttrProvisioning.A_amavisBlacklistSender, "foo2@bar.com") | ||
.create(); | ||
final var request = new GetInfoRequest().addSection("attrs"); | ||
|
||
final var response = getSoapClient().executeSoap(account, request); | ||
|
||
assertEquals(HttpStatus.SC_OK, response.getStatusLine().getStatusCode()); | ||
final var body = EntityUtils.toString(response.getEntity()); | ||
assertTrue(body.contains("amavisWhitelistSender")); | ||
assertTrue(body.contains("amavisBlacklistSender")); | ||
} | ||
} |