Best JavaScript code snippet using redwood
authenticationManagement.spec.ts
Source:authenticationManagement.spec.ts
1// tslint:disable:no-unused-expression2import * as chai from 'chai';3import {KeycloakAdminClient} from '../src/client';4import {credentials} from './constants';5import faker from 'faker';6import {RequiredActionAlias} from '../src/defs/requiredActionProviderRepresentation';7import {fail} from 'assert';8const expect = chai.expect;9describe('Authentication management', () => {10 let kcAdminClient: KeycloakAdminClient;11 let currentRealm: string;12 let requiredActionProvider: Record<string, any>;13 before(async () => {14 kcAdminClient = new KeycloakAdminClient();15 await kcAdminClient.auth(credentials);16 const realmName = faker.internet.userName().toLowerCase();17 await kcAdminClient.realms.create({18 id: realmName,19 realm: realmName,20 enabled: true,21 });22 currentRealm = realmName;23 kcAdminClient.setConfig({24 realmName,25 });26 });27 after(async () => {28 // delete test realm29 await kcAdminClient.realms.del({realm: currentRealm});30 const realm = await kcAdminClient.realms.findOne({31 realm: currentRealm,32 });33 expect(realm).to.be.null;34 });35 /**36 * Required Actions37 */38 describe('Required Actions', () => {39 it('should delete required action by alias', async () => {40 await kcAdminClient.authenticationManagement.deleteRequiredAction({41 alias: RequiredActionAlias.UPDATE_PROFILE,42 });43 });44 it('should get unregistered required actions', async () => {45 const unregisteredReqActions = await kcAdminClient.authenticationManagement.getUnregisteredRequiredActions();46 expect(unregisteredReqActions).to.be.an('array');47 expect(unregisteredReqActions.length).to.be.least(1);48 requiredActionProvider = unregisteredReqActions[0];49 });50 it('should register new required action', async () => {51 const requiredAction = await kcAdminClient.authenticationManagement.registerRequiredAction(52 {53 providerId: requiredActionProvider.providerId,54 name: requiredActionProvider.name,55 },56 );57 expect(requiredAction).to.be.empty;58 });59 it('should get required actions', async () => {60 const requiredActions = await kcAdminClient.authenticationManagement.getRequiredActions();61 expect(requiredActions).to.be.an('array');62 });63 it('should get required action by alias', async () => {64 const requiredAction = await kcAdminClient.authenticationManagement.getRequiredActionForAlias(65 {alias: requiredActionProvider.providerId},66 );67 expect(requiredAction).to.be.ok;68 });69 it('should update required action by alias', async () => {70 const requiredAction = await kcAdminClient.authenticationManagement.getRequiredActionForAlias(71 {alias: requiredActionProvider.providerId},72 );73 const response = await kcAdminClient.authenticationManagement.updateRequiredAction(74 {alias: requiredActionProvider.providerId},75 {76 ...requiredAction,77 enabled: true,78 priority: 10,79 },80 );81 expect(response).to.be.empty;82 });83 it('should lower required action priority', async () => {84 const requiredAction = await kcAdminClient.authenticationManagement.getRequiredActionForAlias(85 {alias: requiredActionProvider.providerId},86 );87 const response = await kcAdminClient.authenticationManagement.lowerRequiredActionPriority(88 {alias: requiredActionProvider.providerId},89 );90 expect(response).to.be.empty;91 const requiredActionUpdated = await kcAdminClient.authenticationManagement.getRequiredActionForAlias(92 {alias: requiredActionProvider.providerId},93 );94 expect(requiredActionUpdated.priority).to.be.greaterThan(95 requiredAction.priority,96 );97 });98 it('should raise required action priority', async () => {99 const requiredAction = await kcAdminClient.authenticationManagement.getRequiredActionForAlias(100 {alias: requiredActionProvider.providerId},101 );102 const response = await kcAdminClient.authenticationManagement.raiseRequiredActionPriority(103 {alias: requiredActionProvider.providerId},104 );105 expect(response).to.be.empty;106 const requiredActionUpdated = await kcAdminClient.authenticationManagement.getRequiredActionForAlias(107 {alias: requiredActionProvider.providerId},108 );109 expect(requiredActionUpdated.priority).to.be.lessThan(110 requiredAction.priority,111 );112 });113 it('should get client authenticator providers', async () => {114 const authenticationProviders = await kcAdminClient.authenticationManagement.getClientAuthenticatorProviders();115 expect(authenticationProviders).is.ok;116 expect(authenticationProviders.length).to.be.equal(4);117 });118 it('should fetch form providers', async () => {119 const formProviders = await kcAdminClient.authenticationManagement.getFormActionProviders();120 expect(formProviders).is.ok;121 expect(formProviders.length).to.be.eq(4);122 });123 it('should fetch authenticator providers', async () => {124 const providers = await kcAdminClient.authenticationManagement.getAuthenticatorProviders();125 expect(providers).is.ok;126 expect(providers.length).to.be.eq(36);127 });128 });129 describe('Flows', () => {130 it('should get the registered form providers', async () => {131 const formProviders = await kcAdminClient.authenticationManagement.getFormProviders();132 expect(formProviders).to.be.ok;133 expect(formProviders.length).to.be.eq(1);134 expect(formProviders[0].displayName).to.be.eq('Registration Page');135 });136 it('should get authentication flows', async () => {137 const flows = await kcAdminClient.authenticationManagement.getFlows();138 expect(flows.map((flow) => flow.alias)).to.be.deep.eq([139 'browser',140 'direct grant',141 'registration',142 'reset credentials',143 'clients',144 'first broker login',145 'docker auth',146 'http challenge',147 ]);148 });149 it('should get authentication flow', async () => {150 const flows = await kcAdminClient.authenticationManagement.getFlows();151 const flow = await kcAdminClient.authenticationManagement.getFlow({152 flowId: flows[0].id!,153 });154 expect(flow.alias).to.be.eq('browser');155 });156 it('should create new authentication flow', async () => {157 const flow = 'test';158 await kcAdminClient.authenticationManagement.createFlow({159 alias: flow,160 providerId: 'basic-flow',161 description: '',162 topLevel: true,163 builtIn: false,164 });165 const flows = await kcAdminClient.authenticationManagement.getFlows();166 expect(flows.find((f) => f.alias === flow)).to.be.ok;167 });168 const flowName = 'copy of browser';169 it('should copy existing authentication flow', async () => {170 await kcAdminClient.authenticationManagement.copyFlow({171 flow: 'browser',172 newName: flowName,173 });174 const flows = await kcAdminClient.authenticationManagement.getFlows();175 const flow = flows.find((f) => f.alias === flowName);176 expect(flow).to.be.ok;177 });178 it('should update authentication flow', async () => {179 const flows = await kcAdminClient.authenticationManagement.getFlows();180 const flow = flows.find((f) => f.alias === flowName)!;181 const description = 'Updated description';182 flow.description = description;183 const updatedFlow = await kcAdminClient.authenticationManagement.updateFlow(184 {flowId: flow.id!},185 flow,186 );187 expect(updatedFlow.description).to.be.eq(description);188 });189 it('should delete authentication flow', async () => {190 let flows = await kcAdminClient.authenticationManagement.getFlows();191 const flow = flows.find((f) => f.alias === flowName)!;192 await kcAdminClient.authenticationManagement.deleteFlow({193 flowId: flow.id!,194 });195 flows = await kcAdminClient.authenticationManagement.getFlows();196 expect(flows.find((f) => f.alias === flowName)).to.be.undefined;197 });198 });199 describe('Flow executions', () => {200 it('should fetch all executions for a flow', async () => {201 const executions = await kcAdminClient.authenticationManagement.getExecutions(202 {flow: 'browser'},203 );204 expect(executions.length).to.be.gt(5);205 });206 const flowName = 'executionTest';207 it('should add execution to a flow', async () => {208 await kcAdminClient.authenticationManagement.copyFlow({209 flow: 'browser',210 newName: flowName,211 });212 const execution = await kcAdminClient.authenticationManagement.addExecutionToFlow(213 {flow: flowName, provider: 'auth-otp-form'},214 );215 expect(execution.id).to.be.ok;216 });217 it('should add flow to a flow', async () => {218 const flow = await kcAdminClient.authenticationManagement.addFlowToFlow({219 flow: flowName,220 alias: 'subFlow',221 description: '',222 provider: 'registration-page-form',223 type: 'basic-flow',224 });225 const executions = await kcAdminClient.authenticationManagement.getExecutions(226 {flow: flowName},227 );228 expect(flow.id).to.be.ok;229 expect(executions.map((execution) => execution.displayName)).includes(230 'subFlow',231 );232 });233 it('should update execution to a flow', async () => {234 let executions = await kcAdminClient.authenticationManagement.getExecutions(235 {flow: flowName},236 );237 let execution = executions[executions.length - 1];238 const choice = execution.requirementChoices![1];239 execution.requirement = choice;240 await kcAdminClient.authenticationManagement.updateExecution(241 {flow: flowName},242 execution,243 );244 executions = await kcAdminClient.authenticationManagement.getExecutions({245 flow: flowName,246 });247 execution = executions[executions.length - 1];248 expect(execution.requirement).to.be.eq(choice);249 });250 it('should delete execution', async () => {251 let executions = await kcAdminClient.authenticationManagement.getExecutions(252 {flow: flowName},253 );254 const id = executions[0].id!;255 await kcAdminClient.authenticationManagement.delExecution({id});256 executions = await kcAdminClient.authenticationManagement.getExecutions({257 flow: flowName,258 });259 expect(executions.find((ex) => ex.id === id)).to.be.undefined;260 });261 it('should raise priority of execution', async () => {262 let executions = await kcAdminClient.authenticationManagement.getExecutions(263 {flow: flowName},264 );265 let execution = executions[executions.length - 1];266 const priority = execution.index!;267 await kcAdminClient.authenticationManagement.raisePriorityExecution({268 id: execution.id!,269 });270 executions = await kcAdminClient.authenticationManagement.getExecutions({271 flow: flowName,272 });273 execution = executions.find((ex) => ex.id === execution.id)!;274 expect(execution.index).to.be.eq(priority - 1);275 });276 it('should lower priority of execution', async () => {277 let executions = await kcAdminClient.authenticationManagement.getExecutions(278 {flow: flowName},279 );280 let execution = executions[0];281 const priority = execution.index!;282 await kcAdminClient.authenticationManagement.lowerPriorityExecution({283 id: execution.id!,284 });285 executions = await kcAdminClient.authenticationManagement.getExecutions({286 flow: flowName,287 });288 execution = executions.find((ex) => ex.id === execution.id)!;289 expect(execution.index).to.be.eq(priority + 1);290 });291 it('should create, update and delete config for execution', async () => {292 const execution = (293 await kcAdminClient.authenticationManagement.getExecutions({294 flow: flowName,295 })296 )[0];297 const alias = 'test';298 let config = await kcAdminClient.authenticationManagement.createConfig({299 id: execution.id,300 alias,301 });302 config = await kcAdminClient.authenticationManagement.getConfig({303 id: config.id!,304 });305 expect(config.alias).to.be.eq(alias);306 const extraConfig = {defaultProvider: 'sdf'};307 await kcAdminClient.authenticationManagement.updateConfig({308 ...config,309 config: extraConfig,310 });311 config = await kcAdminClient.authenticationManagement.getConfig({312 id: config.id!,313 });314 expect(config.config!.defaultProvider).to.be.eq(315 extraConfig.defaultProvider,316 );317 await kcAdminClient.authenticationManagement.delConfig({id: config.id!});318 try {319 await kcAdminClient.authenticationManagement.getConfig({id: config.id!});320 fail('should not find deleted config');321 } catch (error) {322 // ignore323 }324 });325 it('should fetch config description for execution', async () => {326 const execution = (327 await kcAdminClient.authenticationManagement.getExecutions({328 flow: flowName,329 })330 )[0];331 const configDescription = await kcAdminClient.authenticationManagement.getConfigDescription(332 {providerId: execution.providerId!},333 );334 expect(configDescription).is.ok;335 expect(configDescription.providerId).to.be.eq(execution.providerId);336 });337 });...
ControllerBatch.js
Source:ControllerBatch.js
1angular.module('myApp.common').controller("ControllerBatch",2function($scope, $http, Page, ServiceConfiguration) {3 Page.setTitle("Batchs");4 var batches = {5 "seloger" : {"jobName":"jobPasserelle-seloger.com"},6 "acimflo" : {"jobName":"jobPasserelle-acimflo"},7 "diaporama" : {"jobName":"jobPasserelle-diaporama"},8 "leboncoin" : {"jobName":"jobPasserelle-leboncoin"},9 "annoncesjaunes" : {"jobName":"jobPasserelle-annoncesjaunes"},10 "bienici" : {"jobName":"jobPasserelle-bienici"}11 }12 // Read jobs status13 $scope.jobs = {};14 getExecutions("annoncesjaunes");15 getExecutions("bienici");16 getExecutions("seloger");17 getExecutions("leboncoin");18 getExecutions("acimflo");19 getExecutions("diaporama");20 function getExecutions(name) {21 $http.get(ServiceConfiguration.API_URL+"/rest/batch/",22 {"params": {"jobName": batches[name].jobName}}23 ).success(function (data) {24 $scope.jobs[name]= data;25 });26 }...
ExecutionsContainer.js
Source:ExecutionsContainer.js
1import React, { useEffect } from 'react';2import { connect } from "react-redux";3import {4 getExecutions5} from "../../store/execution-action.js"6import Executions from './Executions.js';7function ExecutionsContainer({ getExecutions }) {8 useEffect(() => {9 getExecutions();10 }, [getExecutions])11 return <Executions />;12}13const mapStateToProps = state => ({14});...
Using AI Code Generation
1const redwood = require('redwood-client');2const client = new redwood.Client();3client.GetExecutions({id: '1'}, function(err, response) {4 if (err) {5 console.log(err);6 } else {7 console.log(response);8 }9});10const redwood = require('redwood-client');11const client = new redwood.Client();12client.GetExecutions({id: '1'}, function(err, response) {13 if (err) {14 console.log(err);15 } else {16 console.log(response);17 }18});19const redwood = require('redwood-client');20const client = new redwood.Client();21client.GetExecutions({id: '1'}, function(err, response) {22 if (err) {23 console.log(err);24 } else {25 console.log(response);26 }27});28const redwood = require('redwood-client');29const client = new redwood.Client();30client.GetExecutions({id: '1'}, function(err, response) {31 if (err) {32 console.log(err);33 } else {34 console.log(response);35 }36});37const redwood = require('redwood-client');38const client = new redwood.Client();39client.GetExecutions({id: '1'}, function(err, response) {40 if (err) {41 console.log(err);42 } else {43 console.log(response);44 }45});46const redwood = require('redwood-client');47const client = new redwood.Client();48client.GetExecutions({id: '1'}, function(err, response) {49 if (err) {50 console.log(err);51 } else {52 console.log(response);53 }54});55const redwood = require('redwood-client');56const client = new redwood.Client();57client.GetExecutions({id: '1'}, function(err, response) {58 if (err) {59 console.log(err);60 } else {61 console.log(response);62 }63});64const redwood = require('red
Using AI Code Generation
1var redwood = require('redwood');2var redwoodObj = new redwood.Redwood();3var getExecutionsRequest = new redwood.GetExecutionsRequest();4getExecutionsRequest.setWorkflowName("TestWorkflow");5getExecutionsRequest.setWorkflowVersion("1.0");6getExecutionsRequest.setWorkflowStatus("RUNNING");7getExecutionsRequest.setWorkflowId("TestWorkflowId");8getExecutionsRequest.setExecutionId("TestExecutionId");9getExecutionsRequest.setExecutionStatus("RUNNING");10getExecutionsRequest.setLastExecutedAfter("2014-04-01T00:00:00");11getExecutionsRequest.setLastExecutedBefore("2014-04-01T00:00:00");12getExecutionsRequest.setPageSize(10);13getExecutionsRequest.setNextPageToken("TestNextPageToken");14redwoodObj.getExecutions(getExecutionsRequest, function (err, data) {15 if (err) {16 console.log(err);17 }18 else {19 console.log(data);20 }21});22var redwood = require('redwood');23var redwoodObj = new redwood.Redwood();24var getExecutionHistoryRequest = new redwood.GetExecutionHistoryRequest();25getExecutionHistoryRequest.setExecutionId("TestExecutionId");26getExecutionHistoryRequest.setPageSize(10);27getExecutionHistoryRequest.setNextPageToken("TestNextPageToken");28redwoodObj.getExecutionHistory(getExecutionHistoryRequest, function (err, data) {29 if (err) {30 console.log(err);31 }32 else {33 console.log(data);34 }35});36var redwood = require('redwood');37var redwoodObj = new redwood.Redwood();
Using AI Code Generation
1var redwood = require('redwood');2var client = redwood.createClient({3});4client.getExecutions({query: 'select * from executions'}, function(err, res) {5 if (err) {6 console.log(err);7 } else {8 console.log(res);9 }10});11var redwood = require('redwood');12var client = redwood.createClient({13});14client.getExecutions({query: 'select * from executions where executionId = 1'}, function(err, res) {15 if (err) {16 console.log(err);17 } else {18 console.log(res);19 }20});21var redwood = require('redwood');22var client = redwood.createClient({23});24client.getExecutions({query: 'select * from executions where flowId = 1'}, function(err, res) {25 if (err) {26 console.log(err);27 } else {28 console.log(res);29 }30});
Using AI Code Generation
1var redwood = require('redwood');2var myRedwood = new redwood.Redwood("your_api_key");3myRedwood.GetExecutions(1, function (err, data) {4 if (err) {5 console.log(err);6 }7 else {8 console.log(data);9 }10});11var redwood = require('redwood');12var myRedwood = new redwood.Redwood("your_api_key");13myRedwood.GetExecutions(1, function (err, data) {14 if (err) {15 console.log(err);16 }17 else {18 console.log(data);19 }20});21var redwood = require('redwood');22var myRedwood = new redwood.Redwood("your_api_key");23myRedwood.GetExecutions(1, function (err, data) {24 if (err) {25 console.log(err);26 }27 else {28 console.log(data);29 }30});31var redwood = require('redwood');32var myRedwood = new redwood.Redwood("your_api_key");33myRedwood.GetExecutions(1, function (err, data) {34 if (err) {35 console.log(err);36 }37 else {38 console.log(data);39 }40});41var redwood = require('redwood');42var myRedwood = new redwood.Redwood("your_api_key");43myRedwood.GetExecutions(1, function (err, data) {44 if (err) {45 console.log(err);46 }47 else {48 console.log(data);49 }50});51var redwood = require('redwood');52var myRedwood = new redwood.Redwood("your_api_key");53myRedwood.GetExecutions(1, function (err, data) {54 if (err) {55 console.log(err);56 }57 else {58 console.log(data);59 }60});61var redwood = require('redwood');62var myRedwood = new redwood.Redwood("your_api_key");63myRedwood.GetExecutions(1, function (
Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!