Skip to content

Commit

Permalink
Merge pull request #61 from sailpoint-oss/rz/dev
Browse files Browse the repository at this point in the history
PLTCONN-5210 assume external arn role
  • Loading branch information
ruifeng-zheng-sp authored Oct 8, 2024
2 parents 09633dd + 245a67f commit cd73253
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 3 deletions.
7 changes: 6 additions & 1 deletion lib/connector-customizer.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import { StandardCommand } from './commands'
import { CustomizerType, createConnectorCustomizer } from './connector-customizer'
import { Context } from './connector-handler'
import { Context, AssumeAwsRoleRequest, AssumeAwsRoleResponse } from './connector-handler'

class MockContext implements Context {
config = {}
Expand All @@ -12,6 +12,11 @@ class MockContext implements Context {
reloadConfig(): Promise<any> {
return Promise.resolve({})
}

assumeAwsRole(assumeAwsRoleRequest: AssumeAwsRoleRequest): Promise<AssumeAwsRoleResponse> {
return Promise.resolve(new AssumeAwsRoleResponse('ccessKeyId', 'secretAccessKey', 'sessionToken', 123))
}

}

const MOCK_CONTEXT = new MockContext()
Expand Down
24 changes: 23 additions & 1 deletion lib/connector-handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,30 @@ export interface Context {
[prop: string]: any

reloadConfig(): Promise<any>
assumeAwsRole(assumeAwsRoleRequest: AssumeAwsRoleRequest): Promise<AssumeAwsRoleResponse>;
}
export class AssumeAwsRoleRequest {
roleArn: string;
externalId : string;
roleSessionName :string;
constructor(roleArn: string, externalId: string, roleSessionName: string) {
this.roleArn = roleArn;
this.externalId = externalId;
this.roleSessionName = roleSessionName;
}
}
export class AssumeAwsRoleResponse {
accessKeyId: string;
secretAccessKey: string;
sessionToken: string;
expiration : number;
constructor(accessKeyId: string, secretAccessKey: string, sessionToken: string, expiration: number) {
this.accessKeyId = accessKeyId;
this.secretAccessKey = secretAccessKey;
this.sessionToken = sessionToken;
this.expiration = expiration;
}
}

export type StdAccountCreateHandler = (
context: Context,
input: StdAccountCreateInput,
Expand Down
6 changes: 5 additions & 1 deletion lib/connector.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { major } from 'semver'

import packageJson from '../package.json'
import { createConnectorCustomizer } from './connector-customizer'
import { Context } from './connector-handler'
import { Context, AssumeAwsRoleRequest, AssumeAwsRoleResponse } from './connector-handler'
import path from 'path'

const mockFS = require('mock-fs');
Expand All @@ -22,6 +22,10 @@ class MockContext implements Context {
reloadConfig(): Promise<any> {
return Promise.resolve({})
}

assumeAwsRole(assumeAwsRoleRequest: AssumeAwsRoleRequest): Promise<AssumeAwsRoleResponse> {
return Promise.resolve(new AssumeAwsRoleResponse('ccessKeyId', 'secretAccessKey', 'sessionToken', 123))
}
}

const MOCK_CONTEXT = new MockContext()
Expand Down

0 comments on commit cd73253

Please sign in to comment.