Giter VIP home page Giter VIP logo

unit-tests's Introduction

Azure Active Directory B2C features unit tests

In this repo, you will find samples for several of Azure AD B2C custom policy features.

Getting started

Prerequisites

Sample scenarios

Samples are available for the following categories:

Community Help and Support

Use Stack Overflow to get support from the community. Ask your questions on Stack Overflow first and browse existing issues to see if someone has asked your question before. Make sure that your questions or comments are tagged with [azure-ad-b2c]. If you find a bug in the sample, please raise the issue on GitHub Issues. To provide product feedback, visit the Azure Active Directory B2C Feedback page.

unit-tests's People

Contributors

imranliba506a avatar phaupt avatar yoelhor avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

unit-tests's Issues

User input types unit test not reproducible using the same policy

The B2C_1A_Claim_UserInputTypes_All live demo and all unit tests that have a TextBox user input type can not have the exact same self asserted input display reproduced by using the Claim_UserInputTypes_All.xml policy definition.

How to reproduce: Deploy the sample pack's TrustFrameworkBase, TrustFrameworkLocalization, and TrustFrameworkExtensions and then find and ensure the api.selfasserted ContentDefinition page version is set to 2.1.7 using the AzureBlue template to match the version found in the unit tests as such:

<!-- Ensure api.selfasserted in the sample pack's TrustFrameworkBase.xml matches the following: -->
<ContentDefinitions>
  <ContentDefinition Id="api.selfasserted">
    <LoadUri>~/tenant/templates/AzureBlue/selfAsserted.cshtml</LoadUri>
    <RecoveryUri>~/common/default_page_error.html</RecoveryUri>
    <DataUri>urn:com:microsoft:aad:b2c:elements:contract:selfasserted:2.1.7</DataUri>
  </ContentDefinition>
</ContentDefinitions>

This results in the following differences (unit test on the right, local on left), most notably the <label> element is completely missing on TextBox content types:
image

Can the TrustFrameworkBase.xml, TrustFrameworkLocalization.xml, TrustFrameworkExtensions.xml files, any template modifications or other configuration needed to reproduce these unit tests 1:1 please be added to this repository?

the azure AD Live demo fails with an error

live demo Live demo

AADB2C90289: We encountered an 'invalid_client' error connecting to the identity provider. Please try again later.
Correlation ID: 6eb66fe2-4201-43fa-a2a8-72b994757fa5
Timestamp: 2024-04-18 09:42:50Z

Number assertions with "equals" always fail

Repro steps:

Expected result: the transform would return TRUE for 20=20, 20<=20, 20>=20 instead of failing.

Azure B2c/ACA OIDC url callback convention

Greetings,

I've been attempting to wire up Azure Container App Service (ACA) with my B2C tenant and have run across an issue. ACA provides out of the box auth mechanisms for multiple identity providers including OIDC, AAD, Google, Apple etc. However, the callback url convention they've adopted requires a certain format, namely like so: https://.....xyz/.auth/login/aad/callback. What I've discovered through painful trial and error is that BC2 doesn't like the '.' in the callback url and when the case arises it falls back to a default callback url and simply ignores the user provided url. So, then the '/.auth ends getting overwritten with 'azure-ad-b2c'. Is this intentional and can it be overridden or addressed in some fashion?

Thx!

Unable to use {SAML:RelayState} and the example doesn't seem to use it either

I was linked to this repo from this guide:
https://learn.microsoft.com/en-us/azure/active-directory-b2c/claim-resolver-overview#saml

I am unable to see this line getting used in the policy:
https://github.com/azure-ad-b2c/unit-tests/blob/1e49bfcc94eb86a5b570a2efec1ad520882e0d56/claims-resolver/CR_SAML.xml#LL158C18-L158C18

I tried adding to the url to maybe make it show up like:
https://samltestapp2.azurewebsites.net/SP?abc=123

but I don't see how to create a situation in which that output claim is populated.

I have also tried using it in my own custom policy in both an SP and IdP initiated flows and can't seem to get it to work.

Can the test app be updated to show the RelayState claims resolver working?

Thanks

P.S. Unrelated but also important to me. If there was a claims resolver to get the ID attribute from the saml response or request that would be really useful? I'd like to use it to make sure a response in an IdP initiated SSO is only ever used once, but as of right now none of the claims resolvers give me something that would be unique per response which makes this difficult.

How to properly read from JSON data into AD B2C custom policy claims

I have a cartain issue regarding mapping from a JSON response into custom policy claims. I have been through many documentation and examples regarding JSON transformation and extracting claims from JSON, but could not find any hint on my specific JSON format. I am thankful for any solutions and hints, as I really don't know how to access the data within the JSON properly.

The JSON to extract claims from looks like this:
[{"account_id":"0925", "first_name":"TestFirst", "last_name":"TestLast", "mail":"[email protected]"}]

The only thing I want to achieve is to extract "account_id", "first_name", "last_name" and "mail" into claims to show them in the JWt issuer, like you have already provided similar approaches to other JSON extraction examples in your unit tests.

I really appreciate any guidance on this topic

Doc inconsistency for CompareClaimToValue transform

in unit-tests/claims-transformation/string/CT_CompareClaimToValue.xml

the CT "CheckStrings-Equal" doesn't conform to the documentation..

https://docs.microsoft.com/en-us/azure/active-directory-b2c/string-transformations#compareclaimtovalue

the input parameter 'ignoreCase' is documented as being DataType "boolean" but if you use boolean, you get an error similar to

"Message": "Execution of ClaimsTransformationImpl of Type "Microsoft.Cpim.Data.Transformations.EqualityTransformation" for TransformationMethod "CompareClaimToValue" of ClaimsTransformation with id "xxxxxxx" in policy "B2C_1A_P1_V1_SuSi_UAT" of tenant "xxxxxxxx.onmicrosoft.com" threw an exception with the following message: Unable to cast object of type 'System.Boolean' to type 'System.String'.",

  <ClaimsTransformation Id="CheckStrings-Equal" TransformationMethod="CompareClaimToValue">
        <InputClaims>
          <InputClaim ClaimTypeReferenceId="inputString" TransformationClaimType="inputClaim1" />
        </InputClaims>
        <InputParameters>
          <InputParameter Id="compareTo" DataType="string" Value="ABC" />
          <InputParameter Id="operator" DataType="string" Value="equal" />
          <InputParameter Id="ignoreCase" DataType="string" Value="true" />
        </InputParameters>
        <OutputClaims>
          <OutputClaim ClaimTypeReferenceId="result" TransformationClaimType="outputClaim" />
        </OutputClaims>
      </ClaimsTransformation>

So the code sample is correct, but the docs are incorrect on this point..

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.