Skip to content

Commit

Permalink
Permissions revamp
Browse files Browse the repository at this point in the history
- Removed share flag
- Removed granular encryption, is now across types
  • Loading branch information
shannon-rodricks committed Aug 22, 2021
1 parent b509057 commit 0792af8
Show file tree
Hide file tree
Showing 11 changed files with 132 additions and 240 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,4 @@ class MADAssistantCipherImplTest {
assertEquals(plainText, deciphered)
}

@Test
fun testPermissionModel() {
val input = MADAssistantPermissions(
deviceId = "fsdfsdfsd",

)
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,12 @@ class AnalyticsPermissionModelTest {

private fun testJson(
enabled: Boolean = false,
read: Boolean = false,
share: Boolean = false,
filterDestination: String? = null,
filterEventName: String? = null,
filterParamData: String? = null
) {
val input = AnalyticsPermissionModel(
enabled = enabled,
read = read,
share = share,
filterDestination = filterDestination,
filterEventName = filterEventName,
filterParamData = filterParamData
Expand All @@ -30,8 +26,6 @@ class AnalyticsPermissionModelTest {
fun serializeSimpleObject() {
testJson(
enabled = true,
read = true,
share = true,
filterDestination = "Test*",
filterEventName = null
)
Expand All @@ -41,7 +35,6 @@ class AnalyticsPermissionModelTest {
fun serializeRegexFilter() {
testJson(
enabled = true,
read = true,
filterDestination = "(Destination1|Destination2).*",
filterParamData = "\"screen_view\""
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,11 @@ class ApiCallsPermissionModelTest {

private fun testJson(
enabled: Boolean = false,
read: Boolean = false,
share: Boolean = false,
filterMethod: String? = null,
filterUrl: String? = null
): ApiCallsPermissionModel {
val input = ApiCallsPermissionModel(
enabled = enabled,
read = read,
share = share,
filterMethod = filterMethod,
filterUrl = filterUrl
)
Expand All @@ -30,8 +26,6 @@ class ApiCallsPermissionModelTest {
fun serializeSimpleObject() {
testJson(
enabled = true,
read = true,
share = true,
filterMethod = ".*(GET|POST).*",
filterUrl = null
)
Expand All @@ -41,12 +35,9 @@ class ApiCallsPermissionModelTest {
fun withRegexUrlFilter() {
testJson(
enabled = true,
read = true,
filterMethod = null,
filterUrl = "/records/.*"
).apply {
assertEquals(false, this.share)
}
)
}

}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,14 @@ import com.evdayapps.madassistant.common.kotlinx.getStringOrNull
import org.json.JSONObject

data class AnalyticsPermissionModel(
var enabled: Boolean = false,
var read: Boolean = false,
var share: Boolean = false,
var filterDestination: String? = null,
var filterEventName: String? = null,
var filterParamData: String? = null,
val enabled: Boolean = false,
val filterDestination: String? = null,
val filterEventName: String? = null,
val filterParamData: String? = null,
) {

companion object {
private const val KEY_enabled = "enabled"
private const val KEY_read = "read"
private const val KEY_share = "share"

private const val KEY_filterDestination = "filterDestination"
private const val KEY_filterEventName = "filterEventName"
private const val KEY_filterParamData = "filterParamData"
Expand All @@ -25,8 +20,6 @@ data class AnalyticsPermissionModel(
@Throws(Exception::class)
constructor(json: JSONObject) : this(
enabled = json.optBoolean(KEY_enabled, false),
read = json.optBoolean(KEY_read, false),
share = json.optBoolean(KEY_share, false),
filterDestination = json.getStringOrNull(KEY_filterDestination),
filterEventName = json.getStringOrNull(KEY_filterEventName),
filterParamData = json.getStringOrNull(KEY_filterParamData),
Expand All @@ -35,9 +28,6 @@ data class AnalyticsPermissionModel(
fun toJsonObject(): JSONObject {
return JSONObject().apply {
put(KEY_enabled, enabled)
put(KEY_read, read)
put(KEY_share, share)

putOpt(KEY_filterDestination, filterDestination)
putOpt(KEY_filterEventName, filterEventName)
putOpt(KEY_filterParamData, filterParamData)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,35 +5,27 @@ import org.json.JSONException
import org.json.JSONObject

data class ApiCallsPermissionModel(
var enabled: Boolean = false,
var read: Boolean = false,
var share: Boolean = false,
var filterMethod: String? = null,
var filterUrl: String? = null
val enabled: Boolean = false,
val filterMethod: String? = null,
val filterUrl: String? = null
) {

companion object {
private const val KEY_enabled = "enabled"
private const val KEY_read = "read"
private const val KEY_share = "share"
private const val KEY_filterMethod = "filterMethod"
private const val KEY_filterUrl = "filterUrl"
}

@Throws(JSONException::class)
constructor(json: JSONObject) : this(
enabled = json.optBoolean(KEY_enabled, false),
read = json.optBoolean(KEY_read, false),
share = json.optBoolean(KEY_share, false),
filterMethod = json.getStringOrNull(KEY_filterMethod),
filterUrl = json.getStringOrNull(KEY_filterUrl)
)

fun toJsonObject(): JSONObject {
return JSONObject().apply {
put(KEY_enabled, enabled)
put(KEY_read, read)
put(KEY_share, share)
putOpt(KEY_filterMethod, filterMethod)
putOpt(KEY_filterUrl, filterUrl)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,14 @@ import com.evdayapps.madassistant.common.kotlinx.getStringOrNull
import org.json.JSONObject

data class ExceptionsPermissionModel(
var enabled: Boolean = false,
var read: Boolean = false,
var share: Boolean = false,
// Filters
var filterType: String? = null,
var filterMessage: String? = null,
// Crashes
var crashesEnabled: Boolean = false,
val enabled: Boolean = false,
val filterType: String? = null,
val filterMessage: String? = null,
val logCrashes: Boolean = false,
) {

companion object {
private const val KEY_enabled = "enabled"
private const val KEY_read = "read"
private const val KEY_share = "share"
private const val KEY_filterType = "filterType"
private const val KEY_filterMessage = "filterMessage"
private const val KEY_logCrashes = "logCrashes"
Expand All @@ -26,19 +20,15 @@ data class ExceptionsPermissionModel(
@Throws(Exception::class)
constructor(json: JSONObject) : this(
enabled = json.optBoolean(KEY_enabled, false),
read = json.optBoolean(KEY_read, false),
share = json.optBoolean(KEY_share, false),
crashesEnabled = json.optBoolean(KEY_logCrashes, false),
logCrashes = json.optBoolean(KEY_logCrashes, false),
filterType = json.getStringOrNull(KEY_filterType),
filterMessage = json.getStringOrNull(KEY_filterMessage)
)

fun toJsonObject(): JSONObject {
return JSONObject().apply {
put(KEY_enabled, enabled)
put(KEY_read, read)
put(KEY_share, share)

put(KEY_logCrashes, logCrashes)
putOpt(KEY_filterType, filterType)
putOpt(KEY_filterMessage, filterMessage)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,18 @@ import com.evdayapps.madassistant.common.kotlinx.getStringOrNull
import org.json.JSONObject

data class GenericLogsPermissionModel(
var enabled: Boolean = false,
var read: Boolean = false,
var share: Boolean = false,
var filterTag: String? = null,
var filterMessage: String? = null,
var logDebug: Boolean = true,
var logInfo: Boolean = true,
var logWarning: Boolean = true,
var logError: Boolean = true,
var logVerbose: Boolean = true
val enabled: Boolean = false,
val filterTag: String? = null,
val filterMessage: String? = null,
val logDebug: Boolean = false,
val logInfo: Boolean = false,
val logWarning: Boolean = false,
val logError: Boolean = false,
val logVerbose: Boolean = false
) {

companion object {
private const val KEY_enabled = "enabled"
private const val KEY_read = "read"
private const val KEY_share = "share"
private const val KEY_filterTag = "filterTag"
private const val KEY_filterMessage = "filterMessage"
private const val KEY_logVerbose = "logVerbose"
Expand All @@ -30,28 +26,20 @@ data class GenericLogsPermissionModel(
}

@Throws(Exception::class)
constructor(json: JSONObject) : this() {
json.run {
enabled = json.optBoolean(KEY_enabled, false)
read = json.optBoolean(KEY_read, false)
share = json.optBoolean(KEY_share, false)

filterTag = json.getStringOrNull(KEY_filterTag)
filterMessage = json.getStringOrNull(KEY_filterMessage)

logVerbose = json.optBoolean(KEY_logVerbose, false)
logInfo = json.optBoolean(KEY_logInfo, false)
logWarning = json.optBoolean(KEY_logWarning, false)
logError = json.optBoolean(KEY_logError, false)
logDebug = json.optBoolean(KEY_logDebug, false)
}
}
constructor(json: JSONObject) : this(
enabled = json.optBoolean(KEY_enabled, false),
filterTag = json.getStringOrNull(KEY_filterTag),
filterMessage = json.getStringOrNull(KEY_filterMessage),
logVerbose = json.optBoolean(KEY_logVerbose, false),
logInfo = json.optBoolean(KEY_logInfo, false),
logWarning = json.optBoolean(KEY_logWarning, false),
logError = json.optBoolean(KEY_logError, false),
logDebug = json.optBoolean(KEY_logDebug, false)
)

fun toJsonObject(): JSONObject {
return JSONObject().apply {
put(KEY_enabled, enabled)
put(KEY_read, read)
put(KEY_share, share)

put(KEY_logVerbose, logVerbose)
put(KEY_logInfo, logInfo)
Expand Down
Loading

0 comments on commit 0792af8

Please sign in to comment.