Skip to content
This repository was archived by the owner on Sep 3, 2025. It is now read-only.

Commit e9853d9

Browse files
committed
Merge branch 'main' into feature-accesspackageresourcerole
2 parents 31cf31f + fb43fe0 commit e9853d9

31 files changed

+2282
-101
lines changed

.github/workflows/golint.yaml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
---
2+
name: GoLang Linting
3+
on:
4+
pull_request:
5+
types: ["opened", "synchronize"]
6+
paths:
7+
- "**.go"
8+
- ".github/workflows/golint.yml"
9+
10+
jobs:
11+
golint:
12+
runs-on: ubuntu-latest
13+
steps:
14+
- uses: actions/checkout@v4
15+
16+
- uses: actions/setup-go@v5
17+
with:
18+
go-version-file: ./.go-version
19+
20+
- uses: golangci/golangci-lint-action@v4
21+
with:
22+
version: 'v1.57.1'
23+
24+
# vim: set ts=2 sts=2 sw=2 et:

.github/workflows/golint.yml

Lines changed: 0 additions & 27 deletions
This file was deleted.
Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ on:
66
paths:
77
- "msgraph/**.go"
88
- ".github/workflows/msgraph-tests.yml"
9+
workflow_dispatch:
910

1011
permissions:
1112
contents: 'read'
@@ -15,14 +16,11 @@ jobs:
1516
test-msgraph:
1617
runs-on: self-hosted
1718
steps:
18-
- uses: actions/checkout@v3
19+
- uses: actions/checkout@v4
1920

20-
- id: go-version
21-
run: echo "go_version=$(cat .go-version)" >>$GITHUB_OUTPUT
22-
23-
- uses: actions/setup-go@v3
21+
- uses: actions/setup-go@v5
2422
with:
25-
go-version: '${{ steps.go-version.outputs.go_version }}'
23+
go-version-file: ./.go-version
2624

2725
- run: go test -count=1 -race -v ./msgraph
2826
# env:
Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,21 +3,19 @@ name: Scheduled cleanup
33
on:
44
schedule:
55
- cron: "58 */6 * * *"
6+
workflow_dispatch:
67

78
jobs:
89
cleanup:
910
runs-on: self-hosted
1011
strategy:
1112
fail-fast: true
1213
steps:
13-
- uses: actions/checkout@v3
14+
- uses: actions/checkout@v4
1415

15-
- id: go-version
16-
run: echo "go_version=$(cat .go-version)" >>$GITHUB_OUTPUT
17-
18-
- uses: actions/setup-go@v3
16+
- uses: actions/setup-go@v5
1917
with:
20-
go-version: '${{ steps.go-version.outputs.go_version }}'
18+
go-version-file: ./.go-version
2119

2220
- run: go run ./internal/cmd/test-cleanup
2321

.go-version

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
1.19.2
1+
1.22.1

