Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

xADDomainTrust: Missing unit test for the resource #324

Closed
johlju opened this issue Jun 6, 2019 · 3 comments · Fixed by #423
Closed

xADDomainTrust: Missing unit test for the resource #324

johlju opened this issue Jun 6, 2019 · 3 comments · Fixed by #423
Assignees
Labels
good first issue The issue should be easier to fix and can be taken up by a beginner to learn to contribute on GitHub tests The issue or pull request is about tests only.

Comments

@johlju
Copy link
Member

johlju commented Jun 6, 2019

We should add a unit test for this resource.

@johlju johlju added good first issue The issue should be easier to fix and can be taken up by a beginner to learn to contribute on GitHub help wanted The issue is up for grabs for anyone in the community. tests The issue or pull request is about tests only. labels Jun 6, 2019
@johlju johlju added this to To do in All issues and PR's via automation Jun 6, 2019
@johlju johlju removed the good first issue The issue should be easier to fix and can be taken up by a beginner to learn to contribute on GitHub label Jun 6, 2019
@johlju
Copy link
Member Author

johlju commented Jun 6, 2019

The resource xADDomainTrust looks like it is in need for a refactor as well.

@johlju johlju added the good first issue The issue should be easier to fix and can be taken up by a beginner to learn to contribute on GitHub label Jun 7, 2019
@johlju
Copy link
Member Author

johlju commented Jul 7, 2019

I looked into adding unit tests for this by adding stub C# classes for the namespace System.DirectoryServices.ActiveDirectory. But there is a problem that for example System.DirectoryServices.ActiveDirectory.Domain get loaded by PowerShell every time, so it is not possible to override it.

To solve that we have to move out code that references classes in the namespace System.DirectoryServices.ActiveDirectory into separate function so we can mock those functions. We should then be able to mock different return values so the different code paths can be tested. But it might end up not being able to be tested without running on a Domain Controller. 🤔

@johlju johlju added in progress The issue is being actively worked on by someone. and removed help wanted The issue is up for grabs for anyone in the community. labels Jul 9, 2019
@johlju johlju moved this from To do to In progress in Remove 'x' from module name Jul 9, 2019
@johlju johlju self-assigned this Jul 9, 2019
@johlju
Copy link
Member Author

johlju commented Jul 10, 2019

I'm currently finishing up refactoring this resource and completing unit tests, I will look into adding integration tests when I'm at it as I already have a lab setup with two forests.

johlju added a commit to johlju/ActiveDirectoryDsc that referenced this issue Jul 10, 2019
- Refactored the resource to enable unit tests, and at the same time changed
  it to use the same code pattern as the resource xADObjectEnabledState.
- Added unit tests (issue dsccommunity#324).
- Added comment-based help (issue dsccommunity#337).
johlju added a commit to johlju/ActiveDirectoryDsc that referenced this issue Jul 10, 2019
- Refactored the resource to enable unit tests, and at the same time changed
  it to use the same code pattern as the resource xADObjectEnabledState.
- Added unit tests (issue dsccommunity#324).
- Added comment-based help (issue dsccommunity#337).
johlju added a commit to johlju/ActiveDirectoryDsc that referenced this issue Jul 11, 2019
- Refactored the resource to enable unit tests, and at the same time changed
  it to use the same code pattern as the resource xADObjectEnabledState.
- Added unit tests (issue dsccommunity#324).
- Added comment-based help (issue dsccommunity#337).
johlju added a commit to johlju/ActiveDirectoryDsc that referenced this issue Jul 12, 2019
- Refactored the resource to enable unit tests, and at the same time changed
  it to use the same code pattern as the resource xADObjectEnabledState.
- Added unit tests (issue dsccommunity#324).
- Added comment-based help (issue dsccommunity#337).
All issues and PR's automation moved this from To do to Done Jul 13, 2019
Remove 'x' from module name automation moved this from In progress to Done Jul 13, 2019
johlju added a commit that referenced this issue Jul 13, 2019
- Changes to xActiveDirectory
  - Added new helper functions in xActiveDirectory.Common.
    - New-CimCredentialInstance
    - Add-TypeAssembly
    - New-ADDirectoryContext
- Changes to xADDomainTrust
  - Refactored the resource to enable unit tests, and at the same time changed
    it to use the same code pattern as the resource xADObjectEnabledState.
  - Added unit tests (issue #324).
  - Added comment-based help (issue #337).
  - Added integration tests (issue #348).
@johlju johlju removed the in progress The issue is being actively worked on by someone. label Jul 13, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue The issue should be easier to fix and can be taken up by a beginner to learn to contribute on GitHub tests The issue or pull request is about tests only.
Projects
Development

Successfully merging a pull request may close this issue.

1 participant