-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
197 additions
and
12 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
115 changes: 115 additions & 0 deletions
115
claims-transformation/date/CT_IsTermsOfUseConsentRequired.xml
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 @@ | ||
<?xml version="1.0" encoding="UTF-8" standalone="yes"?> | ||
<TrustFrameworkPolicy xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://schemas.microsoft.com/online/cpim/schemas/2013/06" PolicySchemaVersion="0.3.0.0" | ||
TenantId="yourtenant.onmicrosoft.com" | ||
PolicyId="B2C_1A_CT_IsTermsOfUseConsentRequired" | ||
PublicPolicyUri="http://yourtenant.onmicrosoft.com/B2C_1A_CT_IsTermsOfUseConsentRequired"> | ||
|
||
<BasePolicy> | ||
<TenantId>yourtenant.onmicrosoft.com</TenantId> | ||
<PolicyId>B2C_1A_TrustFrameworkExtensions</PolicyId> | ||
</BasePolicy> | ||
|
||
<BuildingBlocks> | ||
<ClaimsSchema> | ||
<ClaimType Id="dateTime1"> | ||
<DisplayName>First date (dateTime1)</DisplayName> | ||
<DataType>dateTime</DataType> | ||
<UserInputType>DateTimeDropdown</UserInputType> | ||
</ClaimType> | ||
<ClaimType Id="result"> | ||
<DisplayName>The result of this claims transformation (result)</DisplayName> | ||
<DataType>boolean</DataType> | ||
<UserInputType>Readonly</UserInputType> | ||
</ClaimType> | ||
</ClaimsSchema> | ||
|
||
<ClaimsTransformations> | ||
<ClaimsTransformation Id="CompareDates" TransformationMethod="IsTermsOfUseConsentRequired"> | ||
<InputClaims> | ||
<InputClaim ClaimTypeReferenceId="dateTime1" TransformationClaimType="termsOfUseConsentDateTime" /> | ||
</InputClaims> | ||
<InputParameters> | ||
<InputParameter Id="termsOfUseTextUpdateDateTime" DataType="dateTime" Value="2022-01-15T00:00:00" /> | ||
</InputParameters> | ||
<OutputClaims> | ||
<OutputClaim ClaimTypeReferenceId="result" TransformationClaimType="result" /> | ||
</OutputClaims> | ||
</ClaimsTransformation> | ||
</ClaimsTransformations> | ||
</BuildingBlocks> | ||
|
||
<ClaimsProviders> | ||
<ClaimsProvider> | ||
<DisplayName>Unit tests</DisplayName> | ||
<TechnicalProfiles> | ||
<TechnicalProfile Id="ExperimentalTechnicalProfile"> | ||
<DisplayName>Unit test</DisplayName> | ||
<Protocol Name="Proprietary" Handler="Web.TPEngine.Providers.SelfAssertedAttributeProvider, Web.TPEngine, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" /> | ||
<Metadata> | ||
<Item Key="ContentDefinitionReferenceId">api.selfasserted</Item> | ||
</Metadata> | ||
<InputClaims> | ||
<InputClaim ClaimTypeReferenceId="dateTime1" DefaultValue="2022-03-01T00:00:00.100000Z" AlwaysUseDefaultValue="true" /> | ||
</InputClaims> | ||
<OutputClaims> | ||
<OutputClaim ClaimTypeReferenceId="dateTime1" /> | ||
</OutputClaims> | ||
<OutputClaimsTransformations> | ||
<OutputClaimsTransformation ReferenceId="CompareDates" /> | ||
</OutputClaimsTransformations> | ||
<UseTechnicalProfileForSessionManagement ReferenceId="SM-Noop" /> | ||
</TechnicalProfile> | ||
|
||
<TechnicalProfile Id="ResultTechnicalProfile"> | ||
<DisplayName>Unit test</DisplayName> | ||
<Protocol Name="Proprietary" Handler="Web.TPEngine.Providers.SelfAssertedAttributeProvider, Web.TPEngine, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" /> | ||
<Metadata> | ||
<Item Key="ContentDefinitionReferenceId">api.selfasserted</Item> | ||
</Metadata> | ||
<InputClaims> | ||
<InputClaim ClaimTypeReferenceId="result" /> | ||
</InputClaims> | ||
<DisplayClaims> | ||
<DisplayClaim ClaimTypeReferenceId="result" /> | ||
</DisplayClaims> | ||
<UseTechnicalProfileForSessionManagement ReferenceId="SM-Noop" /> | ||
</TechnicalProfile> | ||
</TechnicalProfiles> | ||
</ClaimsProvider> | ||
</ClaimsProviders> | ||
|
||
<UserJourneys> | ||
<UserJourney Id="UnitTestJourney"> | ||
<OrchestrationSteps> | ||
<OrchestrationStep Order="1" Type="ClaimsExchange"> | ||
<ClaimsExchanges> | ||
<ClaimsExchange Id="ExperimentalTechnicalProfile" TechnicalProfileReferenceId="ExperimentalTechnicalProfile" /> | ||
</ClaimsExchanges> | ||
</OrchestrationStep> | ||
<OrchestrationStep Order="2" Type="ClaimsExchange"> | ||
<ClaimsExchanges> | ||
<ClaimsExchange Id="ResultTechnicalProfile" TechnicalProfileReferenceId="ResultTechnicalProfile" /> | ||
</ClaimsExchanges> | ||
</OrchestrationStep> | ||
<OrchestrationStep Order="3" Type="SendClaims" CpimIssuerTechnicalProfileReferenceId="JwtIssuer" /> | ||
</OrchestrationSteps> | ||
</UserJourney> | ||
</UserJourneys> | ||
|
||
<RelyingParty> | ||
<DefaultUserJourney ReferenceId="UnitTestJourney" /> | ||
<TechnicalProfile Id="PolicyProfile"> | ||
<DisplayName>PolicyProfile</DisplayName> | ||
<Protocol Name="OpenIdConnect" /> | ||
<OutputClaims> | ||
<OutputClaim ClaimTypeReferenceId="objectId" PartnerClaimType="sub" DefaultValue="1234" /> | ||
<OutputClaim ClaimTypeReferenceId="tenantId" AlwaysUseDefaultValue="true" DefaultValue="{Policy:TenantObjectId}" /> | ||
|
||
<!-- Unit test claims--> | ||
<OutputClaim ClaimTypeReferenceId="dateTime1" /> | ||
<OutputClaim ClaimTypeReferenceId="result" /> | ||
</OutputClaims> | ||
<SubjectNamingInfo ClaimType="sub" /> | ||
</TechnicalProfile> | ||
</RelyingParty> | ||
</TrustFrameworkPolicy> |
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 @@ | ||
# Date claims transformations unit tests | ||
|
||
This folder contains examples for Azure AD B2C date claims transformations unit tests. For more information, see [Date claims transformations](https://docs.microsoft.com/azure/active-directory-b2c/date-transformations). | ||
|
||
## AssertDateTimeIsGreaterThan | ||
|
||
Asserts whether the `date1` claim is greater than the `date2` claim. An error is thrown if `date2` is later than `date1`. The transformation treats values as equal if they are within 5 minutes (30000 milliseconds) difference. It won't throw an error if the values are equal because `AssertIfEqualTo` is set to `false`. | ||
|
||
The unit test defines the following elements: | ||
|
||
- **ExperimentalTechnicalProfile** - [self-asserted](https://docs.microsoft.com/azure/active-directory-b2c/self-asserted-technical-profile) technical profile. This technical profile renders the `date1` and `date2` claims with default values (you can change the values). Select *Continue* the run the **ExperimentalValidation** validation technical profile. | ||
- **ExperimentalValidation** - [claims transformation](https://docs.microsoft.com/azure/active-directory-b2c/claims-transformation-technical-profile) type of [validation technical profile](https://docs.microsoft.com/azure/active-directory-b2c/validation-technical-profile). This validation technical profile invokes the **AssertDates** claims transformation, which runs the assertion. | ||
- **AssertDates** claims transformation - the unit test. | ||
|
||
[Live demo](https://b2clivedemo.b2clogin.com/b2clivedemo.onmicrosoft.com/B2C_1A_CT_AssertDateTimeIsGreaterThan/oauth2/v2.0/authorize?client_id=cfaf887b-a9db-4b44-ac47-5efff4e2902c&nonce=defaultNonce&redirect_uri=https%3A%2F%2Fjwt.ms&scope=openid&response_type=id_token&prompt=login), [Quick deploy](https://b2ciefsetupapp.azurewebsites.net/), [documentation](https://docs.microsoft.com/azure/active-directory-b2c/date-transformations#assertdatetimeisgreaterthan) | ||
|
||
## ConvertDateTimeToDateClaim | ||
|
||
Converts the `dateTimeClaims` claim (type of dateTime), into `result` claim (type of date). After the claims transformation is completed the time part of the date will be removed. | ||
|
||
The unit test defines the following elements: | ||
|
||
- **ExperimentalTechnicalProfile** - [self-asserted](https://docs.microsoft.com/azure/active-directory-b2c/self-asserted-technical-profile) technical profile. This technical profile first calls the **GetSystemDateTime** adn **ConvertToDate** input claims transformations. Then, renders the `dateTimeClaims` with default value, and `result` claims with the result value of this claims transformation. | ||
- **GetSystemDateTime** claims transformation - Set default value to the `dateTimeClaims` claim using [GetCurrentDateTime](https://docs.microsoft.com/azure/active-directory-b2c/date-transformations#getcurrentdatetime) claims transformation. | ||
- **ConvertToDate** claims transformation - the unit test. | ||
|
||
[Live demo](https://b2clivedemo.b2clogin.com/b2clivedemo.onmicrosoft.com/B2C_1A_CT_ConvertDateTimeToDateClaim/oauth2/v2.0/authorize?client_id=cfaf887b-a9db-4b44-ac47-5efff4e2902c&nonce=defaultNonce&redirect_uri=https%3A%2F%2Fjwt.ms&scope=openid&response_type=id_token&prompt=login), [Quick deploy](https://b2ciefsetupapp.azurewebsites.net/), [documentation](https://docs.microsoft.com/azure/active-directory-b2c/date-transformations#convertdatetimetodateclaim) | ||
|
||
## ConvertDateToDateTimeClaim | ||
|
||
Converts the `dateClaim` claim (type of date), into `result` claim (type of dateTime). After the claims transformation is completed the 00:00:00 time will be added to the `result` claim. | ||
|
||
The unit test defines the following elements: | ||
|
||
- **ExperimentalTechnicalProfile** - [self-asserted](https://docs.microsoft.com/azure/active-directory-b2c/self-asserted-technical-profile) technical profile. This technical profile renders the `dateClaim` claim with default value (you can change the value). Then it calls the **ConvertToDateTime** output claims transformation to convert the date to dateTime. | ||
- **ConvertToDateTime** claims transformation - the unit test. | ||
|
||
[Live demo](https://b2clivedemo.b2clogin.com/b2clivedemo.onmicrosoft.com/B2C_1A_CT_ConvertDateToDateTimeClaim/oauth2/v2.0/authorize?client_id=cfaf887b-a9db-4b44-ac47-5efff4e2902c&nonce=defaultNonce&redirect_uri=https%3A%2F%2Fjwt.ms&scope=openid&response_type=id_token&prompt=login), [Quick deploy](https://b2ciefsetupapp.azurewebsites.net/), [documentation](https://docs.microsoft.com/azure/active-directory-b2c/date-transformations#convertdatetodatetimeclaim) | ||
|
||
## DateTimeComparison | ||
|
||
Determines if the `dateTime1` claim plus the `timeSpanInSeconds` parameter (5 seconds) is later than the `dateTime2` claim. The `result` claim is a new Boolean claim with a value of `true` or `false`. | ||
|
||
The unit test defines the following elements: | ||
|
||
- **ExperimentalTechnicalProfile** - [self-asserted](https://docs.microsoft.com/azure/active-directory-b2c/self-asserted-technical-profile) technical profile. This technical profile renders the `dateTime1` and `dateTime2` where you can choose the dates to compare. Then it runs the **CompareDates** output claims transformation. Select *Continue* the run the next orchestration step that shows the result. | ||
- **ResultTechnicalProfile** - [self-asserted](https://docs.microsoft.com/azure/active-directory-b2c/self-asserted-technical-profile) technical profile. This technical profile shows the `result` of this unit test. | ||
- **CompareDates** claims transformation - the unit test. | ||
|
||
[Live demo](https://b2clivedemo.b2clogin.com/b2clivedemo.onmicrosoft.com/B2C_1A_CT_DateTimeComparison/oauth2/v2.0/authorize?client_id=cfaf887b-a9db-4b44-ac47-5efff4e2902c&nonce=defaultNonce&redirect_uri=https%3A%2F%2Fjwt.ms&scope=openid&response_type=id_token&prompt=login), [Quick deploy](https://b2ciefsetupapp.azurewebsites.net/), [documentation](https://docs.microsoft.com/azure/active-directory-b2c/date-transformations#datetimecomparison) | ||
|
||
|
||
## GetCurrentDateTime | ||
|
||
Shows how to get the current data and time into the `result` claim. | ||
|
||
The unit test defines the following elements: | ||
|
||
- **ExperimentalTechnicalProfile** - [self-asserted](https://docs.microsoft.com/azure/active-directory-b2c/self-asserted-technical-profile) technical profile. This technical profile first calls the **GetResult** input claims transformation. Then, shows the `result` claim with the current date time. | ||
- **GetResult** claims transformation - the unit test. | ||
|
||
[Live demo](https://b2clivedemo.b2clogin.com/b2clivedemo.onmicrosoft.com/B2C_1A_CT_DateTimeComparison/oauth2/v2.0/authorize?client_id=cfaf887b-a9db-4b44-ac47-5efff4e2902c&nonce=defaultNonce&redirect_uri=https%3A%2F%2Fjwt.ms&scope=openid&response_type=id_token&prompt=login), [Quick deploy](https://b2ciefsetupapp.azurewebsites.net/), [documentation](https://docs.microsoft.com/azure/active-directory-b2c/date-transformations#datetimecomparison) | ||
|
||
## IsTermsOfUseConsentRequired | ||
|
||
Determines if the `dateTime1` easier than the `2022-01-15T00:00:00`. The `result` claim is a new Boolean claim with a value of `true` or `false`. If you select date that is later than `2022-01-15T00:00:00` the result will be `false`. Otherwise, it will be `true`. | ||
|
||
The unit test defines the following elements: | ||
|
||
- **ExperimentalTechnicalProfile** - [self-asserted](https://docs.microsoft.com/azure/active-directory-b2c/self-asserted-technical-profile) technical profile. This technical profile renders the `dateTime1` where you can choose a date to compare with `2022-01-15T00:00:00`. Then it runs the output claims transformation. Select *Continue* the run the next orchestration step that shows the result. | ||
- **ResultTechnicalProfile** - [self-asserted](https://docs.microsoft.com/azure/active-directory-b2c/self-asserted-technical-profile) technical profile. This technical profile shows the `result` of this unit test. | ||
- **CompareDates** claims transformation - the unit test. The `2022-01-15T00:00:00` date is configure in this claims transformation. | ||
|
||
[Live demo](https://b2clivedemo.b2clogin.com/b2clivedemo.onmicrosoft.com/B2C_1A_CT_ConvertDateTimeToDateClaim/oauth2/v2.0/authorize?client_id=cfaf887b-a9db-4b44-ac47-5efff4e2902c&nonce=defaultNonce&redirect_uri=https%3A%2F%2Fjwt.ms&scope=openid&response_type=id_token&prompt=login), [Quick deploy](https://b2ciefsetupapp.azurewebsites.net/), [documentation](https://docs.microsoft.com/azure/active-directory-b2c/date-transformations#istermsofuseconsentrequired). |