Skip to content

Commit

Permalink
Create diam_test.go
Browse files Browse the repository at this point in the history
  • Loading branch information
KOSASIH authored Aug 7, 2024
1 parent 2885858 commit d626b8c
Showing 1 changed file with 59 additions and 0 deletions.
59 changes: 59 additions & 0 deletions tests/unit/diam_test.go
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)
}
}

0 comments on commit d626b8c

Please sign in to comment.