Skip to content

Latest commit

 

History

History

JSON claims transformations unit tests

This folder contains unit tests for Azure AD B2C JSON claims transformations. For more information, check out the Integer claims transformations article.

CreateJsonArray

Create a JSON single element array from the string1 claim value. The unit test defines the following elements:

  • ExperimentalTechnicalProfile - self-asserted technical profile. This technical profile renders the string1 claim with a default value (you can change the value). The output claims transformation CreateJsonPayload runs the unit test. Select Continue to run the next orchestration step that shows the result.
  • ResultTechnicalProfile - self-asserted technical profile. This technical profile shows the result of this unit test.
  • CreateJsonPayload claims transformation - the unit test.

live demo Live demo   Quick deploy Quick deploy   policy Policy   documentation Documentation

GenerateJson

Use the boolean1, dateTime1, int1, long1 and string1 claims and constants values to generate a JSON string. The path string following dot notation is used to indicate where to insert the data into a JSON string. The unit test defines the following elements:

  • ExperimentalTechnicalProfile - self-asserted technical profile. This technical profile renders the boolean1, dateTime1, int1, long1 and string1 claims claim with default values (you can change the values). Note, the long1 claim is initiated with a value but not presented. The output claims transformation GenerateJsonPayload runs the unit test. Select Continue to run the next orchestration step that shows the result.
  • ResultTechnicalProfile - self-asserted technical profile. This technical profile shows the result of this unit test.
  • GenerateJsonPayload claims transformation - the unit test.

live demo Live demo   Quick deploy Quick deploy   policy Policy   documentation Documentation

GetClaimFromJson

Gets the displayName (resultDisplayName claim), email (resultEmail claim), givenName (resultGivenName claim) and surname (resultSurname claim) from a JSON data. The results of this unit test are the resultDisplayName, resultEmail, resultGivenName, and resultSurname claims that contain extracted values. The unit test defines the following elements:

  • ExperimentalTechnicalProfile - self-asserted technical profile. This technical profile renders the inputJson claim with default JSON (you can change the JSON). Note, if the JSON isn't valid, or an element not found, the policy won't continue to the next step. The output claims transformations run the unit test. Select Continue to run the next orchestration step that shows the result.
  • ResultTechnicalProfile - self-asserted technical profile. This technical profile shows the result of this unit test.
  • GetDisplayNameClaimFromJson, GetEmailClaimFromJson, GetGivenNameClaimFromJson, GetSurnameClaimFromJson claims transformations - the unit test.

live demo Live demo   Quick deploy Quick deploy   policy Policy   documentation Documentation

GetClaimsFromJsonArray

Get the displayName (string), membershipID (int), active (boolean), and birthDate (dateTime) from the inputJson Json data. The unit test defines the following elements:

  • ExperimentalTechnicalProfile - self-asserted technical profile. This technical profile renders the inputJson claim with default JSON (you can change the JSON). Note, if the JSON isn't valid, or an element not found, the policy won't continue to the next step. Select Continue the run the validation technical profiles.
  • Validation technical profiles (type of claims transformation):
    • ExperimentalValidation-DontIncludeEmptyClaims - invokes the *GetClaimsFromJsonDontIncludeEmptyClaims claims transformation, which doesn't include empty claims.
    • ExperimentalValidation-IncludeEmptyClaims - invokes the *GetClaimsFromJsonIncludeEmptyClaims claims transformation, which includes empty claims.
  • Claims transformations:
    • GetClaimsFromJsonDontIncludeEmptyClaims claims transformation - the increment unit test.
    • GetClaimsFromJsonIncludeEmptyClaims claims transformation - the decrement unit test.

live demo Live demo   Quick deploy Quick deploy   policy Policy   documentation Documentation

GetClaimsFromJsonArrayV2

