-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Dev -> staging for 1.0.0 release (#43)
* Use GPG_KEY_ID secret in script (#38) * Use GPG_KEY_ID secret in script (#37) * Set mock network service for functional tests (#41) * Read ECID from IdentityDirect on Boot when registered (#40) * [AMSDK-11399] Handle install scenario, when Identity direct registered * [AMSDK-11399] Cleanup, IdentityState unit tests * Rename test app * [AMSDK-11399] Add docs for new code * [AMSDK-11399] Cache events locally until the extension is booted up * [AMSDK-11399] Fix unit tests * Code format * [AMSDK-11399] New tests, fix resetIdentities event source * [AMSDK-11399] Cleanup * [AMSDK-11399] Fix null check for getApi * [AMSDK-11399] Review - docs, cleanup * Update core version 1.8.0 (#42) * Fetch identity shared state when needed (#44)
- Loading branch information
Showing
36 changed files
with
1,124 additions
and
543 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
73 changes: 73 additions & 0 deletions
73
code/edgeidentity/src/androidTest/java/com/adobe/marketing/mobile/MockNetworkService.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,73 @@ | ||
/* | ||
Copyright 2021 Adobe. All rights reserved. | ||
This file is licensed 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 REPRESENTATIONS | ||
OF ANY KIND, either express or implied. See the License for the specific language | ||
governing permissions and limitations under the License. | ||
*/ | ||
|
||
package com.adobe.marketing.mobile; | ||
|
||
import com.adobe.marketing.mobile.services.HttpConnecting; | ||
import com.adobe.marketing.mobile.services.NetworkCallback; | ||
import com.adobe.marketing.mobile.services.NetworkRequest; | ||
import com.adobe.marketing.mobile.services.Networking; | ||
|
||
import java.io.ByteArrayInputStream; | ||
import java.io.InputStream; | ||
|
||
/** | ||
* Mock network service used by MobileCore for functional test cases. | ||
* This network service returns '200' HttpConnection responses for every request. | ||
*/ | ||
class MockNetworkService implements Networking { | ||
private static String TAG = "MockNetworkService"; | ||
|
||
private static HttpConnecting dummyConnection = new HttpConnecting() { | ||
@Override | ||
public InputStream getInputStream() { | ||
return new ByteArrayInputStream("{}".getBytes()); | ||
} | ||
|
||
@Override | ||
public InputStream getErrorStream() { | ||
return null; | ||
} | ||
|
||
@Override | ||
public int getResponseCode() { | ||
return 200; | ||
} | ||
|
||
@Override | ||
public String getResponseMessage() { | ||
return null; | ||
} | ||
|
||
@Override | ||
public String getResponsePropertyValue(String s) { | ||
return null; | ||
} | ||
|
||
@Override | ||
public void close() { | ||
|
||
} | ||
}; | ||
|
||
@Override | ||
public void connectAsync(NetworkRequest networkRequest, NetworkCallback networkCallback) { | ||
if (networkRequest == null) { | ||
return; | ||
} | ||
|
||
MobileCore.log(LoggingMode.DEBUG, TAG, "Received async request '" + networkRequest.getUrl() + "', ignoring."); | ||
|
||
if (networkCallback != null) { | ||
networkCallback.call(dummyConnection); | ||
} | ||
} | ||
} |
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
115 changes: 115 additions & 0 deletions
115
code/edgeidentity/src/main/java/com/adobe/marketing/mobile/edge/identity/EventUtils.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,115 @@ | ||
/* | ||
Copyright 2021 Adobe. All rights reserved. | ||
This file is licensed 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 REPRESENTATIONS | ||
OF ANY KIND, either express or implied. See the License for the specific language | ||
governing permissions and limitations under the License. | ||
*/ | ||
|
||
package com.adobe.marketing.mobile.edge.identity; | ||
|
||
import com.adobe.marketing.mobile.Event; | ||
import com.adobe.marketing.mobile.LoggingMode; | ||
import com.adobe.marketing.mobile.MobileCore; | ||
|
||
import java.util.Map; | ||
|
||
import static com.adobe.marketing.mobile.edge.identity.IdentityConstants.LOG_TAG; | ||
|
||
/** | ||
* Class for Event / Event data specific helpers. | ||
*/ | ||
final class EventUtils { | ||
|
||
/** | ||
* Checks if the provided {@code event} is of type {@link IdentityConstants.EventType#EDGE_IDENTITY} and source {@link IdentityConstants.EventSource#REMOVE_IDENTITY} | ||
* | ||
* @param event the event to verify | ||
* @return true if both type and source match | ||
*/ | ||
static boolean isRemoveIdentityEvent(final Event event) { | ||
return event != null && IdentityConstants.EventType.EDGE_IDENTITY.equalsIgnoreCase(event.getType()) | ||
&& IdentityConstants.EventSource.REMOVE_IDENTITY.equalsIgnoreCase(event.getSource()); | ||
} | ||
|
||
/** | ||
* Checks if the provided {@code event} is of type {@link IdentityConstants.EventType#EDGE_IDENTITY} and source {@link IdentityConstants.EventSource#UPDATE_IDENTITY} | ||
* | ||
* @param event the event to verify | ||
* @return true if both type and source match | ||
*/ | ||
static boolean isUpdateIdentityEvent(final Event event) { | ||
return event != null && IdentityConstants.EventType.EDGE_IDENTITY.equalsIgnoreCase(event.getType()) | ||
&& IdentityConstants.EventSource.UPDATE_IDENTITY.equalsIgnoreCase(event.getSource()); | ||
} | ||
|
||
/** | ||
* Checks if the provided {@code event} is of type {@link IdentityConstants.EventType#EDGE_IDENTITY} and source {@link IdentityConstants.EventSource#REQUEST_IDENTITY} | ||
* | ||
* @param event the event to verify | ||
* @return true if both type and source match | ||
*/ | ||
static boolean isRequestIdentityEvent(final Event event) { | ||
return event != null && IdentityConstants.EventType.EDGE_IDENTITY.equalsIgnoreCase(event.getType()) | ||
&& IdentityConstants.EventSource.REQUEST_IDENTITY.equalsIgnoreCase(event.getSource()); | ||
} | ||
|
||
/** | ||
* Checks if the provided {@code event} is of type {@link IdentityConstants.EventType#GENERIC_IDENTITY} and source {@link IdentityConstants.EventSource#REQUEST_RESET} | ||
* | ||
* @param event the event to verify | ||
* @return true if both type and source match | ||
*/ | ||
static boolean isRequestResetEvent(final Event event) { | ||
return event != null && IdentityConstants.EventType.GENERIC_IDENTITY.equalsIgnoreCase(event.getType()) | ||
&& IdentityConstants.EventSource.REQUEST_RESET.equalsIgnoreCase(event.getSource()); | ||
} | ||
|
||
/** | ||
* Checks if the provided {@code event} is a shared state update event for {@code stateOwnerName} | ||
* | ||
* @param stateOwnerName the shared state owner name; should not be null | ||
* @param event current event to check; should not be null | ||
* @return {@code boolean} indicating if it is the shared state update for the provided {@code stateOwnerName} | ||
*/ | ||
static boolean isSharedStateUpdateFor(final String stateOwnerName, final Event event) { | ||
if (Utils.isNullOrEmpty(stateOwnerName) || event == null) { | ||
return false; | ||
} | ||
|
||
String stateOwner; | ||
|
||
try { | ||
stateOwner = (String) event.getEventData().get(IdentityConstants.SharedState.STATE_OWNER); | ||
} catch (ClassCastException e) { | ||
return false; | ||
} | ||
|
||
return stateOwnerName.equals(stateOwner); | ||
} | ||
|
||
/** | ||
* Extracts the ECID from the Identity Direct shared state and returns it as an {@link ECID} object | ||
* | ||
* @param identityDirectSharedState the Identity Direct shared state data | ||
* @return the ECID or null if not found or unable to parse the payload | ||
*/ | ||
static ECID getECID(final Map<String, Object> identityDirectSharedState) { | ||
ECID legacyEcid = null; | ||
|
||
try { | ||
final String legacyEcidString = (String) identityDirectSharedState.get( | ||
IdentityConstants.SharedState.IdentityDirect.ECID); | ||
legacyEcid = legacyEcidString == null ? null : new ECID(legacyEcidString); | ||
} catch (ClassCastException e) { | ||
MobileCore.log(LoggingMode.DEBUG, LOG_TAG, | ||
"EventUtils - Failed to extract ECID from Identity direct shared state, expected String: " | ||
+ e.getLocalizedMessage()); | ||
} | ||
|
||
return legacyEcid; | ||
} | ||
} |
Oops, something went wrong.