-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #48 from crashappsec/nettrino/disableserver
- Loading branch information
Showing
10 changed files
with
88 additions
and
13 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
coverage.txt | ||
*.pem | ||
github-security-auditor.log | ||
github-analyzer | ||
|
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
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 |
---|---|---|
@@ -1 +1 @@ | ||
v0.1.3-pre-alpha-0-g76167ce | ||
v0.1.4-pre-alpha-5-g1722c63 |
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
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 |
---|---|---|
@@ -0,0 +1,56 @@ | ||
package auditor | ||
|
||
import ( | ||
"context" | ||
"os" | ||
"testing" | ||
"time" | ||
|
||
"github.com/crashappsec/github-analyzer/pkg/github/org" | ||
"github.com/google/go-github/v47/github" | ||
"github.com/jpillora/backoff" | ||
"github.com/stretchr/testify/assert" | ||
"golang.org/x/oauth2" | ||
) | ||
|
||
var ( | ||
client *github.Client | ||
|
||
// auth indicates whether tests are being run with an OAuth token. | ||
// Tests can use this flag to skip certain tests when run without auth. | ||
auth bool | ||
) | ||
|
||
func init() { | ||
token := os.Getenv("GH_SECURITY_AUDITOR_TOKEN") | ||
if token == "" { | ||
client = github.NewClient(nil) | ||
} else { | ||
tc := oauth2.NewClient(context.Background(), oauth2.StaticTokenSource( | ||
&oauth2.Token{AccessToken: token}, | ||
)) | ||
client = github.NewClient(tc) | ||
auth = true | ||
} | ||
} | ||
|
||
func TestSampleOrg(t *testing.T) { | ||
auditor := &GithubAuditor{client: client} | ||
ctx := context.Background() | ||
back := &backoff.Backoff{ | ||
Min: 30 * time.Second, | ||
Max: 3 * time.Minute, | ||
Jitter: true, | ||
} | ||
name := "github-security-auditor-test-org" | ||
org, err := org.NewOrganization(ctx, auditor.client, back, name) | ||
assert.Nil(t, err, "Could not create organization") | ||
assert.NotNil(t, org.CoreStats, "Could not fetch core stats") | ||
assert.Equal(t, name, *org.CoreStats.Login) | ||
assert.GreaterOrEqual(t, 1, org.CoreStats.TotalPrivateRepos) | ||
assert.NotNil( | ||
t, | ||
org.CoreStats.TwoFactorRequirementEnabled, | ||
"nil two factor auth", | ||
) | ||
} |