azuretestsupport

package
v0.7.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 26, 2024 License: Apache-2.0 Imports: 17 Imported by: 0

README

Hexa

Azure - Testing Support

This package contains a testing Mock client that simulates calling Azure. Used by azad/azure_client_test and azureProvider tests.

Documentation

Index

Constants

View Source
const AzureAppId = "anAppId"
View Source
const AzureAppName = "anAppName"
View Source
const AzureSecret = "aSecret"
View Source
const AzureSubscription = "aSubscription"
View Source
const AzureTenantId = "aTenant"
View Source
const GraphApiBaseUrl = "https://graph.microsoft.com/v1.0"
View Source
const LoginMicrosoftOnlineUrl = "https://login.microsoftonline.com"
View Source
const ServicePrincipalId = "some-service-principal-id"

Variables

View Source
var ServicePrincipalsRespJson = fmt.Sprintf(`{"value": [
{
	"id": "%s",
	"displayName": "%s",
	"appRoles": [
		{
			"allowedMemberTypes": [
				"User"
			],
			"description": "Allows GET to the /humanresources/us",
			"displayName": "GetHR-US",
			"id": "%s",
			"isEnabled": true,
			"origin": "Application",
			"value": "%s"
		},
		{
			"allowedMemberTypes": [
				"User"
			],
			"description": "Allows GET to the /profile",
			"displayName": "AppRoleIdGetProfile",
			"id": "%s",
			"isEnabled": true,
			"origin": "Application",
			"value": "%s"
		}
	] 
}]}`, ServicePrincipalId, policytestsupport.PolicyObjectResourceId, AppRoleIdGetHrUs, policytestsupport.ActionGetHrUs, AppRoleIdGetProfile, policytestsupport.ActionGetProfile)

Functions

func AssignmentsForDelete

func AssignmentsForDelete(assignments []azad.AzureAppRoleAssignment) []azad.AzureAppRoleAssignment

func AssignmentsWithoutId

func AssignmentsWithoutId(assignments []azad.AzureAppRoleAssignment) []azad.AzureAppRoleAssignment

func AzureKey

func AzureKey() azurecommon.AzureKey

func AzureKeyBytes

func AzureKeyBytes() []byte

func AzureServicePrincipals

func AzureServicePrincipals() azad.AzureServicePrincipals

func AzureTokenCredential

func AzureTokenCredential(httpClient azurecommon.HTTPClient) azcore.TokenCredential

func MakeAssignments

func MakeAssignments(assignments []azad.AzureAppRoleAssignment) azad.AzureAppRoleAssignments

func MakePolicies

func MakePolicies(assignments []azad.AzureAppRoleAssignment) []hexapolicy.PolicyInfo

func NewAppRoleAssignments

func NewAppRoleAssignments(appRoleId AppRoleId, principalId string) azad.AzureAppRoleAssignment

Types

type AppRoleId

type AppRoleId string
const AppRoleIdGetHrUs AppRoleId = "app-role-get-hr-us"
const AppRoleIdGetProfile AppRoleId = "app-role-get-profile"

type AzureHttpClient

type AzureHttpClient struct {
	AppId              string
	TenantId           string
	ServicePrincipalId string
	MockHttpClient     *testsupport.MockHTTPClient
}

func NewAzureHttpClient

func NewAzureHttpClient() *AzureHttpClient

func (*AzureHttpClient) AppRoleAssignmentsUrl

func (ac *AzureHttpClient) AppRoleAssignmentsUrl() string

func (*AzureHttpClient) AzureClient

func (ac *AzureHttpClient) AzureClient() azad.AzureClient

func (*AzureHttpClient) DeleteAppRoleAssignmentsCalled

func (ac *AzureHttpClient) DeleteAppRoleAssignmentsCalled(deleted azad.AzureAppRoleAssignment) bool

func (*AzureHttpClient) DeleteAppRoleAssignmentsRequest

func (ac *AzureHttpClient) DeleteAppRoleAssignmentsRequest(toDelete []azad.AzureAppRoleAssignment)

func (*AzureHttpClient) ErrorRequest

func (ac *AzureHttpClient) ErrorRequest(method string, url string, expStatus int, body []byte)

func (*AzureHttpClient) GetAppRoleAssignmentsCalled

func (ac *AzureHttpClient) GetAppRoleAssignmentsCalled() bool

func (*AzureHttpClient) GetAppRoleAssignmentsRequest