CHANGELOG.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,15 @@
1+
## v0.67.0 (Unreleased)
2+
3+
- Support for PIM Role Management [Policies](https://learn.microsoft.com/en-us/graph/api/resources/unifiedrolemanagementpolicy?view=graph-rest-1.0), [Rules](https://learn.microsoft.com/en-us/graph/api/resources/unifiedrolemanagementpolicyrule?view=graph-rest-1.0), and [Assignments](https://learn.microsoft.com/en-us/graph/api/resources/unifiedrolemanagementpolicyassignment?view=graph-rest-1.0) ([#277](https://github.com/manicminer/hamilton/pull/277))
4+
- Support for PIM Group Eligibility [Schedules](https://learn.microsoft.com/en-us/graph/api/resources/unifiedroleeligibilityschedule?view=graph-rest-1.0), [Instances](https://learn.microsoft.com/en-us/graph/api/resources/unifiedroleeligibilityscheduleinstance?view=graph-rest-1.0), and [Requests](https://learn.microsoft.com/en-us/graph/api/resources/unifiedroleeligibilityschedulerequest?view=graph-rest-1.0) ([#277](https://github.com/manicminer/hamilton/pull/277))
5+
- Support for PIM Group Assignment [Schedules]([https://learn.microsoft.com/en-us/graph/api/resources/unifiedroleeligibilityschedule?view=graph-rest-1.0](https://learn.microsoft.com/en-us/graph/api/resources/privilegedaccessgroupassignmentschedule?view=graph-rest-1.0)), [Instances]([https://learn.microsoft.com/en-us/graph/api/resources/unifiedroleeligibilityscheduleinstance?view=graph-rest-1.0](https://learn.microsoft.com/en-us/graph/api/resources/privilegedaccessgroupassignmentscheduleinstance?view=graph-rest-1.0)), and [Requests]([https://learn.microsoft.com/en-us/graph/api/resources/unifiedroleeligibilityschedulerequest?view=graph-rest-1.0](https://learn.microsoft.com/en-us/graph/api/resources/privilegedaccessgroupassignmentschedulerequest?view=graph-rest-1.0)) ([#277](https://github.com/manicminer/hamilton/pull/277))
6+
- Support for the `ApplicationFilter` field in the `ConditionalAccessApplications` model ([#268](https://github.com/manicminer/hamilton/pull/268))
7+
- Added `SkipExchangeInstantOn` to supported `msgraph.GroupResourceBehaviorOption` values ([#275](https://github.com/manicminer/hamilton/pull/275))
8+
9+
⚠️ BREAKING CHANGES:
10+
11+
- `ExpirationPatternDuration` has changed from a `*time.Duration` to a `*string` ([#276](https://github.com/manicminer/hamilton/pull/277))
12+
113
## v0.66.0 (January 25, 2024)
214

315
- This is a maintenance release to update to the latest published module for `github.com/hashicorp/go-azure-sdk/sdk` ([#272](https://github.com/manicminer/hamilton/pull/272))

GNUmakefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ test:
1818
tools:
1919
@echo "==> installing required tooling..."
2020
go install mvdan.cc/gofumpt@latest
21-
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b "$$(go env GOPATH || $$GOPATH)"/bin v1.50.0
21+
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b "$$(go env GOPATH || $$GOPATH)"/bin v1.57.1
2222

2323
todo:
2424
grep --color=always --exclude=GNUmakefile --exclude-dir=.git --exclude-dir=vendor --recursive TODO "$(CURDIR)"

README.md

Lines changed: 56 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -131,22 +131,74 @@ Please raise a pull request [on GitHub][gh-project] to submit contributions. Bug
131131

132132
## Testing
133133

134-
Testing requires an Azure AD tenant and real credentials. Note that some tests require an Azure AD Premium P2 license and/or an Office 365 license.
135-
You can authenticate with any supported method for the client tests, and the auth tests are split by authentication method.
134+
Testing requires at least one Azure AD tenant and real credentials.
135+
136+
Note that running all tests requires three separate tenants, and that some tests require an Azure AD Premium P2 license and/or an Office 365 license.
137+
138+
> ℹ️ You can sign up for the [Microsoft 365 Developer Program](https://developer.microsoft.com/en-us/microsoft-365/dev-program) which offers a Microsoft 365 E5 subscription for 25 users, at no cost for development purposes. That will suffice for most tests.
136139
137-
> ℹ️ You can sign up for the [Microsoft 365 Developer Program](https://developer.microsoft.com/en-us/microsoft-365/dev-program) which offers a Microsoft 365 E5 subscription for 25 users, at no cost for development purposes.
140+
It's recommended to use an isolated tenant for testing and _not_ a production tenant.
141+
142+
You can authenticate with any supported method for the client tests, and the auth tests are split by authentication method.
138143

139144
Note that each client generally has a single test that exercises all methods. This is to help ensure that test objects
140145
are cleaned up where possible. Where tests fail, often objects will be left behind and should be cleaned up separately.
141146
The [test-cleanup](https://github.com/manicminer/hamilton/tree/main/internal/cmd/test-cleanup) command can be used to
142147
delete leftover test objects in the event of test failure.
143148

144-
It's recommended to use an isolated tenant for testing and _not_ a production tenant.
149+
### Configuring single-tenant tests (eg. with a no-cost subscription from Microsoft 365 Developer Program)
150+
To set up environment variables:
151+
```shell
152+
az login --allow-no-subscriptions
153+
154+
# create one in the Azure Portal -> Entra ID -> App registrations -> New Registration
155+
# set "hamilton" as name, accept other defaults. Then copy Essentials -> Application (client) ID
156+
export CLIENT_ID=...
157+
# find this on the Azure Portal -> Entra ID -> Basic Information -> Tenant ID
158+
export TENANT_ID=...
159+
# find this on the Azure Portal -> Entra ID -> Basic Information -> Primary domain
160+
export TENANT_DOMAIN=...
161+
162+
export DEFAULT_TENANT_ID=${TENANT_ID}
163+
export DEFAULT_TENANT_DOMAIN=${TENANT_DOMAIN}
164+
export CONNECTED_TENANT_ID=${TENANT_ID}
165+
export CONNECTED_TENANT_DOMAIN=${TENANT_DOMAIN}
166+
export B2C_TENANT_ID=${TENANT_ID}
167+
export B2C_TENANT_DOMAIN=${TENANT_DOMAIN}
168+
```
169+
170+
To run one test (eg. `TestUsersClient`):
171+
```shell
172+
go test --race '-run=^TestUsersClient$' ./...
173+
```
174+
175+
176+
### Configuring and running all tests
177+
To set up environment variables:
178+
```shell
179+
az login
180+
181+
# find this on the Azure Portal -> Entra ID -> Basic Information -> Tenant ID
182+
export DEFAULT_TENANT_ID=...
183+
# find this on the Azure Portal -> Entra ID -> Basic Information -> Primary domain
184+
export DEFAULT_TENANT_DOMAIN=...
185+
186+
# same as above, but from a separate tenant, to run TestConnectedOrganizationClient
187+
export CONNECTED_TENANT_ID=...
188+
export CONNECTED_TENANT_DOMAIN=${TENANT_DOMAIN}
189+
190+
# same as above, but from yet another separate tenant, to run TestB2CUserFlowClient
191+
export B2C_TENANT_ID=${TENANT_ID}
192+
export B2C_TENANT_DOMAIN=${TENANT_DOMAIN}
193+
```
194+
195+
> ℹ️ View all supported environment variables in the [`envDefault()` testing helper function](https://github.com/manicminer/hamilton/blob/main/internal/test/testing.go).
145196
146197
To run all the tests:
147198
```shell
148199
$ make test
149200
```
150201

202+
151203
[gh-project]: https://github.com/manicminer/hamilton
152204
[ms-graph-docs]: https://docs.microsoft.com/en-us/graph/overview

internal/test/random.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,18 @@ import (
55
"time"
66
)
77

8+
var source *rand.Rand
9+
810
func init() {
9-
rand.Seed(time.Now().UnixNano())
11+
source = rand.New(rand.NewSource(time.Now().UnixNano()))
1012
}
1113

1214
// RandomString returns a random alphanumeric string useful for testing purposes.
1315
func RandomString() string {
1416
chars := []rune("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789")
1517
s := make([]rune, 8)
1618
for i := range s {
17-
s[i] = chars[rand.Intn(len(chars))]
19+
s[i] = chars[source.Intn(len(chars))]
1820
}
1921
return string(s)
2022
}

0 commit comments

Comments
 (0)