-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(test-utils): improve cluster testing
- Add support for configuring replica authentication with 'masterauth' - Allow default client configuration during test cluster creation This improves the testing framework's flexibility by automatically configuring replica authentication when '--requirepass' is used and enabling custom client configurations across cluster nodes.
- Loading branch information
1 parent
0ce5e7a
commit ac972bd
Showing
6 changed files
with
93 additions
and
14 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
import { AuthenticationResult } from '@azure/msal-node'; | ||
import { IdentityProvider, StreamingCredentialsProvider, TokenManager, TokenResponse } from '@redis/authx'; | ||
import TestUtils from '@redis/test-utils'; | ||
import { EntraidCredentialsProvider } from './entraid-credentials-provider'; | ||
|
||
export const testUtils = new TestUtils({ | ||
dockerImageName: 'redis/redis-stack', | ||
dockerImageVersionArgument: 'redis-version', | ||
defaultDockerVersion: '7.4.0-v1' | ||
}); | ||
|
||
const DEBUG_MODE_ARGS = testUtils.isVersionGreaterThan([7]) ? | ||
['--enable-debug-command', 'yes'] : | ||
[]; | ||
|
||
const idp: IdentityProvider<AuthenticationResult> = { | ||
requestToken(): Promise<TokenResponse<AuthenticationResult>> { | ||
// @ts-ignore | ||
return Promise.resolve({ | ||
ttlMs: 100000, | ||
token: { | ||
accessToken: 'password' | ||
} | ||
}) | ||
} | ||
} | ||
|
||
const tokenManager = new TokenManager<AuthenticationResult>(idp, { expirationRefreshRatio: 0.8 }); | ||
const entraIdCredentialsProvider: StreamingCredentialsProvider = new EntraidCredentialsProvider(tokenManager, idp) | ||
|
||
const PASSWORD_WITH_REPLICAS = { | ||
serverArguments: ['--requirepass', 'password', ...DEBUG_MODE_ARGS], | ||
numberOfMasters: 2, | ||
numberOfReplicas: 1, | ||
clusterConfiguration: { | ||
defaults: { | ||
credentialsProvider: entraIdCredentialsProvider | ||
} | ||
} | ||
} | ||
|
||
export const GLOBAL = { | ||
CLUSTERS: { | ||
PASSWORD_WITH_REPLICAS | ||
} | ||
} |
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