-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[buddy] Truncate AssumeRole session name to API limits (#45202)
* 44833 Truncate AssumeRole session name to API limits * Link reference Co-authored-by: STeve (Xin) Huang <[email protected]> * Hash the username and add audit log * review comments * remove audit --------- Co-authored-by: Joao Ubaldo <[email protected]>
- Loading branch information
1 parent
cafb1ef
commit ec46b01
Showing
4 changed files
with
68 additions
and
4 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -487,3 +487,33 @@ func TestResourceARN(t *testing.T) { | |
}) | ||
} | ||
} | ||
|
||
func TestMaybeHashRoleSessionName(t *testing.T) { | ||
for _, tt := range []struct { | ||
name string | ||
role string | ||
expected string | ||
}{ | ||
{ | ||
name: "role session name not hashed, less than 64 characters", | ||
role: "MyRole", | ||
expected: "MyRole", | ||
}, | ||
{ | ||
name: "role session name not hashed, exactly 64 characters", | ||
role: "Role123456789012345678901234567890123456789012345678901234567890", | ||
expected: "Role123456789012345678901234567890123456789012345678901234567890", | ||
}, | ||
{ | ||
name: "role session name hashed, longer than 64 characters", | ||
role: "remote-raimundo.oliveira@abigcompany.com-teleport.abigcompany.com", | ||
expected: "[email protected]", | ||
}, | ||
} { | ||
t.Run(tt.name, func(t *testing.T) { | ||
actual := MaybeHashRoleSessionName(tt.role) | ||
require.Equal(t, tt.expected, actual) | ||
require.LessOrEqual(t, len(actual), MaxRoleSessionNameLength) | ||
}) | ||
} | ||
} |
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