You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@james.apache.org by GitBox <gi...@apache.org> on 2021/11/22 02:45:14 UTC
[GitHub] [james-project] Arsnael commented on a change in pull request #754: JAMES-3534 Implement Identity/set update (custom identities)
Arsnael commented on a change in pull request #754:
URL: https://github.com/apache/james-project/pull/754#discussion_r753908847
##########
File path: server/protocols/jmap-rfc-8621-integration-tests/jmap-rfc-8621-integration-tests-common/src/main/scala/org/apache/james/jmap/rfc8621/contract/IdentitySetContract.scala
##########
@@ -662,4 +661,438 @@ trait IdentitySetContract {
|}""".stripMargin)
}
+ @Test
+ def updateShouldSucceed(): Unit = {
+ val identityId: String = createNewIdentity()
+ val response: String = `given`
+ .body(
+ s"""{
+ | "using": [ "urn:ietf:params:jmap:core", "urn:ietf:params:jmap:submission" ],
+ | "methodCalls": [
+ | [
+ | "Identity/set",
+ | {
+ | "accountId": "29883977c13473ae7cb7678ef767cbfbaffc8a44a6e463d971d23a65c1dc4af6",
+ | "update": {
+ | "$identityId": {
+ | "name": "NewName1"
+ | }
+ | }
+ | },
+ | "c1"
+ | ]
+ | ]
+ |}""".stripMargin)
+ .when
+ .post
+ .`then`
+ .statusCode(SC_OK)
+ .contentType(JSON)
+ .extract
+ .body
+ .asString
+
+ assertThatJson(response)
+ .isEqualTo(
+ s"""{
+ | "sessionState": "${SESSION_STATE.value}",
+ | "methodResponses": [
+ | [
+ | "Identity/set",
+ | {
+ | "accountId": "29883977c13473ae7cb7678ef767cbfbaffc8a44a6e463d971d23a65c1dc4af6",
+ | "newState": "2c9f1b12-b35a-43e6-9af2-0106fb53a943",
+ | "updated": {
+ | "$identityId": {}
+ | }
+ | },
+ | "c1"
+ | ]
+ | ]
+ |}
+ |""".stripMargin)
+ }
+
+ @Test
+ def updateShouldModifiedIdentityEntry(): Unit = {
Review comment:
```suggestion
def updateShouldModifyIdentityEntry(): Unit = {
```
##########
File path: server/protocols/jmap-rfc-8621-integration-tests/jmap-rfc-8621-integration-tests-common/src/main/scala/org/apache/james/jmap/rfc8621/contract/IdentitySetContract.scala
##########
@@ -662,4 +661,438 @@ trait IdentitySetContract {
|}""".stripMargin)
}
+ @Test
+ def updateShouldSucceed(): Unit = {
+ val identityId: String = createNewIdentity()
+ val response: String = `given`
+ .body(
+ s"""{
+ | "using": [ "urn:ietf:params:jmap:core", "urn:ietf:params:jmap:submission" ],
+ | "methodCalls": [
+ | [
+ | "Identity/set",
+ | {
+ | "accountId": "29883977c13473ae7cb7678ef767cbfbaffc8a44a6e463d971d23a65c1dc4af6",
+ | "update": {
+ | "$identityId": {
+ | "name": "NewName1"
+ | }
+ | }
+ | },
+ | "c1"
+ | ]
+ | ]
+ |}""".stripMargin)
+ .when
+ .post
+ .`then`
+ .statusCode(SC_OK)
+ .contentType(JSON)
+ .extract
+ .body
+ .asString
+
+ assertThatJson(response)
+ .isEqualTo(
+ s"""{
+ | "sessionState": "${SESSION_STATE.value}",
+ | "methodResponses": [
+ | [
+ | "Identity/set",
+ | {
+ | "accountId": "29883977c13473ae7cb7678ef767cbfbaffc8a44a6e463d971d23a65c1dc4af6",
+ | "newState": "2c9f1b12-b35a-43e6-9af2-0106fb53a943",
+ | "updated": {
+ | "$identityId": {}
+ | }
+ | },
+ | "c1"
+ | ]
+ | ]
+ |}
+ |""".stripMargin)
+ }
+
+ @Test
+ def updateShouldModifiedIdentityEntry(): Unit = {
+ val identityId: String = createNewIdentity()
+ val response: String = `given`
+ .body(
+ s"""{
+ | "using": [
+ | "urn:ietf:params:jmap:core",
+ | "urn:ietf:params:jmap:submission"
+ | ],
+ | "methodCalls": [
+ | [
+ | "Identity/set",
+ | {
+ | "accountId": "29883977c13473ae7cb7678ef767cbfbaffc8a44a6e463d971d23a65c1dc4af6",
+ | "update": {
+ | "$identityId": {
+ | "name": "NewName1",
+ | "replyTo": [
+ | {
+ | "name": "Difference Alice",
+ | "email": "alice2@domain.tld"
+ | }
+ | ],
+ | "bcc": [
+ | {
+ | "name": "Difference David",
+ | "email": "david2@domain.tld"
+ | }
+ | ],
+ | "textSignature": "Difference text signature",
+ | "htmlSignature": "<p>Difference html signature</p>"
+ | }
+ | }
+ | },
+ | "c1"
+ | ],
+ | [
+ | "Identity/get",
+ | {
+ | "accountId": "29883977c13473ae7cb7678ef767cbfbaffc8a44a6e463d971d23a65c1dc4af6",
+ | "ids": [
+ | "$identityId"
+ | ]
+ | },
+ | "c2"
+ | ]
+ | ]
+ |}""".stripMargin)
+ .when
+ .post
+ .`then`
+ .statusCode(SC_OK)
+ .contentType(JSON)
+ .extract
+ .body
+ .asString
+
+ assertThatJson(response)
+ .isEqualTo(
+ s"""{
+ | "sessionState": "${SESSION_STATE.value}",
+ | "methodResponses": [
+ | [
+ | "Identity/set",
+ | {
+ | "accountId": "29883977c13473ae7cb7678ef767cbfbaffc8a44a6e463d971d23a65c1dc4af6",
+ | "newState": "2c9f1b12-b35a-43e6-9af2-0106fb53a943",
+ | "updated": {
+ | "$identityId": { }
+ | }
+ | },
+ | "c1"
+ | ],
+ | [
+ | "Identity/get",
+ | {
+ | "accountId": "29883977c13473ae7cb7678ef767cbfbaffc8a44a6e463d971d23a65c1dc4af6",
+ | "state": "2c9f1b12-b35a-43e6-9af2-0106fb53a943",
+ | "list": [
+ | {
+ | "id": "$identityId",
+ | "name": "NewName1",
+ | "email": "bob@domain.tld",
+ | "replyTo": [
+ | {
+ | "name": "Difference Alice",
+ | "email": "alice2@domain.tld"
+ | }
+ | ],
+ | "bcc": [
+ | {
+ | "name": "Difference David",
+ | "email": "david2@domain.tld"
+ | }
+ | ],
+ | "textSignature": "Difference text signature",
+ | "htmlSignature": "<p>Difference html signature</p>",
+ | "mayDelete": true
+ | }
+ | ]
+ | },
+ | "c2"
+ | ]
+ | ]
+ |}""".stripMargin)
+ }
+
+ @Test
+ def updateShouldNotUpdatedWhenIdNotfound(): Unit = {
+ val notfoundIdentityId: String = UUID.randomUUID().toString
+ val response: String = `given`
+ .body(
+ s"""{
+ | "using": [ "urn:ietf:params:jmap:core", "urn:ietf:params:jmap:submission" ],
+ | "methodCalls": [
+ | [
+ | "Identity/set",
+ | {
+ | "accountId": "29883977c13473ae7cb7678ef767cbfbaffc8a44a6e463d971d23a65c1dc4af6",
+ | "update": {
+ | "$notfoundIdentityId": {
+ | "name": "NewName1"
+ | }
+ | }
+ | },
+ | "c1"
+ | ]
+ | ]
+ |}""".stripMargin)
+ .when
+ .post
+ .`then`
+ .statusCode(SC_OK)
+ .contentType(JSON)
+ .extract
+ .body
+ .asString
+
+ assertThatJson(response)
+ .isEqualTo(
+ s"""{
+ | "sessionState": "${SESSION_STATE.value}",
+ | "methodResponses": [
+ | [
+ | "Identity/set",
+ | {
+ | "accountId": "29883977c13473ae7cb7678ef767cbfbaffc8a44a6e463d971d23a65c1dc4af6",
+ | "newState": "2c9f1b12-b35a-43e6-9af2-0106fb53a943",
+ | "notUpdated": {
+ | "$notfoundIdentityId": {
+ | "type": "notFound",
+ | "description": "IdentityId($notfoundIdentityId) could not be found"
+ | }
+ | }
+ | },
+ | "c1"
+ | ]
+ | ]
+ |}""".stripMargin)
+ }
+
+ @Test
+ def updateShouldNotUpdatedWhenIdNotParsed(): Unit = {
+ val notParsedId: String = "k123"
+ val response: String = `given`
+ .body(
+ s"""{
+ | "using": [ "urn:ietf:params:jmap:core", "urn:ietf:params:jmap:submission" ],
+ | "methodCalls": [
+ | [
+ | "Identity/set",
+ | {
+ | "accountId": "29883977c13473ae7cb7678ef767cbfbaffc8a44a6e463d971d23a65c1dc4af6",
+ | "update": {
+ | "$notParsedId": {
+ | "name": "NewName1"
+ | }
+ | }
+ | },
+ | "c1"
+ | ]
+ | ]
+ |}""".stripMargin)
+ .when
+ .post
+ .`then`
+ .statusCode(SC_OK)
+ .contentType(JSON)
+ .extract
+ .body
+ .asString
+
+ assertThatJson(response)
+ .isEqualTo(
+ s"""{
+ | "sessionState": "${SESSION_STATE.value}",
+ | "methodResponses": [
+ | [
+ | "Identity/set",
+ | {
+ | "accountId": "29883977c13473ae7cb7678ef767cbfbaffc8a44a6e463d971d23a65c1dc4af6",
+ | "newState": "2c9f1b12-b35a-43e6-9af2-0106fb53a943",
+ | "notUpdated": {
+ | "$notParsedId": {
+ | "type": "invalidArguments",
+ | "description": "Invalid UUID string: $notParsedId"
+ | }
+ | }
+ | },
+ | "c1"
+ | ]
+ | ]
+ |}""".stripMargin)
+ }
+
+ @Test
+ def updateShouldNotUpdatedWhenAssignServerSetProperty(): Unit = {
+ val identityId: String = createNewIdentity()
+ val response: String = `given`
+ .body(
+ s"""{
+ | "using": [ "urn:ietf:params:jmap:core", "urn:ietf:params:jmap:submission" ],
+ | "methodCalls": [
+ | [
+ | "Identity/set",
+ | {
+ | "accountId": "29883977c13473ae7cb7678ef767cbfbaffc8a44a6e463d971d23a65c1dc4af6",
+ | "update": {
+ | "$identityId": {
+ | "email": "bob2@domain.tld"
+ | }
+ | }
+ | },
+ | "c1"
+ | ]
+ | ]
+ |}""".stripMargin)
+ .when
+ .post
+ .`then`
+ .statusCode(SC_OK)
+ .contentType(JSON)
+ .extract
+ .body
+ .asString
+
+ assertThatJson(response)
+ .isEqualTo(
+ s"""{
+ | "sessionState": "${SESSION_STATE.value}",
+ | "methodResponses": [
+ | [
+ | "Identity/set",
+ | {
+ | "accountId": "29883977c13473ae7cb7678ef767cbfbaffc8a44a6e463d971d23a65c1dc4af6",
+ | "newState": "2c9f1b12-b35a-43e6-9af2-0106fb53a943",
+ | "notUpdated": {
+ | "$identityId": {
+ | "type": "invalidArguments",
+ | "description": "Some server-set properties were specified",
+ | "properties": [
+ | "email"
+ | ]
+ | }
+ | }
+ | },
+ | "c1"
+ | ]
+ | ]
+ |}""".stripMargin)
+ }
+
+ @Test
+ def updateShouldSuccessWhenMixed(): Unit = {
+ val updateIdentityId1: String = createNewIdentity()
+ val updateIdentityId2: String = createNewIdentity()
+ val notUpdateIdentityId1: String = UUID.randomUUID().toString
+ val notUpdateIdentityId2: String = "notParsedId"
+
+ val response: String = `given`
+ .body(
+ s"""{
+ | "using": [ "urn:ietf:params:jmap:core", "urn:ietf:params:jmap:submission" ],
+ | "methodCalls": [
+ | [
+ | "Identity/set",
+ | {
+ | "accountId": "29883977c13473ae7cb7678ef767cbfbaffc8a44a6e463d971d23a65c1dc4af6",
+ | "update": {
Review comment:
indent
##########
File path: server/protocols/jmap-rfc-8621-integration-tests/jmap-rfc-8621-integration-tests-common/src/main/scala/org/apache/james/jmap/rfc8621/contract/IdentitySetContract.scala
##########
@@ -662,4 +661,438 @@ trait IdentitySetContract {
|}""".stripMargin)
}
+ @Test
+ def updateShouldSucceed(): Unit = {
+ val identityId: String = createNewIdentity()
+ val response: String = `given`
+ .body(
+ s"""{
+ | "using": [ "urn:ietf:params:jmap:core", "urn:ietf:params:jmap:submission" ],
+ | "methodCalls": [
+ | [
+ | "Identity/set",
+ | {
+ | "accountId": "29883977c13473ae7cb7678ef767cbfbaffc8a44a6e463d971d23a65c1dc4af6",
+ | "update": {
Review comment:
indent
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@james.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@james.apache.org
For additional commands, e-mail: notifications-help@james.apache.org