-
-
Notifications
You must be signed in to change notification settings - Fork 44
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
1 changed file
with
59 additions
and
0 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 |
---|---|---|
@@ -0,0 +1,59 @@ | ||
package diam_test | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/KOSASIH/pi-nexus-autonomous-banking-network/diam" | ||
) | ||
|
||
func TestCreateIdentity(t *testing.T) { | ||
// Create a test DIAM node | ||
node := diam.NewDIAMNode() | ||
|
||
// Create a test identity | ||
identity := &diam.Identity{ | ||
ID: "user-1", | ||
Username: "john", | ||
Password: "password", | ||
} | ||
|
||
// Create the identity | ||
req := &diam.CreateIdentityRequest{ | ||
Identity: identity, | ||
} | ||
resp, err := node.CreateIdentity(context.Background(), req) | ||
|
||
// Check the response | ||
if err != nil { | ||
t.Errorf("failed to create identity: %v", err) | ||
} | ||
if resp.Identity.ID != identity.ID { | ||
t.Errorf("unexpected response: %v", resp) | ||
} | ||
} | ||
|
||
func TestAuthenticate(t *testing.T) { | ||
// Create a test DIAM node | ||
node := diam.NewDIAMNode() | ||
|
||
// Create a test identity | ||
identity := &diam.Identity{ | ||
ID: "user-1", | ||
Username: "john", | ||
Password: "password", | ||
} | ||
|
||
// Authenticate the identity | ||
req := &diam.AuthenticateRequest{ | ||
Identity: identity, | ||
} | ||
resp, err := node.Authenticate(context.Background(), req) | ||
|
||
// Check the response | ||
if err != nil { | ||
t.Errorf("failed to authenticate: %v", err) | ||
} | ||
if !resp.Authenticated { | ||
t.Errorf("unexpected response: %v", resp) | ||
} | ||
} |