This repository has been archived by the owner on Apr 21, 2022. It is now read-only.
forked from bitly/oauth2_proxy
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
53 additions
and
40 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 |
---|---|---|
@@ -0,0 +1,50 @@ | ||
// +build go1.3 | ||
// +build !plan9,!solaris,!windows | ||
|
||
// Turns out you can't copy over an existing file on Windows. | ||
|
||
package main | ||
|
||
import ( | ||
"io/ioutil" | ||
"os" | ||
"testing" | ||
) | ||
|
||
func (vt *ValidatorTest) UpdateEmailFileViaCopyingOver( | ||
t *testing.T, emails []string) { | ||
orig_file := vt.auth_email_file | ||
var err error | ||
vt.auth_email_file, err = ioutil.TempFile("", "test_auth_emails_") | ||
if err != nil { | ||
t.Fatal("failed to create temp file for copy: " + err.Error()) | ||
} | ||
vt.WriteEmails(t, emails) | ||
err = os.Rename(vt.auth_email_file.Name(), orig_file.Name()) | ||
if err != nil { | ||
t.Fatal("failed to copy over temp file: " + err.Error()) | ||
} | ||
vt.auth_email_file = orig_file | ||
} | ||
|
||
func TestValidatorOverwriteEmailListViaCopyingOver(t *testing.T) { | ||
vt := NewValidatorTest(t) | ||
defer vt.TearDown() | ||
|
||
vt.WriteEmails(t, []string{"[email protected]"}) | ||
domains := []string(nil) | ||
updated := make(chan bool) | ||
validator := newValidatorImpl(domains, vt.auth_email_file.Name(), | ||
func() { updated <- true }) | ||
|
||
if !validator("[email protected]") { | ||
t.Error("email in list should validate") | ||
} | ||
|
||
vt.UpdateEmailFileViaCopyingOver(t, []string{"[email protected]"}) | ||
<-updated | ||
|
||
if validator("[email protected]") { | ||
t.Error("email removed from list should not validate") | ||
} | ||
} |
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 |
---|---|---|
|
@@ -19,22 +19,6 @@ func (vt *ValidatorTest) UpdateEmailFile(t *testing.T, emails []string) { | |
vt.WriteEmails(t, emails) | ||
} | ||
|
||
func (vt *ValidatorTest) UpdateEmailFileViaCopyingOver( | ||
t *testing.T, emails []string) { | ||
orig_file := vt.auth_email_file | ||
var err error | ||
vt.auth_email_file, err = ioutil.TempFile("", "test_auth_emails_") | ||
if err != nil { | ||
t.Fatal("failed to create temp file for copy: " + err.Error()) | ||
} | ||
vt.WriteEmails(t, emails) | ||
err = os.Rename(vt.auth_email_file.Name(), orig_file.Name()) | ||
if err != nil { | ||
t.Fatal("failed to copy over temp file: " + err.Error()) | ||
} | ||
vt.auth_email_file = orig_file | ||
} | ||
|
||
func (vt *ValidatorTest) UpdateEmailFileViaRenameAndReplace( | ||
t *testing.T, emails []string) { | ||
orig_file := vt.auth_email_file | ||
|
@@ -98,28 +82,6 @@ func TestValidatorOverwriteEmailListDirectly(t *testing.T) { | |
} | ||
} | ||
|
||
func TestValidatorOverwriteEmailListViaCopyingOver(t *testing.T) { | ||
vt := NewValidatorTest(t) | ||
defer vt.TearDown() | ||
|
||
vt.WriteEmails(t, []string{"[email protected]"}) | ||
domains := []string(nil) | ||
updated := make(chan bool) | ||
validator := newValidatorImpl(domains, vt.auth_email_file.Name(), | ||
func() { updated <- true }) | ||
|
||
if !validator("[email protected]") { | ||
t.Error("email in list should validate") | ||
} | ||
|
||
vt.UpdateEmailFileViaCopyingOver(t, []string{"[email protected]"}) | ||
<-updated | ||
|
||
if validator("[email protected]") { | ||
t.Error("email removed from list should not validate") | ||
} | ||
} | ||
|
||
func TestValidatorOverwriteEmailListViaRenameAndReplace(t *testing.T) { | ||
vt := NewValidatorTest(t) | ||
defer vt.TearDown() | ||
|