Get the displayName (string), membershipID (int), active (boolean), and birthDate (dateTime) from the inputJson a string collection JSON elements. The unit test defines the following elements:

  • ExperimentalTechnicalProfile - self-asserted technical profile. This technical profile renders the inputJson1, inputJson2, inputJson3, and inputJson4, claims with default JSON (you can change the JSON). Note, if the JSON aren't valid, or an element not found, the policy won't continue to the next step. Select Continue the run the validation technical profiles.
  • Claims transformations:
    • AddJsonToStringCollection1 adds the inputJson1 into the inputJsonStringCollection string collection.
    • AddJsonToStringCollection2 adds the inputJson2 into the inputJsonStringCollection string collection.
    • AddJsonToStringCollection3 adds the inputJson3 into the inputJsonStringCollection string collection.
    • AddJsonToStringCollection4 adds the inputJson4 into the inputJsonStringCollection string collection.
    • GetClaimsFromJson - the decrement unit test. It reads the values from the inputJsonStringCollection claims

live demo Live demo   Quick deploy Quick deploy   policy Policy   documentation Documentation

GetNumericClaimFromJson

Gets the id element from a JSON data. The result of this unit test is the result claim that contains extracted values. The unit test defines the following elements:

  • ExperimentalTechnicalProfile - self-asserted technical profile. This technical profile renders the inputJson claim with default JSON (you can change the JSON). Note, if the JSON isn't valid, or an element not found, the policy won't continue to the next step. The output claims transformations run the unit test. The output claims transformation GetIdFromJson runs the unit test. Select Continue to run the next orchestration step that shows the result.
  • ResultTechnicalProfile - self-asserted technical profile. This technical profile shows the result of this unit test.
  • GetIdFromJson claims transformations - the unit test.

live demo Live demo   Quick deploy Quick deploy   policy Policy   documentation Documentation

GetSingleItemFromJson

Gets the first element key (resultKey claim) and value (resultValue claim) from a JSON data. Note, you can change the name of the key and value to something else, by changing the claims transformation's output claims TransformationClaimType attribute. The unit test defines the following elements:

  • ExperimentalTechnicalProfile - self-asserted technical profile. This technical profile renders the inputJson claim with default JSON (you can change the JSON). Note, if the JSON isn't valid, or an element not found, the policy won't continue to the next step. The output claims transformations run the unit test. The output claims transformation GetKeyValueFromJson runs the unit test. Select Continue to run the next orchestration step that shows the result.
  • ResultTechnicalProfile - self-asserted technical profile. This technical profile shows the result of this unit test.
  • GetKeyValueFromJson claims transformations - the unit test.

live demo Live demo   Quick deploy Quick deploy   policy Policy   documentation Documentation

GetSingleValueFromJsonArray

Gets the first element from a JSON data array (inputJson claim). The result of this unit test is a result claim that contains the first element. The unit test defines the following elements:

  • ExperimentalTechnicalProfile - self-asserted technical profile. This technical profile renders the inputJson claim with default JSON (you can change the JSON). Note, if the JSON isn't valid, or an element not found, the policy won't continue to the next step. The output claims transformations run the unit test. The output claims transformation GetFirstItemFromJson runs the unit test. Select Continue to run the next orchestration step that shows the result.
  • ResultTechnicalProfile - self-asserted technical profile. This technical profile shows the result of this unit test.
  • GetFirstItemFromJson claims transformations - the unit test.

live demo Live demo   Quick deploy Quick deploy   policy Policy   documentation Documentation

XmlStringToJsonString

Converts the XML data (inputXML claim) to JSON format. The result of this unit test is a result claim that contains the JSON. The unit test defines the following elements:

  • ExperimentalTechnicalProfile - claims transformation technical profile. This technical profile sets the inputXML claim with default XML (you can change the XML). Note, if the XML isn't valid, or an element not found, the policy won't continue to the next step. The output claims transformations run the unit test. The output claims transformation ConvertXmlToJson runs the unit test. Select Continue to run the next orchestration step that shows the result.
  • ResultTechnicalProfile - self-asserted technical profile. This technical profile shows the result of this unit test.
  • ConvertXmlToJson claims transformations - the unit test.

live demo Live demo   Quick deploy Quick deploy   policy Policy   documentation Documentation