From 6a4a7c5182fbce05ebd06a013c3dd99c8701ef9a Mon Sep 17 00:00:00 2001 From: Sattvik Chakravarthy Date: Fri, 20 Oct 2023 13:05:30 +0530 Subject: [PATCH] fix: tests --- .../multitenancy/MfaConfig.java | 30 ++++++++++++------- 1 file changed, 19 insertions(+), 11 deletions(-) diff --git a/src/main/java/io/supertokens/pluginInterface/multitenancy/MfaConfig.java b/src/main/java/io/supertokens/pluginInterface/multitenancy/MfaConfig.java index c2157d63..e73ddd05 100644 --- a/src/main/java/io/supertokens/pluginInterface/multitenancy/MfaConfig.java +++ b/src/main/java/io/supertokens/pluginInterface/multitenancy/MfaConfig.java @@ -32,23 +32,31 @@ public MfaConfig(@Nullable String[] firstFactors, @Nullable String[] defaultRequ this.defaultRequiredFactorIds = defaultRequiredFactorIds; } - @Override - public boolean equals(Object other) { - if (other == null) { + private boolean compareStrArray(String[] arr1, String[] arr2) { + if (arr1 == null && arr2 == null) { + return true; + } + + if (arr1 == null || arr2 == null) { return false; } - if (other instanceof MfaConfig) { - Set thisFirstFactors = Set.of(this.firstFactors); - Set otherFirstFactors = Set.of(((MfaConfig) other).firstFactors); + Set set1 = Set.of(arr1); + Set set2 = Set.of(arr2); - Set thisdefaultRequiredFactorIds = Set.of(this.defaultRequiredFactorIds); - Set otherdefaultRequiredFactorIds = Set.of(((MfaConfig) other).defaultRequiredFactorIds); + return set1.equals(set2); + } - return thisFirstFactors.equals(otherFirstFactors) && - thisdefaultRequiredFactorIds.equals(otherdefaultRequiredFactorIds); + @Override + public boolean equals(Object other) { + if (other == null) { + return false; + } + if (!(other instanceof MfaConfig)) { + return false; } - return false; + return compareStrArray(this.firstFactors, ((MfaConfig) other).firstFactors) && + compareStrArray(this.defaultRequiredFactorIds, ((MfaConfig) other).defaultRequiredFactorIds); } }