-
Notifications
You must be signed in to change notification settings - Fork 44
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#317: Added Google Analytics Tracking Id to server configuration
- Loading branch information
Showing
8 changed files
with
210 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
Isotope Mail Client (Server) | ||
============================ | ||
|
||
HTTP REST API for IMAP/SMTP communications. | ||
|
||
Java Back-end application designed as a "microservice", future developments | ||
will break down this application into separate microservices for communications with | ||
different protocols (IMAP, SMTP, etc.) and data domains. | ||
|
||
## Configuration variables | ||
|
||
Variable | Description | ||
-------- | ----------- | ||
ENCRYPTION_PASSWORD | Password used for encryption and decryption (symmetric) of credentials (Password must be the same for all the instances of the microservice in a single deployment) | ||
TRUSTED_HOSTS | Comma separated list of hosts allowed as IMAP/SMTP server parameters, if empty or not provided, all hosts will be allowed. | ||
EMBEDDED_IMAGE_SIZE_THRESHOLD | Size in bytes defining the threshold value used to decide if images will be downloaded separately or embedded within messages when retrieved from the client | ||
GOOGLE_ANALYTICS_TRACKING_ID | \[Optional\] Google Analytics tracking id to enable google analytics in client application |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,14 +20,41 @@ | |
*/ | ||
package com.marcnuri.isotope.api.application; | ||
|
||
import com.fasterxml.jackson.annotation.JsonInclude; | ||
import com.marcnuri.isotope.api.resource.IsotopeResource; | ||
|
||
import java.io.Serializable; | ||
import java.util.Objects; | ||
|
||
/** | ||
* Created by Marc Nuri <[email protected]> on 2019-04-06. | ||
*/ | ||
@JsonInclude(JsonInclude.Include.NON_NULL) | ||
class ConfigurationDto extends IsotopeResource implements Serializable { | ||
|
||
private static final long serialVersionUID = -1279556906780840837L; | ||
|
||
private String googleAnalyticsTrackingId; | ||
|
||
public String getGoogleAnalyticsTrackingId() { | ||
return googleAnalyticsTrackingId; | ||
} | ||
|
||
public void setGoogleAnalyticsTrackingId(String googleAnalyticsTrackingId) { | ||
this.googleAnalyticsTrackingId = googleAnalyticsTrackingId; | ||
} | ||
|
||
@Override | ||
public boolean equals(Object o) { | ||
if (this == o) return true; | ||
if (o == null || getClass() != o.getClass()) return false; | ||
if (!super.equals(o)) return false; | ||
ConfigurationDto that = (ConfigurationDto) o; | ||
return Objects.equals(googleAnalyticsTrackingId, that.googleAnalyticsTrackingId); | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
return Objects.hash(super.hashCode(), googleAnalyticsTrackingId); | ||
} | ||
} |
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
74 changes: 74 additions & 0 deletions
74
server/src/test/java/com/marcnuri/isotope/api/application/ConfigurationDtoTest.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,74 @@ | ||
/* | ||
* ConfigurationDtoTest.java | ||
* | ||
* Created on 2019-07-29, 6:58 | ||
* | ||
* Copyright 2019 Marc Nuri | ||
* | ||
* Licensed 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 com.marcnuri.isotope.api.application; | ||
|
||
import org.junit.Test; | ||
|
||
import static org.hamcrest.Matchers.is; | ||
import static org.junit.Assert.assertThat; | ||
|
||
/** | ||
* Created by Marc Nuri <[email protected]> on 2019-07-29. | ||
*/ | ||
public class ConfigurationDtoTest { | ||
|
||
@Test | ||
public void hashCode_sameProperties_shouldBeTrue() { | ||
// Given | ||
final ConfigurationDto one = new ConfigurationDto(); | ||
final ConfigurationDto other = new ConfigurationDto(); | ||
for (ConfigurationDto instance : new ConfigurationDto[]{one, other}) { | ||
instance.setGoogleAnalyticsTrackingId("UA-1337-33"); | ||
} | ||
// When | ||
final int hashCodeOne = one.hashCode(); | ||
final int hashCodeOther = other.hashCode(); | ||
// Then | ||
assertThat(hashCodeOne, is(hashCodeOther)); | ||
} | ||
|
||
@Test | ||
public void equals_sameProperties_shouldBeTrue() { | ||
// Given | ||
final ConfigurationDto one = new ConfigurationDto(); | ||
final ConfigurationDto other = new ConfigurationDto(); | ||
for (ConfigurationDto instance : new ConfigurationDto[]{one, other}) { | ||
instance.setGoogleAnalyticsTrackingId("UA-1337-33"); | ||
} | ||
// When | ||
final boolean result = one.equals(other); | ||
// Then | ||
assertThat(result, is(true)); | ||
} | ||
|
||
@Test | ||
public void equals_differentProperties_shouldBeFalse() { | ||
// Given | ||
final ConfigurationDto one = new ConfigurationDto(); | ||
one.setGoogleAnalyticsTrackingId("UA-1337-33"); | ||
final ConfigurationDto other = new ConfigurationDto(); | ||
// When | ||
final boolean result = one.equals(other); | ||
// Then | ||
assertThat(result, is(false)); | ||
} | ||
|
||
} |
69 changes: 69 additions & 0 deletions
69
server/src/test/java/com/marcnuri/isotope/api/configuration/IsotopeApiConfigurationTest.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,69 @@ | ||
/* | ||
* IsotopeApiConfigurationTest.java | ||
* | ||
* Created on 2019-07-28, 20:34 | ||
* | ||
* Copyright 2019 Marc Nuri | ||
* | ||
* Licensed 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 com.marcnuri.isotope.api.configuration; | ||
|
||
import org.junit.Before; | ||
import org.junit.Test; | ||
import org.mockito.Mockito; | ||
import org.springframework.core.env.Environment; | ||
|
||
import static org.hamcrest.Matchers.is; | ||
import static org.junit.Assert.assertThat; | ||
import static org.mockito.ArgumentMatchers.anyString; | ||
import static org.mockito.ArgumentMatchers.eq; | ||
import static org.mockito.Mockito.doReturn; | ||
|
||
/** | ||
* Created by Marc Nuri <[email protected]> on 2019-07-28. | ||
*/ | ||
public class IsotopeApiConfigurationTest { | ||
|
||
private Environment environment; | ||
private IsotopeApiConfiguration istotopeApiConfiguration; | ||
|
||
@Before | ||
public void setUp() { | ||
environment = Mockito.mock(Environment.class); | ||
istotopeApiConfiguration = new IsotopeApiConfiguration(environment); | ||
} | ||
|
||
@Test | ||
public void getEncryptionPassword_envVariableSet_shouldReturnEnvValue() { | ||
// Given | ||
doReturn("1234").when(environment) | ||
.getProperty(eq("ENCRYPTION_PASSWORD"), anyString()); | ||
// When | ||
final String result = istotopeApiConfiguration.getEncryptionPassword(); | ||
// Then | ||
assertThat(result, is("1234")); | ||
} | ||
|
||
@Test | ||
public void getGoogleAnalyticsTrackingId_envVariableSet_shouldReturnEnvValue() { | ||
// Given | ||
doReturn("UA-1337-33").when(environment).getProperty(eq("GOOGLE_ANALYTICS_TRACKING_ID")); | ||
// When | ||
final String result = istotopeApiConfiguration.getGoogleAnalyticsTrackingId(); | ||
// Then | ||
assertThat(result, is("UA-1337-33")); | ||
} | ||
|
||
} |