func (ac *AzureHttpClient) GetAppRoleAssignmentsRequest(appRoleAssignments []azad.AzureAppRoleAssignment)

func (*AzureHttpClient) GetPrincipalIdFromEmailRequest

func (ac *AzureHttpClient) GetPrincipalIdFromEmailRequest(principalId string)

func (*AzureHttpClient) GetPrincipalIdFromEmailUrl

func (ac *AzureHttpClient) GetPrincipalIdFromEmailUrl(principalId string) string

func (*AzureHttpClient) GetServicePrincipalsRequest

func (ac *AzureHttpClient) GetServicePrincipalsRequest()

func (*AzureHttpClient) GetServicePrincipalsUrl

func (ac *AzureHttpClient) GetServicePrincipalsUrl() string

func (*AzureHttpClient) GetUserInfoFromPrincipalIdRequest

func (ac *AzureHttpClient) GetUserInfoFromPrincipalIdRequest(principalId string)

func (*AzureHttpClient) GetUserInfoFromPrincipalIdUrl

func (ac *AzureHttpClient) GetUserInfoFromPrincipalIdUrl(principalId string) string

func (*AzureHttpClient) GetWebApplicationsRequest

func (ac *AzureHttpClient) GetWebApplicationsRequest(expResp string)

func (*AzureHttpClient) PostAppRoleAssignmentsCalled

func (ac *AzureHttpClient) PostAppRoleAssignmentsCalled() bool

func (*AzureHttpClient) PostAppRoleAssignmentsRequest

func (ac *AzureHttpClient) PostAppRoleAssignmentsRequest()

func (*AzureHttpClient) TokenCalled

func (ac *AzureHttpClient) TokenCalled() bool

func (*AzureHttpClient) TokenRequest

func (ac *AzureHttpClient) TokenRequest(token string)

func (*AzureHttpClient) TokenUrl

func (ac *AzureHttpClient) TokenUrl() string

type MockAzureClient

type MockAzureClient struct {
	mock.Mock
}

func NewMockAzureClient

func NewMockAzureClient() *MockAzureClient

func (*MockAzureClient) ExpectAppRoleAssignedTo

func (m *MockAzureClient) ExpectAppRoleAssignedTo(assignments []azad.AzureAppRoleAssignment)

func (*MockAzureClient) ExpectGetAzureApplications

func (m *MockAzureClient) ExpectGetAzureApplications()

func (*MockAzureClient) ExpectGetPrincipalIdFromEmail

func (m *MockAzureClient) ExpectGetPrincipalIdFromEmail(email, principalId string)

func (*MockAzureClient) ExpectGetServicePrincipals

func (m *MockAzureClient) ExpectGetServicePrincipals()

func (*MockAzureClient) ExpectGetUserInfoFromPrincipalId

func (m *MockAzureClient) ExpectGetUserInfoFromPrincipalId(principalIds ...string)

func (*MockAzureClient) ExpectSetAppRoleAssignedTo

func (m *MockAzureClient) ExpectSetAppRoleAssignedTo(requestedAssignments []azad.AzureAppRoleAssignment)

func (*MockAzureClient) GetAppRoleAssignedTo

func (m *MockAzureClient) GetAppRoleAssignedTo(key []byte, servicePrincipalId string) (azad.AzureAppRoleAssignments, error)

func (*MockAzureClient) GetAzureApplications

func (m *MockAzureClient) GetAzureApplications(key []byte) ([]azad.AzureWebApp, error)

func (*MockAzureClient) GetPrincipalIdFromEmail

func (m *MockAzureClient) GetPrincipalIdFromEmail(key []byte, email string) (string, error)

func (*MockAzureClient) GetServicePrincipals

func (m *MockAzureClient) GetServicePrincipals(key []byte, appId string) (azad.AzureServicePrincipals, error)

func (*MockAzureClient) GetUserInfoFromPrincipalId

func (m *MockAzureClient) GetUserInfoFromPrincipalId(key []byte, principalId string) (azad.AzureUser, error)

func (*MockAzureClient) GetWebApplications

func (m *MockAzureClient) GetWebApplications(key []byte) ([]policyprovider.ApplicationInfo, error)

func (*MockAzureClient) SetAppRoleAssignedTo

func (m *MockAzureClient) SetAppRoleAssignedTo(key []byte, servicePrincipalId string, assignments []azad.AzureAppRoleAssignment) error

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL