@@ -0,0 +1,31 @@
|
||||
package deviceactivation
|
||||
|
||||
import "testing"
|
||||
|
||||
func TestCanTransition(t *testing.T) {
|
||||
allowed := [][2]State{{Factory, Claimable}, {Claimable, Bound}, {Bound, Provisioning}, {Provisioning, Active}, {Active, Lost}, {Lost, Active}, {Active, Claimable}, {Active, Provisioning}, {Bound, Revoked}}
|
||||
for _, edge := range allowed {
|
||||
if !CanTransition(edge[0], edge[1]) {
|
||||
t.Fatalf("expected %s -> %s to be allowed", edge[0], edge[1])
|
||||
}
|
||||
}
|
||||
rejected := [][2]State{{Factory, Active}, {Claimable, Active}, {Active, Bound}, {Revoked, Claimable}, {Lost, Provisioning}}
|
||||
for _, edge := range rejected {
|
||||
if CanTransition(edge[0], edge[1]) {
|
||||
t.Fatalf("expected %s -> %s to be rejected", edge[0], edge[1])
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestAllowsDeviceAuthentication(t *testing.T) {
|
||||
for _, state := range []string{"", "CLAIMABLE", "BOUND", "PROVISIONING", "ACTIVE"} {
|
||||
if !AllowsDeviceAuthentication(state) {
|
||||
t.Fatalf("expected %q to authenticate", state)
|
||||
}
|
||||
}
|
||||
for _, state := range []string{"FACTORY", "LOST", "REVOKED", "invalid"} {
|
||||
if AllowsDeviceAuthentication(state) {
|
||||
t.Fatalf("expected %q to be blocked", state)
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user