Skip to content

Commit

Permalink
Merge pull request #462 from apache/master
Browse files Browse the repository at this point in the history
[pull] master from apache:master
  • Loading branch information
pull[bot] committed Jun 20, 2024
2 parents 58c3471 + 30f2433 commit a6c8f78
Show file tree
Hide file tree
Showing 28 changed files with 201 additions and 68 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ private static Optional<String> getFixedBuildId() {

@SuppressWarnings("resource")
public DockerCassandra() {
this("cassandra_4_1_3-" + buildSpecificImageDiscriminator(),
this("cassandra_4_1_5-" + buildSpecificImageDiscriminator(),
getFixedBuildId().isEmpty(),
AdditionalDockerFileStep.IDENTITY);
}
Expand Down Expand Up @@ -181,14 +181,15 @@ public void close() {
new ImageFromDockerfile(imageName,deleteImageAfterUsage)
.withDockerfileFromBuilder(builder ->
additionalSteps.applyStep(builder
.from("cassandra:4.1.3")
.from("cassandra:4.1.5")
.env("CASSANDRA_CONFIG", "/etc/cassandra")
.run(memorySettingCommand
+ "&& echo \"-Dcassandra.skip_wait_for_gossip_to_settle=0\" >> " + JVM_OPTIONS
+ "&& echo \"-Dcassandra.load_ring_state=false\" >> " + JVM_OPTIONS
+ "&& echo \"-Dcassandra.initial_token=1 \" >> " + JVM_OPTIONS
+ "&& sed -i 's/auto_snapshot: true/auto_snapshot: false/g' /etc/cassandra/cassandra.yaml"
+ "&& sed -i 's/allocate_tokens_for_local_replication_factor: 3/allocate_tokens_for_local_replication_factor: 0/g' /etc/cassandra/cassandra.yaml"
+ "&& sed -i 's/sstable_preemptive_open_interval: .*$/sstable_preemptive_open_interval_in_mb: 0/' /etc/cassandra/cassandra.yaml"
+ "&& echo 'authenticator: PasswordAuthenticator' >> /etc/cassandra/cassandra.yaml"
+ "&& echo 'authorizer: org.apache.cassandra.auth.CassandraAuthorizer' >> /etc/cassandra/cassandra.yaml"))
.build()))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ private static Stream<Arguments> goodAddresses() {
GOOD_ADDRESS,
GOOD_QUOTED_LOCAL_PART,
"server-dev@james-apache.org",
"a&b@james-apache.org",
"server-dev@[127.0.0.1]",
"server.dev@james.apache.org",
"\\.server-dev@james.apache.org",
Expand Down
6 changes: 6 additions & 0 deletions core/src/test/java/org/apache/james/core/UsernameTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,12 @@ void fromUsernameShouldParseUsernameWithDomain() {
.isEqualTo(Username.from("aa", Optional.of("bb")));
}

@Test
void fromUsernameShouldParseUsernameWithDomainWithAnd() {
assertThat(Username.of("a&a@bb"))
.isEqualTo(Username.from("a&a", Optional.of("bb")));
}

@Test
void fromUsernameShouldParseUsernameWithoutDomain() {
assertThat(Username.of("aa"))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
import java.util.Optional;

import org.apache.james.core.Domain;
import org.apache.james.mailbox.exception.MailboxException;
import org.apache.james.mailbox.model.QuotaRoot;
import org.junit.jupiter.api.Test;

Expand Down Expand Up @@ -61,6 +60,12 @@ void quotaRootShouldBeWellDeSerialized() {
.isEqualTo(QuotaRoot.quotaRoot("#private&bob", Optional.empty()));
}

@Test
void quotaRootWithAndShouldBeWellDeSerialized() {
assertThat(DTO_JSON_SERIALIZE.quotaRootReads().reads(new JsString("#private&bob&marley")).get())
.isEqualTo(QuotaRoot.quotaRoot("#private&bob&marley", Optional.empty()));
}

@Test
void emptyQuotaRootShouldBeWellSerialized() {
assertThat(DTO_JSON_SERIALIZE.quotaRootWrites().writes(QuotaRoot.quotaRoot("", Optional.empty())))
Expand All @@ -70,8 +75,8 @@ void emptyQuotaRootShouldBeWellSerialized() {
@Test
void emptyQuotaRootShouldBeWellDeSerialized() {
assertThatThrownBy(() -> DTO_JSON_SERIALIZE.quotaRootReads().reads(new JsString("")).get())
.isInstanceOf(MailboxException.class)
.hasMessage(" used as QuotaRoot should contain exactly one \"&\"");
.isInstanceOf(IllegalArgumentException.class)
.hasMessage("username should not be null or empty after being trimmed");
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,11 @@
import org.apache.james.util.ReactorUtils;
import org.reactivestreams.Publisher;

import com.google.common.base.Joiner;
import com.google.common.base.Preconditions;
import com.google.common.base.Splitter;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.Iterables;

import reactor.core.publisher.Flux;
import reactor.core.publisher.Mono;
Expand All @@ -61,7 +64,10 @@ public QuotaRoot fromString(String serializedQuotaRoot) throws MailboxException
public List<String> toParts(String serializedQuotaRoot) throws MailboxException {
List<String> parts = Splitter.on(SEPARATOR).splitToList(serializedQuotaRoot);
if (parts.size() != 2) {
throw new MailboxException(serializedQuotaRoot + " used as QuotaRoot should contain exactly one \"" + SEPARATOR + "\"");
return ImmutableList.<String>builder()
.add(parts.get(0))
.add(Joiner.on(SEPARATOR).join(Iterables.skip(parts, 1)))
.build();
}
return parts;
}
Expand Down Expand Up @@ -96,10 +102,6 @@ public Username associatedUsername(QuotaRoot quotaRoot) {
public QuotaRoot getQuotaRoot(MailboxPath mailboxPath) {
Preconditions.checkArgument(!mailboxPath.getNamespace().contains(SEPARATOR), "Namespace should not contain %s", SEPARATOR);
return Optional.ofNullable(mailboxPath.getUser())
.map(user -> {
Preconditions.checkArgument(!mailboxPath.getUser().asString().contains(SEPARATOR), "Username should not contain %s", SEPARATOR);
return mailboxPath.getUser();
})
.map(user -> QuotaRoot.quotaRoot(mailboxPath.getNamespace() + SEPARATOR + user.asString(), user.getDomainPart()))
.orElseGet(() -> QuotaRoot.quotaRoot(mailboxPath.getNamespace(), Optional.empty()));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
import org.apache.james.core.Username;
import org.apache.james.mailbox.MailboxSession;
import org.apache.james.mailbox.SessionProvider;
import org.apache.james.mailbox.exception.MailboxException;
import org.apache.james.mailbox.model.Mailbox;
import org.apache.james.mailbox.model.MailboxId;
import org.apache.james.mailbox.model.MailboxPath;
Expand All @@ -46,7 +45,6 @@
import reactor.core.publisher.Mono;

class DefaultUserQuotaRootResolverTest {

static final Username BENWA = Username.of("benwa");
static final MailboxId MAILBOX_ID = TestId.of(42);
static final MailboxPath MAILBOX_PATH = MailboxPath.inbox(BENWA);
Expand Down Expand Up @@ -80,9 +78,26 @@ void getQuotaRootShouldThrowWhenNamespaceContainsSeparator() {
}

@Test
void getQuotaRootShouldThrowWhenUserContainsSeparator() {
assertThatThrownBy(() -> testee.getQuotaRoot(MailboxPath.forUser(Username.of("ben&wa"), "INBOX")))
.isInstanceOf(IllegalArgumentException.class);
void associatedUsernameShouldNoopWhenUsernameWithAnd() {
Username originalUsername = Username.of("ben&wa");
Username resolvedUsername = testee.associatedUsername(testee.getQuotaRoot(MailboxPath.inbox(originalUsername)));

assertThat(resolvedUsername).isEqualTo(originalUsername);
}

@Test
void getQuotaRootShouldNoopWhenUsernameWithAnd() {
QuotaRoot originalQuotaRoot = QuotaRoot.quotaRoot("#private&ben&wa", Optional.empty());
QuotaRoot resolvedQuotaRoot = testee.getQuotaRoot(MailboxPath.inbox(testee.associatedUsername(originalQuotaRoot)));

assertThat(resolvedQuotaRoot).isEqualTo(originalQuotaRoot);
}

@Test
void fromStringShouldNoopWhenUsernameWithAnd() throws Exception {
QuotaRoot originalQuotaRoot = QuotaRoot.quotaRoot("#private&ben&wa", Optional.empty());
QuotaRoot parsedQuotaRoot = testee.fromString(originalQuotaRoot.getValue());
assertThat(parsedQuotaRoot).isEqualTo(originalQuotaRoot);
}

@Test
Expand All @@ -93,24 +108,28 @@ void getQuotaRootShouldWorkWhenUserIsNull() {
}

@Test
void retrieveAssociatedMailboxesShouldWork() throws Exception {
void retrieveAssociatedMailboxesShouldWork() {
MailboxMapper mockedMapper = mock(MailboxMapper.class);
when(mockedFactory.getMailboxMapper(MAILBOX_SESSION)).thenReturn(mockedMapper);
when(mockedFactory.getMailboxMapper(any())).thenReturn(mockedMapper);
when(mockedMapper.findMailboxWithPathLike(any())).thenReturn(Flux.just(MAILBOX, MAILBOX_2));

assertThat(testee.retrieveAssociatedMailboxes(QUOTA_ROOT, MAILBOX_SESSION).collectList().block()).containsOnly(MAILBOX, MAILBOX_2);
}

@Test
void retrieveAssociatedMailboxesShouldThrowWhenQuotaRootContainsSeparator2Times() {
assertThatThrownBy(() -> testee.retrieveAssociatedMailboxes(
void retrieveAssociatedMailboxesShouldSupportQuotaRootContainsSeparator2Times() {
MailboxMapper mockedMapper = mock(MailboxMapper.class);
when(mockedFactory.getMailboxMapper(any())).thenReturn(mockedMapper);
when(mockedMapper.findMailboxWithPathLike(any())).thenReturn(Flux.just(MAILBOX, MAILBOX_2));

assertThat(testee.retrieveAssociatedMailboxes(
QuotaRoot.quotaRoot("#private&be&nwa", Optional.empty()), MAILBOX_SESSION)
.collectList().block())
.hasCauseInstanceOf(MailboxException.class);
.containsOnly(MAILBOX, MAILBOX_2);
}

@Test
void getQuotaRootShouldReturnUserValueWhenCalledWithMailboxId() throws Exception {
void getQuotaRootShouldReturnUserValueWhenCalledWithMailboxId() {
MailboxMapper mockedMapper = mock(MailboxMapper.class);
when(mockedFactory.getMailboxMapper(any())).thenReturn(mockedMapper);
when(mockedMapper.findMailboxById(MAILBOX_ID)).thenReturn(Mono.just(MAILBOX));
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -609,7 +609,7 @@
<jsieve.version>0.8</jsieve.version>
<spring.version>6.1.4</spring.version>
<activmq-artemis.version>2.32.0</activmq-artemis.version>
<apache-jspf-resolver.version>1.0.3</apache-jspf-resolver.version>
<apache-jspf-resolver.version>1.0.4</apache-jspf-resolver.version>
<angus-mail.version>2.0.2</angus-mail.version>
<angus-activation.version>2.0.1</angus-activation.version>
<jakarta.activation-api.version>2.1.2</jakarta.activation-api.version>
Expand Down
2 changes: 1 addition & 1 deletion server/apps/cassandra-app/README.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ Third party compulsory dependencies:

[source]
----
$ docker run -d --network james -p 9042:9042 --name=cassandra cassandra:4.1.3
$ docker run -d --network james -p 9042:9042 --name=cassandra cassandra:4.1.5
$ docker run -d --network james -p 9200:9200 --name=opensearch --env 'discovery.type=single-node' opensearchproject/opensearch:2.1.0
----

Expand Down
2 changes: 1 addition & 1 deletion server/apps/cassandra-app/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ services:
- DISABLE_SECURITY_PLUGIN=true

cassandra:
image: cassandra:4.1.3
image: cassandra:4.1.5
ports:
- "9042:9042"
healthcheck:
Expand Down
2 changes: 1 addition & 1 deletion server/apps/distributed-app/README.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ Third party compulsory dependencies:

[source]
----
$ docker run -d --network james -p 9042:9042 --name=cassandra cassandra:4.1.3
$ docker run -d --network james -p 9042:9042 --name=cassandra cassandra:4.1.5
$ docker run -d --network james -p 9200:9200 --name=opensearch --env 'discovery.type=single-node' --env 'DISABLE_SECURITY_PLUGIN=true' --env 'DISABLE_INSTALL_DEMO_CONFIG=true' opensearchproject/opensearch:2.1.0
$ docker run -d --network james -p 5672:5672 -p 15672:15672 --name=rabbitmq rabbitmq:3.12.1-management
$ docker run -d --network james -p 8000:8000 --env 'REMOTE_MANAGEMENT_DISABLE=1' --env 'SCALITY_ACCESS_KEY_ID=accessKey1' --env 'SCALITY_SECRET_ACCESS_KEY=secretKey1' --name=s3 registry.scality.com/cloudserver/cloudserver:8.7.25
Expand Down
2 changes: 1 addition & 1 deletion server/apps/distributed-app/docker-compose-with-pulsar.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ services:

cassandra:
container_name: cassandra
image: cassandra:4.1.3
image: cassandra:4.1.5
ports:
- "9042:9042"
healthcheck:
Expand Down
2 changes: 1 addition & 1 deletion server/apps/distributed-app/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ services:
- elasticsearch

cassandra:
image: cassandra:4.1.3
image: cassandra:4.1.5
ports:
- "9042:9042"
healthcheck:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ services:
- discovery.type=single-node
cassandra:
image: cassandra:4.1.3
image: cassandra:4.1.5
ports:
- "9042:9042"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ Firstly, create your own user network on Docker for the James environment:

You need a running *cassandra* in docker which connects to *james* network. To achieve this run:

$ docker run -d --network james --name=cassandra cassandra:4.1.3
$ docker run -d --network james --name=cassandra cassandra:4.1.5

You need a running *rabbitmq* in docker which connects to *james* network. To achieve this run:

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ running. You can either install the servers or launch them via docker:

[source,bash]
----
$ docker run -d -p 9042:9042 --name=cassandra cassandra:4.1.3
$ docker run -d -p 9042:9042 --name=cassandra cassandra:4.1.5
$ docker run -d --network james -p 9200:9200 --name=opensearch --env 'discovery.type=single-node' opensearchproject/opensearch:2.1.0
$ docker run -d -p 5672:5672 -p 15672:15672 --name=rabbitmq rabbitmq:3.12.1-management
$ docker run -d --env 'REMOTE_MANAGEMENT_DISABLE=1' --env 'SCALITY_ACCESS_KEY_ID=accessKey1' --env 'SCALITY_SECRET_ACCESS_KEY=secretKey1' --name=s3 registry.scality.com/cloudserver/cloudserver:8.7.25
Expand Down
2 changes: 1 addition & 1 deletion server/apps/distributed-pop3-app/README.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ Third party compulsory dependencies:

[source]
----
$ docker run -d --network james -p 9042:9042 --name=cassandra cassandra:4.1.3
$ docker run -d --network james -p 9042:9042 --name=cassandra cassandra:4.1.5
$ docker run -d --network james -p 5672:5672 -p 15672:15672 --name=rabbitmq rabbitmq:3.12.1-management
$ docker run -d --network james --env 'REMOTE_MANAGEMENT_DISABLE=1' --env 'SCALITY_ACCESS_KEY_ID=accessKey1' --env 'SCALITY_SECRET_ACCESS_KEY=secretKey1' --name=s3 registry.scality.com/cloudserver/cloudserver:8.7.25
----
Expand Down
2 changes: 1 addition & 1 deletion server/apps/distributed-pop3-app/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ services:
- elasticsearch

cassandra:
image: cassandra:4.1.3
image: cassandra:4.1.5
ports:
- "9042:9042"
healthcheck:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,4 +88,20 @@ void simpleMailShouldBeSent() throws Exception {
.select(TARGETED_MAILBOX)
.awaitMessage(awaitAtMostOneMinute);
}

@Test
void shouldDeliverToEmailAddressWithAND() throws Exception {
String recipient = "a&b@james.org";
jamesServer.getProbe(DataProbeImpl.class)
.addUser(recipient, PASSWORD);

messageSender.connect(LOCALHOST_IP, jamesServer.getProbe(SmtpGuiceProbe.class).getSmtpPort())
.authenticate(FROM, PASSWORD)
.sendMessage(FROM, recipient);

testIMAPClient.connect(LOCALHOST_IP, jamesServer.getProbe(ImapGuiceProbe.class).getImapPort())
.login(recipient, PASSWORD)
.select("INBOX")
.awaitMessage(awaitAtMostOneMinute);
}
}
44 changes: 44 additions & 0 deletions server/mailet/ldap/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
-->
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>

<parent>
<groupId>org.apache.james</groupId>
<artifactId>james-server</artifactId>
<version>3.9.0-SNAPSHOT</version>
<relativePath>../../pom.xml</relativePath>
</parent>
<artifactId>james-server-mailet-ldap</artifactId>
<packaging>jar</packaging>

<name>Apache James :: Server :: Matcher :: LDAP</name>

<dependencies>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>james-server-data-ldap</artifactId>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>james-server-mailets</artifactId>
</dependency>
</dependencies>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/****************************************************************
* Licensed to the Apache Software Foundation (ASF) under one *
* or more contributor license agreements. See the NOTICE file *
* distributed with this work for additional information *
* regarding copyright ownership. The ASF licenses this file *
* to you under the Apache License, Version 2.0 (the *
* "License"); you may not use this file except in compliance *
* with the License. You may obtain a copy of the License at *
* *
* http://www.apache.org/licenses/LICENSE-2.0 *
* *
* Unless required by applicable law or agreed to in writing, *
* software distributed under the License is distributed on an *
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY *
* KIND, either express or implied. See the License for the *
* specific language governing permissions and limitations *
* under the License. *
****************************************************************/

package org.apache.james.transport.matchers;

import java.util.Collection;

import org.apache.james.core.MailAddress;
import org.apache.james.user.ldap.LdapRepositoryConfiguration;
import org.apache.mailet.Mail;
import org.apache.mailet.base.GenericMatcher;

import jakarta.mail.MessagingException;

public class HasLDAPAttribute extends GenericMatcher {
private final LdapRepositoryConfiguration configuration;

@Override
public Collection<MailAddress> match(Mail mail) throws MessagingException {
return null;
}
}
Loading

0 comments on commit a6c8f78

Please sign in to comment.